JSPM

  • Created
  • Published
  • Downloads 288
  • Score
    100M100P100Q111432F
  • License MIT OR Apache-2.0

Complete AI-powered algorithmic trading platform with neural networks, backtesting, live trading, and MCP integration - all features included (meta package)

Package Exports

  • neural-trader
  • neural-trader/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (neural-trader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

๐Ÿš€ Neural Trader by rUv - AI-Powered Trading Platform

Advanced Neural Trading System with 27 AI Models, 20 NPM Packages & 78.75x Performance Boost

License: MIT Python 3.11+ Rust Node.js FastAPI JWT Auth Deployed MCP Compatible

NPM Packages (20 Published)

Backend Neural Strategies Risk Sports Betting Syndicate Downloads

Performance & Features

27 Neural Models 78.75x Speedup 60+ Functions 20 Packages GPU Accelerated SIMD Optimized

A cutting-edge AI-powered trading platform featuring advanced neural strategies, real-time news sentiment analysis, comprehensive backtesting, and optional JWT authentication. Built with FastAPI and designed for both CPU and GPU environments.

๐ŸŒ Live API: https://neural-trader.ruv.io
๐Ÿ“š Documentation: https://neural-trader.ruv.io/docs


โœจ Key Features

๐Ÿง  Neural Trading Strategies

  • 8 Advanced Strategies: Mirror Trader, Momentum Trader, Enhanced Momentum, Neural Sentiment, Neural Arbitrage, Neural Trend, Mean Reversion, Pairs Trading
  • GPU Acceleration Ready: Automatic detection and utilization when available
  • Real-Time Execution: Sub-second decision making and order placement
  • Multi-Symbol Support: Trade multiple assets simultaneously

๐Ÿ“Š Comprehensive Trading Operations

  • Live Trading: Start/stop trading with advanced configuration
  • Backtesting: Historical performance analysis with Sharpe ratio calculations
  • Strategy Optimization: Parameter tuning with up to 100 iterations
  • Risk Management: Stop-loss, take-profit, and position sizing controls

๐Ÿ” Enterprise Security (NEW!)

  • JWT Authentication: Optional Bearer token authentication
  • API Key Support: Alternative authentication method
  • Environment-Based Config: Secure secrets management
  • Bcrypt Password Hashing: Industry-standard security

๐Ÿ“ˆ Advanced Analytics

  • AI News Sentiment: Real-time news analysis for trading signals
  • Portfolio Analytics: Sharpe ratio, max drawdown, win rate metrics
  • Risk Analysis: VaR, CVaR, and Monte Carlo simulations
  • Performance Monitoring: Real-time tracking and Prometheus metrics

๐Ÿš€ Production Ready

  • FastAPI Framework: High-performance async API
  • Docker Deployment: Containerized for easy deployment
  • Fly.io Integration: One-command cloud deployment
  • Health Monitoring: Built-in health checks and status endpoints

๐Ÿ”ฅ Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/ai-news-trader.git
cd ai-news-trader

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment

cp .env.example .env
# Edit .env with your API keys and settings

4. Run Locally

python -m uvicorn src.main:app --reload --port 8080

5. Deploy to Production

# Using the deployment script
./scripts/deploy-to-fly.sh

# Or deploy with Docker (see Docker section below)

๐Ÿ“ฆ NPM Packages

Neural Trader is available as 20 modular npm packages for Node.js integration with high-performance Rust bindings:

Core Packages

Package Version Description Size Install
@neural-trader/backend npm Complete trading backend with 60+ functions 4.4 MB npm i @neural-trader/backend
@neural-trader/core npm Core utilities and shared types - npm i @neural-trader/core
@neural-trader/neural npm 27 neural forecasting models (78.75x speedup) 10.3 MB npm i @neural-trader/neural
@neural-trader/neuro-divergent npm Advanced neural forecasting library 7.7 MB npm i @neural-trader/neuro-divergent

Trading Components

Package Version Description Size Install
@neural-trader/backtesting npm Historical backtesting engine 2.6 MB npm i @neural-trader/backtesting
@neural-trader/brokers npm Multi-broker integrations (Alpaca, IBKR, etc.) 2.6 MB npm i @neural-trader/brokers
@neural-trader/execution npm Order execution and routing 2.6 MB npm i @neural-trader/execution
@neural-trader/features npm Technical indicators and feature engineering 2.6 MB npm i @neural-trader/features
@neural-trader/market-data npm Real-time and historical market data 2.6 MB npm i @neural-trader/market-data
@neural-trader/portfolio npm Portfolio management and tracking 2.6 MB npm i @neural-trader/portfolio
@neural-trader/risk npm Risk analysis (VaR, CVaR, Monte Carlo) 2.6 MB npm i @neural-trader/risk
@neural-trader/strategies npm Trading strategy implementations 2.6 MB npm i @neural-trader/strategies

Specialized Strategies

Package Version Description Size Install
@neural-trader/news-trading npm News sentiment analysis and trading 2.6 MB npm i @neural-trader/news-trading
@neural-trader/prediction-markets npm Prediction market integration (Polymarket) 2.6 MB npm i @neural-trader/prediction-markets
@neural-trader/sports-betting npm Sports betting arbitrage and Kelly sizing 2.6 MB npm i @neural-trader/sports-betting
@neural-trader/syndicate npm Collaborative investment syndicates 174 KB npm i @neural-trader/syndicate

Tools & Protocols

Package Version Description Size Install
@neural-trader/benchoptimizer npm Performance benchmarking and optimization 1.5 MB npm i @neural-trader/benchoptimizer
@neural-trader/mcp npm Model Context Protocol integration 2.6 MB npm i @neural-trader/mcp
@neural-trader/mcp-protocol npm MCP protocol specifications 42 KB npm i @neural-trader/mcp-protocol
neural-trader npm Main neural-trader CLI and metapackage 2.6 MB npm i neural-trader

Package Features

@neural-trader/backend (v2.2.0)

High-performance Rust NAPI bindings - 4.4 MB

  • โœ… Trading: executeTrade, runBacktest, simulateTrade, quickAnalysis
  • โœ… Neural Models: neuralForecast, neuralTrain, neuralEvaluate, neuralBacktest, neuralOptimize
  • โœ… Sports Betting: getSportsEvents, getSportsOdds, findSportsArbitrage, calculateKellyCriterion
  • โœ… Syndicate Management: FundAllocationEngine, ProfitDistributionSystem, VotingSystem
  • โœ… Security: JWT auth, API keys, rate limiting, DDoS protection, audit logging
  • โœ… Risk Management: VaR/CVaR analysis, portfolio rebalancing, correlation analysis
  • โœ… E2B Sandboxes: Isolated code execution environments
  • โœ… News Trading: Real-time sentiment analysis and news collection

Example Usage:

const { executeTrade, neuralForecast, getSystemInfo } = require('@neural-trader/backend');

// Get system info
const info = getSystemInfo();
console.log('Version:', info.version);

// Neural forecasting
const forecast = await neuralForecast({
  symbol: 'AAPL',
  horizon: 5,
  model: 'LSTM'
});

// Execute trade
const result = await executeTrade({
  strategy: 'momentum_trader',
  symbol: 'SPY',
  action: 'buy',
  quantity: 100
});

@neural-trader/neural (v2.1.2)

27 Neural Forecasting Models - 10.3 MB - 78.75x Performance Boost

Supported Models:

  • Basic: MLP, DLinear, NLinear, RLinear
  • Recurrent: RNN, LSTM, GRU
  • Advanced: NHITS, NBEATS, TFT, DeepAR
  • Transformers: Transformer, Informer, Autoformer, FedFormer, PatchTST, ITransformer
  • Specialized: TCN, BiTCN, TimesNet, StemGNN, TSMixer, TimeLLM, DeepNPTS, TIDE

Performance Optimizations:

  • ๐Ÿš€ SIMD Vectorization: 2.5-3.8x speedup (AVX2, AVX-512, NEON)
  • ๐Ÿš€ Rayon Parallelization: 6.94x on 8 cores
  • ๐Ÿš€ Flash Attention: 4.2x speedup, 256x memory reduction
  • ๐Ÿš€ Mixed Precision FP16: 1.8x speedup, 50% memory savings
  • ๐Ÿš€ Combined: 78.75x overall speedup

Example Usage:

const { NeuralModel, BatchPredictor, listModelTypes } = require('@neural-trader/neural');

// List available models
const models = listModelTypes();
console.log('Available:', models); // 27 models

// Create LSTM model
const model = new NeuralModel({
  modelType: 'LSTM',
  inputSize: 10,
  horizon: 5,
  hiddenSize: 128,
  numLayers: 3
});

// Batch predictions
const predictor = new BatchPredictor();
const results = await predictor.predict(data, {
  model: 'Transformer',
  batchSize: 32
});

Platform Support

Current Release:

  • โœ… Linux x86_64 (GNU libc)

Coming Soon (v2.3.0+):

  • macOS x86_64 (Intel)
  • macOS ARM64 (Apple Silicon)
  • Windows x86_64 (MSVC)
  • Linux ARM64 (GNU/MUSL)

Quick Install

# Install everything (metapackage)
npm install neural-trader

# Or install specific packages
npm install @neural-trader/backend        # Core trading backend
npm install @neural-trader/neural         # 27 neural models
npm install @neural-trader/strategies     # Trading strategies
npm install @neural-trader/risk           # Risk management

# Install all trading components
npm install @neural-trader/backend \
            @neural-trader/neural \
            @neural-trader/strategies \
            @neural-trader/risk \
            @neural-trader/portfolio \
            @neural-trader/execution

# Install specialized strategies
npm install @neural-trader/sports-betting       # Sports arbitrage
npm install @neural-trader/prediction-markets   # Polymarket
npm install @neural-trader/news-trading         # Sentiment trading
npm install @neural-trader/syndicate            # Collaborative pools

Documentation


๐Ÿ“ก API Endpoints

Core Endpoints

Method Endpoint Description
GET / Platform info and status
GET /health Health check with strategy status
GET /gpu-status GPU availability check
GET /metrics Prometheus metrics

Authentication (Optional)

Method Endpoint Description
POST /auth/login Get JWT token
GET /auth/status Check auth status
POST /auth/verify Verify JWT token

Trading Operations

Method Endpoint Description
POST /trading/start Start trading with configuration
POST /trading/stop Stop trading strategies
GET /trading/status Current trading status
POST /trading/backtest Run historical backtest
POST /trading/optimize Optimize strategy parameters
POST /trading/analyze-news AI news sentiment analysis
POST /trading/execute-trade Execute individual trade

Portfolio & Risk

Method Endpoint Description
GET /portfolio/status Portfolio overview with analytics
POST /risk/analysis Comprehensive risk analysis

๐Ÿ”ง Configuration

Environment Variables

# Authentication (Optional)
AUTH_ENABLED=false              # Enable/disable JWT auth
JWT_SECRET_KEY=your-secret-key  # JWT signing key
AUTH_USERNAME=admin             # Default username
AUTH_PASSWORD=changeme          # Default password

# Trading APIs
ALPACA_API_KEY=your-key
ALPACA_SECRET_KEY=your-secret
NEWS_API_KEY=your-key
FINNHUB_API_KEY=your-key

# Application
PORT=8080
LOG_LEVEL=info

Trading Configuration

{
  "strategies": ["momentum_trader", "neural_sentiment"],
  "symbols": ["SPY", "QQQ", "AAPL"],
  "risk_level": "medium",
  "max_position_size": 10000,
  "stop_loss_percentage": 2.0,
  "take_profit_percentage": 5.0,
  "time_frame": "5m",
  "use_gpu": false,
  "enable_news_trading": true,
  "enable_sentiment_analysis": true
}

๐Ÿ” Authentication

The platform includes optional JWT authentication that can be enabled for production:

Enable Authentication

# For cloud deployments
fly secrets set AUTH_ENABLED=true --app your-app-name

# For Docker deployments
export AUTH_ENABLED=true

Obtain Token

curl -X POST https://neural-trader.ruv.io/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"your-password"}'

Use Token

curl -H "Authorization: Bearer YOUR_TOKEN" \
  https://neural-trader.ruv.io/trading/status

See Authentication Guide for detailed documentation.

๐Ÿงช Testing

Run Tests

# Test all endpoints
./scripts/test-api-endpoints.sh

# Test authentication
./scripts/test-auth.sh

# Validate core features
./scripts/validate-core-features.sh

# Comprehensive capability test
./scripts/test-all-capabilities.sh

API Testing with cURL

# Start trading
curl -X POST https://neural-trader.ruv.io/trading/start \
  -H "Content-Type: application/json" \
  -d '{"strategies":["momentum_trader"],"symbols":["SPY"]}'

# Check status
curl https://neural-trader.ruv.io/trading/status

# Run backtest
curl -X POST https://neural-trader.ruv.io/trading/backtest \
  -H "Content-Type: application/json" \
  -d '{
    "strategy": "momentum_trader",
    "symbols": ["SPY"],
    "start_date": "2024-01-01",
    "end_date": "2024-06-30"
  }'

