npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@neural-trader/core

v2.0.0

Published

Ultra-low latency neural trading engine with Rust + Node.js bindings

Downloads

221

Readme

Neural Trader 2.0 - Rust Implementation

CI Status codecov License npm version

High-performance algorithmic trading system written in Rust with Node.js bindings. Delivers 10-100x performance improvements over Python implementations while maintaining feature parity.

Features

  • 8 Trading Strategies: Momentum, Mean Reversion, Pairs Trading, Market Making, Statistical Arbitrage, ML-Enhanced, Risk Parity, Multi-Factor
  • Ultra-Low Latency: <200ms order execution, <50ms risk checks
  • Real-Time Risk Management: Position limits, drawdown controls, dynamic stops
  • AgentDB Integration: Self-learning with 150x faster vector search
  • Multi-Exchange Support: Alpaca, Binance, with extensible broker abstraction
  • Node.js Bindings: Use from JavaScript/TypeScript via napi-rs
  • CLI Interface: Comprehensive command-line tools
  • Production Ready: Docker, CI/CD, monitoring, observability

Performance Benchmarks

| Operation | Python | Rust | Speedup | |-----------|--------|------|---------| | Strategy Execution | 1,200ms | 150ms | 8x | | Risk Calculation | 450ms | 35ms | 13x | | Portfolio Rebalancing | 800ms | 60ms | 13x | | Backtesting (1 year) | 45min | 4min | 11x | | Memory Usage | 850MB | 45MB | 19x |

Quick Start

Installation

Via npm (Node.js) - Modular Packages

Neural Trader offers a plugin-style architecture - install only what you need!

Core Types (Required):

npm install @neural-trader/core

Functional Packages (install what you need):

# Backtesting
npm install @neural-trader/backtesting

# AI-Powered Forecasting
npm install @neural-trader/neural

# Risk Management
npm install @neural-trader/risk

# Trading Strategies
npm install @neural-trader/strategies

# Sports Betting & Prediction Markets
npm install @neural-trader/sports-betting @neural-trader/prediction-markets

# Full Platform (all features)
npm install neural-trader

Package Sizes:

  • @neural-trader/core: 3.4 KB (types only)
  • Individual packages: 250-1,200 KB each
  • Full platform: ~5 MB

See packages/README.md for complete package documentation.

Via Cargo (Rust)

cargo install neural-trader-cli

Via Docker

docker pull neuraltrader/neural-trader-rust:latest

Basic Usage

CLI

# Initialize a new strategy
neural-trader init my-strategy --template momentum

# Backtest the strategy
cd my-strategy
neural-trader backtest --start 2024-01-01 --end 2024-12-31

# Run live (paper trading)
neural-trader run --config config/production.toml --paper

Node.js

const { NeuralTrader, MomentumStrategy } = require('@neural-trader/core');

async function main() {
  // Initialize trader
  const trader = new NeuralTrader({
    apiKey: process.env.ALPACA_API_KEY,
    apiSecret: process.env.ALPACA_API_SECRET,
    paperTrading: true
  });

  // Create strategy
  const strategy = new MomentumStrategy({
    symbols: ['AAPL', 'MSFT', 'GOOGL'],
    lookbackPeriod: 20,
    minMomentum: 0.02
  });

  // Run strategy
  await trader.addStrategy(strategy);
  await trader.start();
}

main().catch(console.error);

Rust

use neural_trader::prelude::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize trader
    let config = Config::from_file(".config/production.toml")?;
    let mut trader = Trader::new(config).await?;

    // Create momentum strategy
    let strategy = MomentumStrategy::builder()
        .symbols(vec!["AAPL", "MSFT", "GOOGL"])
        .lookback_period(20)
        .min_momentum(0.02)
        .build()?;

    // Add strategy and run
    trader.add_strategy(Box::new(strategy)).await?;
    trader.run().await?;

    Ok(())
}

Architecture

┌─────────────────────────────────────────────────────────────┐
│                     Neural Trader Core                       │
├─────────────────────────────────────────────────────────────┤
│                                                               │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │   Market     │  │  Strategies  │  │  Execution   │       │
│  │   Data       │  │  Engine      │  │  Engine      │       │
│  └──────────────┘  └──────────────┘  └──────────────┘       │
│                                                               │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │  Portfolio   │  │     Risk     │  │   Neural     │       │
│  │  Manager     │  │   Manager    │  │   Engine     │       │
│  └──────────────┘  └──────────────┘  └──────────────┘       │
│                                                               │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │   AgentDB    │  │  Backtesting │  │  Governance  │       │
│  │   Client     │  │   Engine     │  │   System     │       │
│  └──────────────┘  └──────────────┘  └──────────────┘       │
│                                                               │
└─────────────────────────────────────────────────────────────┘
         │                    │                    │
         ▼                    ▼                    ▼
   ┌──────────┐        ┌──────────┐        ┌──────────┐
   │  NAPI    │        │   CLI    │        │  Docker  │
   │ Bindings │        │  Binary  │        │  Image   │
   └──────────┘        └──────────┘        └──────────┘

