Skip to content

Commit 9241d99

Browse files
committed
update candle
1 parent c6992c9 commit 9241d99

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

candle.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pandas as pd
2+
3+
4+
def get_klines_iter(symbol, interval, start, end, limit=5000):
5+
df = pd.DataFrame()
6+
startDate = end
7+
while startDate > start:
8+
url = 'https://api.binance.com/api/v3/klines?symbol=' + \
9+
symbol + '&interval=' + interval + '&limit=' + str(iteration)
10+
if startDate is not None:
11+
url += '&endTime=' + str(startDate)
12+
13+
df2 = pd.read_json(url)
14+
df2.columns = ['Opentime', 'Open', 'High', 'Low', 'Close', 'Volume', 'Closetime',
15+
'Quote asset volume', 'Number of trades', 'Taker by base', 'Taker buy quote', 'Ignore']
16+
df = pd.concat([df2, df], axis=0, ignore_index=True, keys=None)
17+
startDate = df.Opentime[0]
18+
df.reset_index(drop=True, inplace=True)
19+
return df

0 commit comments

Comments
 (0)