๐Ÿ“Š Performance Metrics

  • Response Time: Average 121ms
  • Success Rate: 87.76% in comprehensive tests
  • Deployment Size: 327 MB Docker image
  • Memory Usage: ~500MB typical
  • CPU Usage: <10% idle, 20-40% active trading

๐Ÿ—๏ธ Architecture

ai-news-trader/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ auth/                 # JWT authentication
โ”‚   โ”œโ”€โ”€ trading/
โ”‚   โ”‚   โ””โ”€โ”€ strategies/       # Trading strategies
โ”‚   โ”œโ”€โ”€ optimization/         # Strategy optimization
โ”‚   โ””โ”€โ”€ main.py              # FastAPI application
โ”œโ”€โ”€ scripts/                  # Deployment & testing
โ”œโ”€โ”€ docs/                     # Documentation
โ””โ”€โ”€ requirements.txt          # Dependencies

๐Ÿš€ Deployment

Docker Deployment

Build the Image

# Build from Dockerfile
docker build -t neural-trader:latest .

# Or build with specific Dockerfile
docker build -f Dockerfile.fly -t neural-trader:latest .

Run the Container

# Run with environment file
docker run -d \
  --name neural-trader \
  -p 8080:8080 \
  --env-file .env \
  neural-trader:latest

