Package: binance-historical-data
Table of ContentsShort Overview.Installation via pip:How to use itInitialize main object:data_dumper1) The only method to dump the data2) Delete outdated daily results.csv klines (candles) files columnsExamplesHow to dump all data for all USDT trading pairsHow to update data (get all new data)How to update (reload) data for the asked time periodOther useful methodsGet all trading pairs (tickers) from binanceGet the first data when data for the ticker can be foundGet all tickers with locally saved dataGet all dates for which there is locally saved dataGet directory where the local data of exact ticker liesCreate file name for the local fileLinksProject local LinksContactsLicenseShort Overview.binance_historical_data is a python package (py>=3.8)
which makes download of historical crypto data (prices and volumes) from binance server as simple as it can only be.You don’t even need to have an account at binance.com to download all history of crypto dataData is taken from here:https://data.binance.vision/?prefix=data/Dumped locally and then unzipped,so you would have an identical local ready to use data copyUsing this package you will be able to have full historical data of prices and volumes with only 3 lines of python codeAnd if you need to update already downloaded data then once again 3 lines of python code will do the jobLimitations: The previous day data appears on binance server a few minutes after 0 a.m. UTCSo there is a delay in which you can get the data.Installation via pip:pipinstallbinance_historical_dataHow to use itInitialize main object:data_dumperfrombinance_historical_dataimportBinanceDataDumperdata_dumper=BinanceDataDumper(path_dir_where_to_dump=".",asset_class="spot",# spot, um, cmdata_type="klines",# aggTrades, klines, tradesdata_frequency="1m",)Arguments:path_dir_where_to_dump:(string) Path to folder where to dump the dataasset_class:(string) Source of data: [spot, um, cm] um: usd(t) margined futures, cm: coin margined futuresdata_type=”klines”:(string) data type to dump:[aggTrades, klines, trades] for spot[aggTrades, klines, trades, indexPriceKlines, markPriceKlines, premiumIndexKlines, metrics] for futures (metrics only supported for um)Refer to binance doc for additional info:https://github.com/binance/binance-public-datastr_data_frequency:(string) One of [1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h]Frequency of price-volume data candles to get1) The only method to dump the datadata_dumper.dump_data(tickers=None,date_start=None,date_end=None,is_to_update_existing=False,tickers_to_exclude=["UST"],)Arguments:tickers=None:(list) Trading pairs for which to dump dataif equals to None- allUSDTpairs will be useddate_start=None:(datetime.date) The date from which to start dumpif equals to None- every trading pair will be dumped from the early begining (the earliest is 2017-01-01)date_end=True=None:(datetime.date) The last date for which to dump dataif equals to None- Today’s date will be usedis_to_update_existing=False:(bool) Flag if you want to update the data if it’s already existtickers_to_exclude=None:(list) Tickers to exclude from dump2) Delete outdated daily resultsDeleta all daily data for which full month monthly data was already dumpeddata_dumper.delete_outdated_daily_results().csv klines (candles) files columns“Open time” - Timestamp“Open”“High”“Low”“Close”“Volume”“Close time” - Timestamp“Quote asset volume”“Number of trades”“Taker buy base asset volume”“Taker buy quote asset volume”“Ignore”ExamplesHow to dump all data for all USDT trading pairsPlease be advised that the first data dump for all trading pairs might take some time (~40 minutes)data_dumper.dump_data()How to update data (get all new data)It’s as easy as running the exactly same methoddump_dataonce againThedata_dumperwill find all the dates for which data already existsand will try to dump only the new datadata_dumper.dump_data()How to update (reload) data for the asked time perioddata_dumper.dump_data(date_start=datetime.date(year=2021,month=1,day=1),date_end=datetime.date(year=2022,month=1,day=1),is_to_update_existing=True)Other useful methodsGet all trading pairs (tickers) from binanceprint(data_dumper.get_list_all_trading_pairs())Get the first data when data for the ticker can be foundprint(data_dumper.get_min_start_date_for_ticker())Get all tickers with locally saved dataprint(data_dumper.get_all_tickers_with_data(timeperiod_per_file="daily"))Get all dates for which there is locally saved dataprint(data_dumper.get_all_dates_with_data_for_ticker(ticker,timeperiod_per_file="monthly"))Get directory where the local data of exact ticker liesprint(data_dumper.get_local_dir_to_data(ticker,timeperiod_per_file,))Create file name for the local fileprint(data_dumper.create_filename(ticker,date_obj,timeperiod_per_file="monthly",))LinksPYPIGitHubProject local LinksCHANGELOG.CONTRIBUTING.ContactsEmail:stas.prokopiev@gmail.comvk.comFacebookLicenseThis project is licensed under the MIT License.