Skip to content

Commit 4e426a7

Browse files
author
Sam McHardy
committed
Update documentation for historical klines
1 parent 066f769 commit 4e426a7

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

PYPIREADME.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Features
4444
- Response exception handling
4545
- Websocket handling with reconnection and multiplexed connections
4646
- Symbol Depth Cache
47+
- Historical Kline/Candle fetching function
4748
- Withdraw functionality
4849
- Deposit addresses
4950

@@ -112,6 +113,18 @@ Quick Start
112113
bm.start_aggtrade_socket('BNBBTC', process_message)
113114
bm.start()
114115
116+
# get historical kline data from any date range
117+
118+
# fetch 1 minute klines for the last day up until now
119+
klines = client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC"))
120+
121+
# fetch 30 minute klines for the last month of 2017
122+
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018"))
123+
124+
# fetch weekly klines since it listed
125+
klines = client.get_historical_klines("NEOBTC", KLINE_INTERVAL_1WEEK, "1 Jan, 2017"))
126+
127+
115128
For more `check out the documentation <https://python-binance.readthedocs.io/en/latest/>`_.
116129

117130
Donate

README.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Features
4444
- Response exception handling
4545
- Websocket handling with reconnection and multiplexed connections
4646
- Symbol Depth Cache
47+
- Historical Kline/Candle fetching function
4748
- Withdraw functionality
4849
- Deposit addresses
4950

@@ -112,6 +113,17 @@ Quick Start
112113
bm.start_aggtrade_socket('BNBBTC', process_message)
113114
bm.start()
114115
116+
# get historical kline data from any date range
117+
118+
# fetch 1 minute klines for the last day up until now
119+
klines = client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC"))
120+
121+
# fetch 30 minute klines for the last month of 2017
122+
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018"))
123+
124+
# fetch weekly klines since it listed
125+
klines = client.get_historical_klines("NEOBTC", KLINE_INTERVAL_1WEEK, "1 Jan, 2017"))
126+
115127
For more `check out the documentation <https://python-binance.readthedocs.io/en/latest/>`_.
116128

117129
Donate

docs/market_data.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,23 @@ Market Data Endpoints
3636

3737
.. code:: python
3838
39-
from binance.enums import *
40-
candles = client.get_klines(symbol='BNBBTC', interval=KLINE_INTERVAL_30MINUTE)
39+
candles = client.get_klines(symbol='BNBBTC', interval=Client.KLINE_INTERVAL_30MINUTE)
40+
41+
`Get Historical Kline/Candlesticks <binance.html#binance.client.Client.get_historical_klines>`_
42+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
44+
Fetch klines for any date range and interval
45+
46+
.. code:: python
47+
48+
# fetch 1 minute klines for the last day up until now
49+
klines = client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC"))
50+
51+
# fetch 30 minute klines for the last month of 2017
52+
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018"))
53+
54+
# fetch weekly klines since it listed
55+
klines = client.get_historical_klines("NEOBTC", KLINE_INTERVAL_1WEEK, "1 Jan, 2017"))
4156
4257
`Get 24hr Ticker <binance.html#binance.client.Client.get_ticker>`_
4358
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)