import requests
import json
import time
import math
from datetime import datetime
import pandas as pd
def get_polonix() :
time_depth = 500
start_day = 500
st_time=time.time()-start_day*24*60*60
end_time=st_time+time_depth*60*60*24
pair = 'USDT_BTC'
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=1800" % (pair,st_time,end_time))
resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=14400" % (pair,st_time,end_time))
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=300" % (pair,st_time,end_time))
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=86400" % (pair,st_time,end_time))
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=21600" % (pair,st_time,end_time))
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'])
df['openinterest']=0
df['date'] = pd.to_datetime(df['date'], unit='s')
#df = df[(df['date'] > '2018-1-1') & (df['date'] <= '2018-2-1')]
#df = df[(df['date'] > '2017-9-1') & (df['date'] <= '2018-1-1')]
df = df[(df['date'] >= '2018-4-1')]
df = df.set_index('date')
#print(df)
return df
#################################################
df = get_polonix()
data = bt.feeds.PandasData(dataname=df)
cerebro.adddata(data, name='Poloniex')
import json
import time
import math
from datetime import datetime
import pandas as pd
def get_polonix() :
time_depth = 500
start_day = 500
st_time=time.time()-start_day*24*60*60
end_time=st_time+time_depth*60*60*24
pair = 'USDT_BTC'
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=1800" % (pair,st_time,end_time))
resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=14400" % (pair,st_time,end_time))
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=300" % (pair,st_time,end_time))
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=86400" % (pair,st_time,end_time))
#resource=requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=%s&start=%s&end=%s&period=21600" % (pair,st_time,end_time))
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'])
df['openinterest']=0
df['date'] = pd.to_datetime(df['date'], unit='s')
#df = df[(df['date'] > '2018-1-1') & (df['date'] <= '2018-2-1')]
#df = df[(df['date'] > '2017-9-1') & (df['date'] <= '2018-1-1')]
df = df[(df['date'] >= '2018-4-1')]
df = df.set_index('date')
#print(df)
return df
#################################################
df = get_polonix()
data = bt.feeds.PandasData(dataname=df)
cerebro.adddata(data, name='Poloniex')
Комментариев нет:
Отправить комментарий