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
NPM Packages (20 Published)
Performance & Features
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-trader2. Install Dependencies
pip install -r requirements.txt3. Configure Environment
cp .env.example .env
# Edit .env with your API keys and settings4. Run Locally
python -m uvicorn src.main:app --reload --port 80805. 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 | Complete trading backend with 60+ functions | 4.4 MB | npm i @neural-trader/backend |
|
| @neural-trader/core | Core utilities and shared types | - | npm i @neural-trader/core |
|
| @neural-trader/neural | 27 neural forecasting models (78.75x speedup) | 10.3 MB | npm i @neural-trader/neural |
|
| @neural-trader/neuro-divergent | Advanced neural forecasting library | 7.7 MB | npm i @neural-trader/neuro-divergent |
Trading Components
| Package | Version | Description | Size | Install |
|---|---|---|---|---|
| @neural-trader/backtesting | Historical backtesting engine | 2.6 MB | npm i @neural-trader/backtesting |
|
| @neural-trader/brokers | Multi-broker integrations (Alpaca, IBKR, etc.) | 2.6 MB | npm i @neural-trader/brokers |
|
| @neural-trader/execution | Order execution and routing | 2.6 MB | npm i @neural-trader/execution |
|
| @neural-trader/features | Technical indicators and feature engineering | 2.6 MB | npm i @neural-trader/features |
|
| @neural-trader/market-data | Real-time and historical market data | 2.6 MB | npm i @neural-trader/market-data |
|
| @neural-trader/portfolio | Portfolio management and tracking | 2.6 MB | npm i @neural-trader/portfolio |
|
| @neural-trader/risk | Risk analysis (VaR, CVaR, Monte Carlo) | 2.6 MB | npm i @neural-trader/risk |
|
| @neural-trader/strategies | Trading strategy implementations | 2.6 MB | npm i @neural-trader/strategies |
Specialized Strategies
| Package | Version | Description | Size | Install |
|---|---|---|---|---|
| @neural-trader/news-trading | News sentiment analysis and trading | 2.6 MB | npm i @neural-trader/news-trading |
|
| @neural-trader/prediction-markets | Prediction market integration (Polymarket) | 2.6 MB | npm i @neural-trader/prediction-markets |
|
| @neural-trader/sports-betting | Sports betting arbitrage and Kelly sizing | 2.6 MB | npm i @neural-trader/sports-betting |
|
| @neural-trader/syndicate | Collaborative investment syndicates | 174 KB | npm i @neural-trader/syndicate |
Tools & Protocols
| Package | Version | Description | Size | Install |
|---|---|---|---|---|
| @neural-trader/benchoptimizer | Performance benchmarking and optimization | 1.5 MB | npm i @neural-trader/benchoptimizer |
|
| @neural-trader/mcp | Model Context Protocol integration | 2.6 MB | npm i @neural-trader/mcp |
|
| @neural-trader/mcp-protocol | MCP protocol specifications | 42 KB | npm i @neural-trader/mcp-protocol |
|
| neural-trader | 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 poolsDocumentation
- Backend API: See package README for 60+ function signatures
- Neural Models: 27 model architectures documented
- Performance: Benchmark results
๐ก 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=infoTrading 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=trueObtain 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/statusSee 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.shAPI 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:latestDocker 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-stoppedCloud 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
- Mirror Trader: Copy institutional trading patterns
- Momentum Trader: Trend-following with technical indicators
- Enhanced Momentum: Advanced momentum with ML signals
- Neural Sentiment: News-driven sentiment trading
- Neural Arbitrage: Cross-market arbitrage opportunities
- Neural Trend: Trend prediction with neural networks
- Mean Reversion: Statistical arbitrage
- 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
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push branch (
git push origin feature/amazing) - Open Pull Request
๐ API Documentation
Interactive API documentation available at:
- Swagger UI: https://neural-trader.ruv.io/docs
- ReDoc: https://neural-trader.ruv.io/redoc
๐ 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
- Issues: GitHub Issues
- Documentation: /docs
- API Status: https://neural-trader.ruv.io/health
๐ Acknowledgments
Built with:
- FastAPI - Modern web framework
- Alpaca - Trading API
- Fly.io - Cloud deployment
- python-jose - JWT implementation
Neural Trader by rUv - Advanced AI Trading Made Simple
๐ Live: https://neural-trader.ruv.io
๐ Docs: https://neural-trader.ruv.io/docs