Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import numpy as np
import pandas as pd
from binance.helpers import *
from binance.client import Client
from binance.websockets import BinanceSocketManager
client = Client('API','SECRET')
bm = BinanceSocketManager(client)
def get_historical_candles():
record = client.get_historical_klines("ETHUSDT",client.KLINE_INTERVAL_30MINUTE, "30 minutes ago UTC")
myList = []
for item in record:
n_item = []
int_ts = int(item[0] / 1000)
# nur neue timestamps anhängen
n_item.append(int_ts) # open time
n_item.append(float(item[1])) # open
n_item.append(float(item[2])) # high
n_item.append(float(item[3])) # low
n_item.append(float(item[4])) # close
n_item.append(float(item[5])) # volume
n_item.append(int(item[6] / 1000)) # close_time
n_item.append(float(item[7])) # quote_assetv
n_item.append(int(item[8])) # trades
n_item.append(float(item[9])) # taker_b_asset_v
n_item.append(float(item[10])) # taker_b_quote_v
except Exception as error:
new_ohlc = pd.DataFrame(myList, columns=['open_time', 'open', 'high', 'low',
'close', 'volume', 'close_time', 'quote_assetv', 'trades',
'taker_b_quote_v', 'datetime'])
return new_ohlc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment