https://api.binance.com/api/v1/klines?symbol=BTCUSDT&interval=4h
https://bitcointalk.org/index.php?topic=2575875.msg28134260#msg28134260
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md
https://stackoverflow.com/questions/22993124/ta-lib-numpy-assertionerror-real-is-not-double
import requests
import json
import time
import calendar
#import mysql.connector
import sys
from datetime import datetime
import pandas as pd
def get_binance():
#resource=requests.get("https://api.binance.com/api/v1/klines?symbol=BTCUSDT&interval=4h")
resource=requests.get("https://api.binance.com/api/v1/klines?symbol=BTCUSDT&interval=1m")
data=[]
chart_data={}
chart_data = json.loads(resource.text)
for elems in chart_data:
data.append(elems)
df = pd.DataFrame(data, columns=['date', 'open', 'high', 'low', 'close', 'volume','f7','f8','f9','f10','f11','f12'])
df['date']=df['date'].astype(int)
df['open']=df['open'].astype(float)
df['high']=df['high'].astype(float)
df['low']=df['low'].astype(float)
df['close']=df['close'].astype(float)
df['volume']=df['volume'].astype(float)
df['date']=df['date']/1000
df['date']=df['date'].astype(int)
df = df.drop(df.columns[[6,7,8,9,10,11]], axis=1)
#print(df.columns)
return df
######################################################
df = get_binance()
df['date'] = pd.to_datetime(df['date'], unit='s')
print(df)
https://bitcointalk.org/index.php?topic=2575875.msg28134260#msg28134260
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md
https://stackoverflow.com/questions/22993124/ta-lib-numpy-assertionerror-real-is-not-double
import requests
import json
import time
import calendar
#import mysql.connector
import sys
from datetime import datetime
import pandas as pd
def get_binance():
#resource=requests.get("https://api.binance.com/api/v1/klines?symbol=BTCUSDT&interval=4h")
resource=requests.get("https://api.binance.com/api/v1/klines?symbol=BTCUSDT&interval=1m")
data=[]
chart_data={}
chart_data = json.loads(resource.text)
for elems in chart_data:
data.append(elems)
df = pd.DataFrame(data, columns=['date', 'open', 'high', 'low', 'close', 'volume','f7','f8','f9','f10','f11','f12'])
df['date']=df['date'].astype(int)
df['open']=df['open'].astype(float)
df['high']=df['high'].astype(float)
df['low']=df['low'].astype(float)
df['close']=df['close'].astype(float)
df['volume']=df['volume'].astype(float)
df['date']=df['date']/1000
df['date']=df['date'].astype(int)
df = df.drop(df.columns[[6,7,8,9,10,11]], axis=1)
#print(df.columns)
return df
######################################################
df = get_binance()
df['date'] = pd.to_datetime(df['date'], unit='s')
print(df)
Комментариев нет:
Отправить комментарий