fetch_binance_dataset#
API documentation for tradeexecutor.utils.binance.fetch_binance_dataset Python function.
- fetch_binance_dataset(symbols, candle_time_bucket, stop_loss_time_bucket=None, start_at=None, end_at=None, include_lending=False, force_download=False, desc='Downloading Binance data')[source]#
Load a Binance dataset.
This is the one-stop shop function for loading all your Binance data. It can include candlestick, stop loss, lending and supply data for all valid symbols.
If start_at and end_at are not provided, the entire dataset will be loaded.
Example:
from tradingstrategy.timebucket import TimeBucket from tradingstrategy.binance.downloader import BinanceDownloader downloader = BinanceDownloader() df = downloader.fetch_candlestick_data( ["BTCUSDT", "ETHUSDT"], TimeBucket.d1, datetime.datetime(2020, 1, 1), datetime.datetime(2021, 1, 1), ) # Show a candle for both BTC and ETH assert df.iloc[0].to_json() == '{"open":7195.24,"high":7255.0,"low":7175.15,"close":7200.85,"volume":16792.388165,"pair_id":"BTCUSDT"}' assert df.iloc[-1].to_json() == '{"open":2281.87,"high":2352.37,"low":2265.24,"close":2352.04,"volume":216702.6914,"pair_id":"ETHUSDT"}'
- Parameters:
candle_time_bucket (TimeBucket) – Time bucket for candle data
stop_loss_time_bucket (tradingstrategy.timebucket.TimeBucket | None) – Time bucket for stop loss data
start_at (datetime.datetime | None) – Start time for data
end_at (datetime.datetime | None) – End time for data
include_lending (bool) – Whether to include lending data or not
force_download (bool) – Force download of data
- Returns:
Dataset object with exchange, pairs, candles and lending candles data populated.
- Return type: