Overview
VibeTrader supports multiple data sources for fetching market data. Currently, the platform integrates with Binance for cryptocurrency data and Yahoo Finance for stocks, indices, and other traditional financial instruments.Supported Data Sources
Yahoo Finance
Access stocks, ETFs, indices, commodities, and currencies from global markets.
Binance
Real-time and historical cryptocurrency trading data with high precision.
Data Source Selection
The platform uses an enum-based system for selecting data sources:The data source is typically selected during chart initialization based on the symbol type or user preference.
Binance Data Source
Overview
Binance integration provides access to cryptocurrency market data through the Binance API, powered by the PineTS provider.Features
Real-time Data
Real-time Data
Fetch the latest candlestick data with minimal delay.
Historical Data
Historical Data
Access extensive historical data for backtesting and analysis.
Symbol Search
Symbol Search
Search and filter available trading pairs.
Multiple Timeframes
Multiple Timeframes
Support for various timeframes from 1-minute to monthly charts.
Fetching Binance Data
Data Structure
Binance returns kline (candlestick) data with these fields:Candle open time in milliseconds (Unix timestamp)
Opening price
Highest price during the period
Lowest price during the period
Closing price
Trading volume during the period
Candle close time in milliseconds
Symbol List
Fetch available Binance trading pairs:Yahoo Finance Data Source
Overview
Yahoo Finance integration provides access to a vast array of financial instruments including stocks, ETFs, indices, commodities, currencies, and more.Features
Global Markets
Global Markets
Access data from stock exchanges worldwide.
Multiple Asset Types
Multiple Asset Types
Stocks, ETFs, indices, forex, commodities, and cryptocurrencies.
Historical Data
Historical Data
Extensive historical data going back many years.
Adjusted Prices
Adjusted Prices
Corporate actions (splits, dividends) are reflected in the data.
Fetching Yahoo Finance Data
Time Handling
Symbol Examples
Symbol Search
Unified Data Fetching
ThefetchData function provides a unified interface for both data sources:
Function Signature
Parameters
The data source to use (
Source.yfinance or Source.binance)The time series object where data will be stored
The symbol/ticker identifier for the instrument
The timeframe for the data (e.g.,
TFrame.parse("1h") for hourly)The timezone for timestamp interpretation
Optional start time in milliseconds. If not provided, calculated based on
limitOptional maximum number of candles to fetch. Default varies by implementation
Return Value
Returns aPromise<number> containing the timestamp of the most recent candle, or undefined if no data was fetched.
Timeframe Support
Common Timeframes
- Intraday
- Daily+
1m- 1 minute5m- 5 minutes15m- 15 minutes30m- 30 minutes1h- 1 hour4h- 4 hours
Timeframe Conversion
Binance uses PineTS provider timeframe notation. The implementation handles automatic conversion:
Data Processing
Automatic Deduplication
Both data sources implement automatic deduplication:Kline Object Creation
Data from both sources is converted to a unifiedKline object:
Fallback Mechanism
If API fetching fails, the system falls back to local data:Local data should be in JSON format with fields:
Date, Open, High, Low, Close, VolumeTime Range Calculation
WhenstartTime is not provided, it’s calculated based on limit:
limit number of candles.
Error Handling
Network Errors
Network Errors
If the API request fails due to network issues, the promise rejects and should be caught by your error handler.
Invalid Symbols
Invalid Symbols
Invalid symbols may return empty data or error responses. Always validate symbol format before fetching.
Rate Limiting
Rate Limiting
Both APIs have rate limits. Implement request throttling for production use.
Missing Data
Missing Data
Some symbols or timeframes may not have complete historical data. Handle cases where fewer candles than requested are returned.
Best Practices
Cache Data
Cache fetched data locally to reduce API calls and improve load times.
Use Appropriate Limits
Request only the data you need. Smaller limits mean faster responses.
Handle Timezones
Always specify the correct timezone for your symbols to ensure accurate timestamps.
Validate Symbols
Use symbol search to validate symbols before fetching data.