Welcome to binance-history’s documentation!#
binance-history is a Python library for fetching cryptocurrency klines or trades data. It downloads data from the Binance Public Data.
API#
- binance_history.fetch_klines(symbol, start, end, timeframe='1m', asset_type='spot', tz=None)#
convinience function by calling
fetch_data
- binance_history.fetch_agg_trades(symbol, start, end, asset_type='spot', tz=None)#
convinience function by calling
fetch_data
- binance_history.fetch_data(symbol, asset_type, data_type, start, end, tz=None, timeframe=None)#
- Parameters:
symbol (str) – The binance market pair name. e.g.
'BTCUSDT'.start (datetime) – The start datetime of requested data. If it’s an instance of
datetime.datetime,asset_type (str) – The asset type of requested data. It must be one of
'spot','futures/um','futures/cm'.data_type (str) – The type of requested data. It must be one of
'klines','agg_trades'. it’s timezone is ignored. If it’s astr, it should be parsed by dateutil, e.g."2022-1-1 8:10".end (datetime) –
The end datetime of requested data. If it’s an instance of
datetime.datetime, it’s timezone is ignored. If it’s astr, it should be parsed by dateutil, e.g."2022-1-2 8:10".tz (str | None) – Timezone of
start,end, and the open/close datetime of the returned dataframe. It should be a time zone name of tz database, e.g. “Asia/Shanghai”. Your can find a full list of available time zone names in List of tz database time zones.timeframe (str | None) – The kline interval. e.g. “1m”. see
binance_history.constants.TIMEFRAMESto see the full list of available intervals.
- Returns:
A pandas dataframe with columns open, high, low, close, volume, trades, close_datetime. the dataframe’s index is the open datetime of klines, the timezone of the datetime is set by
tz, if it is None, your local timezone will be used.- Return type: