Package: binance-history
Fetch binance public data easily.Supports Python3.8+.Installation$pipinstallbinance-historyUsageAPI docsKlines>>>importbinance_historyasbh>>>klines=bh.fetch_klines(...symbol="BTCUSDT",...timeframe="1m",...start="2022-12-14",...end="2022-12-24",...)openhighlowclosevolumequote_volumetradesclose_datetimeopen_datetime2022-12-1400:00:00+08:0017753.5417768.4117752.7817766.99240.829184.277685e+0652412022-12-1400:00:59.999000+08:002022-12-1400:01:00+08:0017766.9917786.4017764.3717781.81311.476705.536668e+0662782022-12-1400:01:59.999000+08:002022-12-1400:02:00+08:0017781.8117790.5417771.4417785.37372.129926.616562e+0669112022-12-1400:02:59.999000+08:002022-12-1400:03:00+08:0017786.2317800.1817774.6317777.35401.522237.142210e+0669262022-12-1400:03:59.999000+08:002022-12-1400:04:00+08:0017777.3517785.9817769.1517781.93218.038373.876373e+0655192022-12-1400:04:59.999000+08:00...........................2022-12-2323:56:00+08:0016850.2216850.2216839.5516842.59146.389062.465894e+0642292022-12-2323:56:59.999000+08:002022-12-2323:57:00+08:0016842.5916846.2216839.0016840.9986.954401.464495e+0631522022-12-2323:57:59.999000+08:002022-12-2323:58:00+08:0016840.9916843.6116827.2816830.27208.414713.508642e+0649182022-12-2323:58:59.999000+08:002022-12-2323:59:00+08:0016830.2716836.6616824.4116832.16154.108332.593717e+0645022022-12-2323:59:59.999000+08:002022-12-2400:00:00+08:0016832.1516833.6216828.4216830.52119.285722.007721e+0637252022-12-2400:00:59.999000+08:00[14401rowsx8columns]AggTrades>>>bh.fetch_agg_trades(...symbol="ETCBTC",...start="2022-11 01:05",...end="2022-11-25 3:20",...tz="Europe/Paris"...)pricequantityis_buyer_makerdatetime2022-11-0101:05:09.435000+01:000.0011871.60True2022-11-0101:05:17.639000+01:000.00118629.56True2022-11-0101:05:18.616000+01:000.0011868.43True2022-11-0101:05:18.621000+01:000.00118637.31True2022-11-0101:05:18.748000+01:000.0011860.17True............2022-11-2503:19:18.317000+01:000.0011995.00False2022-11-2503:19:19.482000+01:000.00119910.69False2022-11-2503:19:23.270000+01:000.0011997.55True2022-11-2503:19:26.082000+01:000.0011992.56True2022-11-2503:19:40.375000+01:000.0011992.20FalseCommand Linebinance-historycomes with a command line interface,
you need to install some extra dependencies to use it:$pipinstall'binance-history[cli]'$bh--helpUsage:bh[OPTIONS]Options:--symbolTEXTThebinancemarketpairname,e.g.BTCUSDT[required]--startTEXTThestartdatetime,e.g.'2022-1-2 1:10'[required]--endTEXTTheenddatetime,e.g.'2022-1-25 2:20
                                  [required]
  --data-type [klines|aggTrades]  choose klines or aggTrades to download,
                                  default to 'klines'
  --asset-type [spot|futures/um|futures/cm]
                                  choose spot or futures data, default to
                                  'spot'
  --timeframe [1s|1m|3m|5m|15m|30m|1h|2h|4h|6h|8h|12h|1d|3d|1w|1M]
                                  The timeframe of klines, default to '15m',
                                  can be omitted if --data-type is not
                                  'klines'
  --tz TEXT                       The tz database name of time zone, use your
                                  local time zone if omitted'--output-pathTEXTThepathyouwanttosavethedownloadeddata,supportformat:[csv,json,xlsx],e.g.a.xlsx[required]--helpShowthismessageandexit.$bh--start2022-1-5--end2022-1-7--symbolETCBTC--output-patha.xlsx