hdf5存储格式会根据data
存储到不同的表,请注意。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| from OkcoinSpotAPI import OKCoinSpot from OkcoinFutureAPI import OKCoinFuture import time
import numpy as np import pandas as pd
import datetime
def getYesterday(): today=datetime.date.today() oneday=datetime.timedelta(days=1) yesterday=today-oneday return yesterday
apikey = 'XXXX' secretkey = 'XXXXX' okcoinRESTURL = 'www.okcoin.com'
okcoinSpot = OKCoinSpot(okcoinRESTURL,apikey,secretkey)
okcoinFuture = OKCoinFuture(okcoinRESTURL,apikey,secretkey)
print(u' 开始时间 ') yesterdayTime = int(time.mktime(getYesterday().timetuple()) * 1000) print (getYesterday()) print (yesterdayTime)
print (u' okCoin Com 期货 当周 Kline 日线 ') thisWeekArr = okcoinFuture.future_kline('btc_usd','1day','this_week', 2, yesterdayTime) print (thisWeekArr) b = pd.DataFrame(thisWeekArr)
h5 = pd.HDFStore('../data/test1.h5','a') h5.append('df',b) h5.close()
h5 = pd.HDFStore('../data/test1.h5','r') print (h5) e = h5['df'] h5.close() print (e)
|