Workspace Structure

neural-trader-rust/
├── crates/
│   ├── core/              # Core types and traits
│   ├── market-data/       # Market data providers
│   ├── features/          # Technical indicators
│   ├── strategies/        # 8 trading strategies
│   ├── execution/         # Order execution
│   ├── portfolio/         # Portfolio management
│   ├── risk/              # Risk management
│   ├── backtesting/       # Backtesting engine
│   ├── neural/            # Neural network integration
│   ├── agentdb-client/    # AgentDB persistent memory
│   ├── streaming/         # Real-time data streaming
│   ├── governance/        # Governance and compliance
│   ├── cli/               # Command-line interface
│   ├── napi-bindings/     # Node.js bindings
│   └── utils/             # Shared utilities
├── .config/               # Configuration templates
├── tests/                 # Integration & E2E tests
├── benches/              # Performance benchmarks
├── examples/             # Usage examples
└── docs/                 # Documentation

Trading Strategies

1. Momentum Strategy

Captures price momentum using RSI, MACD, and moving averages.

MomentumStrategy::builder()
    .symbols(vec!["AAPL", "MSFT"])
    .lookback_period(20)
    .min_momentum(0.02)
    .build()?

2. Mean Reversion Strategy

Trades mean-reverting securities using Bollinger Bands and Z-scores.

MeanReversionStrategy::builder()
    .symbols(vec!["SPY", "QQQ"])
    .lookback_period(50)
    .z_score_threshold(2.0)
    .build()?

3. Pairs Trading Strategy

Statistical arbitrage on cointegrated pairs.

PairsTradingStrategy::builder()
    .pairs(vec![("AAPL", "MSFT"), ("GLD", "SLV")])
    .lookback_period(100)
    .entry_threshold(2.0)
    .exit_threshold(0.5)
    .build()?

4. Market Making Strategy

Provides liquidity with bid-ask spread capture.

MarketMakingStrategy::builder()
    .symbols(vec!["BTC/USDT"])
    .spread_bps(20)
    .order_size(0.1)
    .max_inventory(10.0)
    .build()?

5. Statistical Arbitrage

Multi-asset statistical relationships.

StatArbStrategy::builder()
    .basket(vec!["AAPL", "MSFT", "GOOGL", "AMZN"])
    .lookback_period(60)
    .z_score_threshold(2.5)
    .build()?

6. ML-Enhanced Strategy

Neural network predictions combined with traditional signals.

MLEnhancedStrategy::builder()
    .symbols(vec!["AAPL"])
    .model_path("models/lstm_predictor.onnx")
    .confidence_threshold(0.7)
    .build()?

7. Risk Parity Strategy

Portfolio allocation based on risk contribution.

RiskParityStrategy::builder()
    .universe(vec!["SPY", "TLT", "GLD", "VNQ"])
    .rebalance_frequency(Duration::days(30))
    .target_volatility(0.12)
    .build()?

8. Multi-Factor Strategy

Combines multiple factors (value, momentum, quality).

MultiFactorStrategy::builder()
    .universe(sp500_tickers())
    .factors(vec![
        Factor::Value { weight: 0.3 },
        Factor::Momentum { weight: 0.4 },
        Factor::Quality { weight: 0.3 }
    ])
    .rebalance_frequency(Duration::days(30))
    .build()?

Configuration

Configuration files use TOML format with environment variable substitution:

[environment]
name = "production"
log_level = "info"

[market_data.alpaca]
api_key = "${ALPACA_API_KEY}"
api_secret = "${ALPACA_API_SECRET}"

[risk]
max_portfolio_drawdown = 0.15
max_position_size = 0.10

See .config/README.md for full configuration documentation.

Development

Prerequisites

  • Rust 1.75+
  • Node.js 18+ (for npm package)
  • PostgreSQL 14+ (optional, for persistent storage)
  • Redis 7+ (optional, for caching)

Building from Source

# Clone repository
git clone https://github.com/ruvnet/neural-trader.git
cd neural-trader/neural-trader-rust

# Build all crates
cargo build --workspace

# Run tests
cargo test --workspace

# Run benchmarks
cargo bench --workspace

# Build Node.js bindings
npm run build

# Build Docker image
docker build -t neural-trader .

Running Tests

# Unit tests
cargo test --workspace

# Integration tests
cargo test --test '*' --workspace