# Or run with individual environment variables
docker run -d \
  --name neural-trader \
  -p 8080:8080 \
  -e AUTH_ENABLED=false \
  -e JWT_SECRET_KEY="$(openssl rand -hex 32)" \
  -e ALPACA_API_KEY="your-key" \
  neural-trader:latest

Docker Compose

# docker-compose.yml
version: '3.8'
services:
  neural-trader:
    build: .
    ports:
      - "8080:8080"
    environment:
      - AUTH_ENABLED=false
      - JWT_SECRET_KEY=${JWT_SECRET_KEY}
      - ALPACA_API_KEY=${ALPACA_API_KEY}
    volumes:
      - ./logs:/app/logs
    restart: unless-stopped

Cloud Deployment (Fly.io)

# Deploy with the provided script
./scripts/deploy-to-fly.sh

# Or manually
fly deploy --app your-app-name
fly secrets set AUTH_ENABLED=true --app your-app-name

๐Ÿ“ˆ Trading Strategies

Available Strategies

  1. Mirror Trader: Copy institutional trading patterns
  2. Momentum Trader: Trend-following with technical indicators
  3. Enhanced Momentum: Advanced momentum with ML signals
  4. Neural Sentiment: News-driven sentiment trading
  5. Neural Arbitrage: Cross-market arbitrage opportunities
  6. Neural Trend: Trend prediction with neural networks
  7. Mean Reversion: Statistical arbitrage
  8. Pairs Trading: Market-neutral pair strategies

Risk Levels

  • Low: Conservative, 1% position size
  • Medium: Balanced, 2.5% position size
  • High: Aggressive, 5% position size
  • Aggressive: Maximum risk, 10% position size

๐Ÿ› ๏ธ Development

Local Development

# Install dev dependencies
pip install -r requirements-dev.txt

# Run with hot reload
uvicorn src.main:app --reload --port 8080

# Run tests
pytest tests/

# Format code
black src/

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push branch (git push origin feature/amazing)
  5. Open Pull Request

๐Ÿ“ API Documentation

Interactive API documentation available at:

๐Ÿ” Monitoring

  • Health Check: /health
  • Prometheus Metrics: /metrics
  • Application Logs: Check your deployment platform's logging dashboard

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿค Support

๐Ÿ™ Acknowledgments

Built with:


Neural Trader by rUv - Advanced AI Trading Made Simple

๐ŸŒ Live: https://neural-trader.ruv.io
๐Ÿ“š Docs: https://neural-trader.ruv.io/docs