Feature: Add Binance/Bybit as OHLCV Historical Data Provider
Status: Proposed
Author: Community
Date: 2026-05-26
Priority: Medium
Executive Summary
This feature request proposes adding Binance and Bybit as native OHLCV (candlestick) data providers within OpenAlice's market data system. Currently, users connected to Binance/Bybit for trading must use separate data providers (yfinance, FMP) for historical price data. This creates friction and introduces unnecessary dependencies.
By leveraging CCXT's existing Binance/Bybit connections, OpenAlice can unify trading and analysis into a single data source, eliminating redundant API keys and subscription costs.
Problem Statement
Current Limitations
1. Data Provider Fragmentation
┌─────────────────────────────────────────────────┐
│ OpenAlice Market Data Architecture │
├─────────────────────────────────────────────────┤
│ │
│ Configured Providers: │
│ ├─ yfinance (free, limited crypto support) │
│ ├─ FMP (paid, intraday available) │
│ ├─ FRED (macro data only) │
│ └─ ... other providers ... │
│ │
│ NOT Available: │
│ ├─ Binance API (despite CCXT integration) │
│ ├─ Bybit API (despite CCXT integration) │
│ └─ Other CCXT-supported exchanges │
│ │
└─────────────────────────────────────────────────┘
2. Timeframe Limitations for Crypto
Why Binance as a Crypto Data Provider Makes Sense
Legend: ✅ Supported · ⚠️ Limited · ❌ Not supported
| Provider |
1m |
5m |
15m |
1h |
4h |
1d |
Market Coverage |
Practical Limitation |
| yfinance |
⚠️ |
⚠️ |
⚠️ |
⚠️ |
❌ |
✅ |
Only a subset of major crypto tickers |
Limited intraday history and incomplete coin coverage. |
| FMP Free |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
Limited |
No useful intraday crypto support on the free tier. |
| FMP Pro |
✅ |
✅ |
✅ |
✅ |
❌ |
✅ |
Limited and plan-dependent |
Intraday access exists, but coverage is not as broad or exchange-native as Binance. |
| Binance via CCXT |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
Native Binance pairs |
Requires pagination and rate-limit handling, but no extra market data subscription is needed. |
FMP Pro intraday support for crypto is not guaranteed and may require additional licenses
3. Architectural Misalignment
Users with Binance/Bybit trading accounts must:
- Authenticate to Binance/Bybit for trading (already done via CCXT)
- Separately configure yfinance/FMP for historical data
- Manage additional API keys/subscriptions
- Accept data latency and potential provider limitations
This violates the principle of minimal configuration and single source of truth.
Proposed Solution
Architecture Overview
┌──────────────────────────────────────────────────────┐
│ Unified Data + Trading Architecture │
├──────────────────────────────────────────────────────┤
│ │
│ User configures: crypto → "binance" │
│ │
│ ┌────────────────────────────────────────────┐ │
│ │ CCXT Layer │ │
│ │ ├─ createOrder() → Binance trading API │ │
│ │ └─ fetchOHLCV() → Binance market data │ │
│ └────────────────────────────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────────────────┐ │
│ │ OpenTypeBB BinanceProvider │ │
│ │ ├─ Normalize timeframes │ │
│ │ ├─ Handle rate limiting │ │
│ │ ├─ Cache OHLCV data │ │
│ │ └─ Return standardized format │ │
│ └────────────────────────────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────────────────┐ │
│ │ AI Tools + UI │ │
│ │ ├─ technical analysis │ │
│ │ ├─ backtesting │ │
│ │ ├─ indicator calculation │ │
│ │ └─ portfolio visualization │ │
│ └────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────┘
Implementation Roadmap
Phase 1: Binance Provider (Core)
Phase 2: Configuration & UI
Phase 3: Bybit Provider (Similar)
Phase 4: Polish & Testing
Technical Specification
Configuration
Current (yfinance):
{
"enabled": true,
"backend": "typebb-sdk",
"providers": {
"equity": "yfinance",
"crypto": "yfinance",
"currency": "yfinance"
}
}
After implementation (Binance):
{
"enabled": true,
"backend": "typebb-sdk",
"providers": {
"equity": "yfinance",
"crypto": "binance",
"currency": "yfinance"
}
}
API Query Format
Input:
interface CryptoHistoricalQuery {
symbol: string // "BTCUSDT" or "BTC/USDT"
start_date?: string // YYYY-MM-DD
end_date?: string // YYYY-MM-DD
interval: string // "1m", "5m", "15m", "1h", "4h", "1d"
provider?: string // "binance"
[key: string]: unknown
}
Output:
interface CryptoHistoricalData {
date: string // ISO 8601 timestamp
open: number
high: number
low: number
close: number
volume: number | null
vwap: number | null
[key: string]: unknown
}
Timeframe Support
Binance supports:
- Minutes: 1m, 3m, 5m, 15m, 30m
- Hours: 1h, 2h, 4h, 6h, 8h, 12h
- Daily: 1d
- Weekly: 1w
- Monthly: 1M
Initial support: 1m, 5m, 15m, 30m, 1h, 4h, 1d (most commonly used)
Rate Limiting
Binance API limits:
- 1200 requests per minute (general)
- 10 requests per second (IP-based)
Implementation:
- Use token bucket algorithm
- Log rate limit warnings
- Gracefully handle 429 responses
Error Handling
// Example: Symbol not found
throw new ProviderError(
"Symbol INVALIDBTC not found on Binance",
{ provider: "binance", symbol: "INVALIDBTC" }
);
// Example: Timeframe not supported
throw new ProviderError(
"Timeframe 2m not supported by Binance",
{ provider: "binance", timeframe: "2m" }
);
Benefits
For Users
- 🔓 No additional API keys — use existing Binance/Bybit credentials
- 💰 Free intraday data — no subscription costs
- ⚡ Faster data — direct exchange API instead of third-party aggregators
- 📊 All timeframes — 1m through 1M granularity
- 🎯 Better accuracy — official exchange data, no aggregation lag
For OpenAlice
- 🏗️ Architectural alignment — single source of truth for trading + analysis
- 📈 Reduced dependencies — fewer third-party data providers to manage
- 🔐 Credential reuse — no additional secret management
- 🚀 Competitive advantage — built-in support for major exchanges
Risks & Mitigations
| Risk |
Severity |
Mitigation |
| Binance API changes |
Medium |
Monitor official docs, add integration tests |
| Rate limiting issues |
Medium |
Implement backoff, cache responses |
| Data staleness |
Low |
Document cache TTL, use WebSocket for real-time |
| Symbol format differences |
Low |
Normalize input (accept "BTC/USDT" or "BTCUSDT") |
| Breaking changes in CCXT |
Medium |
Pin CCXT version, test on upgrades |
Testing Strategy
Unit Tests
// Test 1: Fetch 1h candles for BTCUSDT
const result = await binanceProvider.fetchOHLCV({
symbol: "BTCUSDT",
interval: "1h",
start_date: "2024-05-01",
end_date: "2024-05-07"
});
expect(result.length).toBeGreaterThan(0);
expect(result[0].open).toBeLessThan(result[0].high);
// Test 2: Handle invalid timeframe
await expect(
binanceProvider.fetchOHLCV({
symbol: "BTCUSDT",
interval: "2m"
})
).rejects.toThrow("Timeframe 2m not supported");
// Test 3: Rate limiting
// 1201 concurrent requests should not exceed 1200/min
Integration Tests
- Real Binance API calls with small query sets
- Test with multiple symbol formats
- Verify data consistency vs. official Binance UI
- Performance benchmarking
Edge Cases
- Symbols with special characters (e.g., "USDC-USDT")
- Gap handling (markets with low liquidity)
- DST transitions
- Market data gaps during exchange maintenance
Documentation Updates Needed
- README.md — Add Binance to provider list
- docs/opentypebb-tutorial.md — Update provider configuration section
- src/domain/market-data/README.md — Add Binance provider docs
- CLAUDE.md — Reference this feature as load-bearing for crypto trading
Acceptance Criteria
References
Questions for Discussion
- Symbol Format: Should we auto-normalize "BTC/USD" → "BTCUSDT" or require exact format?
- Bybit Timeline: Implement in Phase 3, or parallel with Binance?
- Caching Strategy: In-memory only, or persistent cache layer?
- WebSocket Support: Future enhancement for real-time candles?
Feature: Add Binance/Bybit as OHLCV Historical Data Provider
Status: Proposed
Author: Community
Date: 2026-05-26
Priority: Medium
Executive Summary
This feature request proposes adding Binance and Bybit as native OHLCV (candlestick) data providers within OpenAlice's market data system. Currently, users connected to Binance/Bybit for trading must use separate data providers (yfinance, FMP) for historical price data. This creates friction and introduces unnecessary dependencies.
By leveraging CCXT's existing Binance/Bybit connections, OpenAlice can unify trading and analysis into a single data source, eliminating redundant API keys and subscription costs.
Problem Statement
Current Limitations
1. Data Provider Fragmentation
2. Timeframe Limitations for Crypto
Why Binance as a Crypto Data Provider Makes Sense
Legend: ✅ Supported ·⚠️ Limited · ❌ Not supported
FMP Pro intraday support for crypto is not guaranteed and may require additional licenses
3. Architectural Misalignment
Users with Binance/Bybit trading accounts must:
This violates the principle of minimal configuration and single source of truth.
Proposed Solution
Architecture Overview
Implementation Roadmap
Phase 1: Binance Provider (Core)
BinanceProviderclass inpackages/opentypebb/src/providers/fetchOHLCV()method wrapping CCXTfetchOHLCV()Phase 2: Configuration & UI
"binance"option to market-data config schemaPhase 3: Bybit Provider (Similar)
BybitProviderclassPhase 4: Polish & Testing
Technical Specification
Configuration
Current (yfinance):
{ "enabled": true, "backend": "typebb-sdk", "providers": { "equity": "yfinance", "crypto": "yfinance", "currency": "yfinance" } }After implementation (Binance):
{ "enabled": true, "backend": "typebb-sdk", "providers": { "equity": "yfinance", "crypto": "binance", "currency": "yfinance" } }API Query Format
Input:
Output:
Timeframe Support
Binance supports:
Initial support:
1m, 5m, 15m, 30m, 1h, 4h, 1d(most commonly used)Rate Limiting
Binance API limits:
Implementation:
Error Handling
Benefits
For Users
For OpenAlice
Risks & Mitigations
Testing Strategy
Unit Tests
Integration Tests
Edge Cases
Documentation Updates Needed
Acceptance Criteria
References
packages/opentypebb/Questions for Discussion