# End-to-end tests
cargo test --test test_full_trading_loop

# Property tests
cargo test --test 'test_pnl' --features proptest

# With coverage
cargo tarpaulin --workspace --timeout 300

Running Benchmarks

# All benchmarks
cargo bench --workspace

# Specific benchmark
cargo bench --bench strategy_benchmarks

# Compare with baseline
cargo bench --workspace -- --save-baseline main

Docker Deployment

Using Docker Compose

# Start all services (app + postgres + redis + monitoring)
docker-compose up -d

# View logs
docker-compose logs -f neural-trader

# Stop services
docker-compose down

Standalone Container

# Run with configuration file
docker run -v $(pwd)/config.toml:/app/config.toml \
  -e ALPACA_API_KEY=$ALPACA_API_KEY \
  neuraltrader/neural-trader-rust:latest

# Run with environment variables only
docker run \
  -e DATABASE_URL=$DATABASE_URL \
  -e ALPACA_API_KEY=$ALPACA_API_KEY \
  neuraltrader/neural-trader-rust:latest

CI/CD

The project uses GitHub Actions for continuous integration:

  • Format Check: Ensures code formatting with rustfmt
  • Lint: Runs clippy for code quality
  • Test: Multi-platform tests (Linux/macOS/Windows, stable/nightly)
  • Coverage: Code coverage with tarpaulin
  • Security Audit: Dependency vulnerability scanning
  • License Check: Ensures license compliance
  • Benchmarks: Performance regression detection
  • Release: Automated binary builds and npm publishing

See .github/workflows/rust-ci.yml for details.

Monitoring and Observability

Metrics (Prometheus)

  • Request latency (p50, p95, p99)
  • Order execution time
  • Strategy performance
  • Risk metrics
  • System resources

Access at http://localhost:9090 (Prometheus) or http://localhost:3000 (Grafana).

Tracing (Jaeger)

Distributed tracing for request flows across services.

Access at http://localhost:16686.

Logging

Structured JSON logs with tracing integration:

tracing::info!(
    symbol = %order.symbol,
    quantity = order.quantity,
    price = %order.price,
    "Order executed successfully"
);

API Documentation

REST API

# Start server
neural-trader serve --port 8080

# Health check
curl http://localhost:8080/health

# Get portfolio
curl http://localhost:8080/api/v1/portfolio

# Submit order
curl -X POST http://localhost:8080/api/v1/orders \
  -H "Content-Type: application/json" \
  -d '{"symbol":"AAPL","quantity":10,"side":"buy"}'

WebSocket API

const ws = new WebSocket('ws://localhost:8080/ws');

ws.on('message', (data) => {
  const message = JSON.parse(data);
  console.log('Market data:', message);
});

ws.send(JSON.stringify({
  type: 'subscribe',
  symbols: ['AAPL', 'MSFT']
}));

AgentDB Integration

Neural Trader uses AgentDB for persistent memory and self-learning:

use neural_trader::agentdb::AgentDBClient;

// Store trading decision
client.store_memory(
    "decision",
    &json!({
        "strategy": "momentum",
        "action": "buy",
        "symbol": "AAPL",
        "confidence": 0.85
    })
).await?;

// Query similar past decisions
let similar = client.query_similar(
    "What were successful trades for AAPL?",
    5
).await?;

// Learn from outcomes
client.train_pattern(
    &decision_embedding,
    outcome.pnl,
    0.01  // learning rate
).await?;

License

This project is dual-licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/amazing-feature)
  3. Make changes and add tests
  4. Run tests and linting (cargo test && cargo clippy)
  5. Commit changes (git commit -m 'feat: add amazing feature')
  6. Push to branch (git push origin feat/amazing-feature)
  7. Open a Pull Request

Security

For security issues, please see SECURITY.md for our security policy and reporting process.

Support

  • Documentation: https://neural-trader.ruv.io
  • Issues: https://github.com/ruvnet/neural-trader/issues
  • Discord: https://discord.gg/neural-trader
  • Email: [email protected]

Roadmap

  • [ ] Additional exchanges (Coinbase, Kraken)
  • [ ] Options trading support
  • [ ] Advanced order types (iceberg, TWAP, VWAP)
  • [ ] Multi-account management
  • [ ] Backtesting UI dashboard
  • [ ] Mobile app for monitoring
  • [ ] Telegram bot integration
  • [ ] Social trading features

Acknowledgments

  • Built with Rust
  • Node.js bindings via napi-rs
  • AgentDB for self-learning capabilities
  • Inspired by the original Neural Trader Python implementation

Disclaimer: This software is for educational and research purposes only. Trading financial instruments carries risk. Past performance does not guarantee future results. Use at your own risk.