nt-market-data
Real-time and historical market data providers for stocks, crypto, forex, and options.
The nt-market-data crate provides unified interfaces for fetching market data from multiple providers including Alpaca, Polygon, Yahoo Finance, Alpha Vantage, and cryptocurrency exchanges.
Features
- Multi-Source - Unified API across 10+ data providers
- Real-Time Streaming - WebSocket connections for live market data
- Historical Data - OHLCV bars, ticks, and quotes
- Order Book - Level 2 market depth data
- Rate Limiting - Built-in rate limiting per provider
- Caching - Intelligent caching to reduce API calls
- Reconnection - Automatic reconnection with exponential backoff
- Normalization - Consistent data format across providers
Supported Providers
| Provider | Real-Time | Historical | Asset Classes |
|---|---|---|---|
| Alpaca | ✅ | ✅ | Stocks, Crypto |
| Polygon | ✅ | ✅ | Stocks, Options, Forex |
| Yahoo Finance | ❌ | ✅ | Stocks, ETFs, Crypto |
| Alpha Vantage | ❌ | ✅ | Stocks, Forex, Crypto |
| Binance | ✅ | ✅ | Crypto |
| Coinbase | ✅ | ✅ | Crypto |
| Kraken | ✅ | ✅ | Crypto |
| IEX Cloud | ✅ | ✅ | Stocks |
Quick Start
[]
= "0.1"
Stream Real-Time Market Data
use ;
use StreamExt;
async
Fetch Historical Data
use ;
use ;
async
Order Book Data
use ;
async
Architecture
nt-market-data/
├── providers/ # Data provider implementations
│ ├── alpaca.rs
│ ├── polygon.rs
│ ├── yahoo.rs
│ ├── alpha_vantage.rs
│ ├── binance.rs
│ ├── coinbase.rs
│ └── iex.rs
├── types.rs # Market data types
├── traits.rs # Provider traits
├── normalization.rs # Data normalization
├── cache.rs # Caching layer
└── lib.rs
Configuration
Create a market_data.toml configuration file:
[]
= "${ALPACA_API_KEY}"
= "${ALPACA_SECRET_KEY}"
= "https://data.alpaca.markets"
[]
= "${POLYGON_API_KEY}"
[]
= 200
= 300
[]
= true
= 300
Dependencies
| Crate | Purpose |
|---|---|
nt-core |
Core types and traits |
tokio |
Async runtime |
reqwest |
HTTP client |
tokio-tungstenite |
WebSocket client |
serde_json |
JSON serialization |
governor |
Rate limiting |
Testing
# Unit tests
# Integration tests with real providers
ALPACA_API_KEY=xxx POLYGON_API_KEY=yyy
# Test specific provider
Performance
- WebSocket latency: <10ms (provider-dependent)
- Historical data throughput: 10,000+ bars/sec
- Concurrent streams: 100+ symbols simultaneously
- Memory usage: <100MB for 50 symbols
Contributing
See CONTRIBUTING.md for guidelines.
License
Licensed under MIT OR Apache-2.0.