本文整理汇总了Python中Client.fetchKline方法的典型用法代码示例。如果您正苦于以下问题:Python Client.fetchKline方法的具体用法?Python Client.fetchKline怎么用?Python Client.fetchKline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.fetchKline方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: import Client [as 别名]
# 或者: from Client import fetchKline [as 别名]
ktimestr = ktime.strftime("%y-%m-%d %H:%M")
fd = os.open(store_dir+"/"+fname+"."+filetype,os.O_CREAT)
os.close(fd)
fwriter = open(store_dir+"/"+fname+"."+filetype,"r+")
if filetype == "1":
offset = (kline.time-tdaytime)/60
elif filetype == "5":
offset = (kline.time-tdaytime)/(60*5)
elif filetype == "15":
offset = (kline.time-tdaytime)/(60*15)
fwriter.seek(offset*48)
#32 + 16 + 2 = 50 + close open high low,time
fwriter.write("%6.2f,%6.2f,%6.2f,%6.2f,%s\r\n" % (kline.close,kline.open,kline.high,kline.low,ktimestr))
fwriter.close()
while True:
try:
klines = Client.fetchKline("btc_cny","1min",500,None)
store("1",klines)
klines = Client.fetchKline("btc_cny","5min",500,None)
store("5",klines)
klines = Client.fetchKline("btc_cny","15min",500,None)
store("15",klines)
time.sleep(60)
except Exception as e:
pass
示例2: stock
# 需要导入模块: import Client [as 别名]
# 或者: from Client import fetchKline [as 别名]
import traceback
kline5 = None
kline15 = None
stock1Min = stock("btc_cny",stock.OneMin,500)
stock5Min = stock("btc_cny",stock.FiveMin,500)
stock15Min = stock("btc_cny",stock.FifteenMin,500)
okcoin_websocket.stock1Min = stock1Min
okcoin_websocket.stock5Min = stock5Min
okcoin_websocket.stock15Min = stock15Min
while True:
try:
kline1 = Client.fetchKline("btc_cny","1min",100,None)
kline5 = Client.fetchKline("btc_cny","5min",50,None)
kline15 = Client.fetchKline("btc_cny","15min",30,None)
k1 = stock1Min.lastKline()
if k1==0:
k1 = kline1[-1]
elif kline1[-1].time-k1.time<=60:
k1 = kline1[-1]
else:
okcoin_websocket.pricelogging.error("kline 1min b=%s,get=%s" % (k1,kline1[-1]));
break