def get_buy_count(order_id): orders = HuobiService.order_matchresults(order_id) if orders['status'] == 'ok': count = 0 for i in xrange(len(orders['data'])): count = count + float(orders['data'][i]['filled-amount']) - float( orders['data'][i]['filled-fees']) return count else: # 如果一次不成功, 再试一次 orders = HuobiService.order_matchresults(order_id) if orders['status'] == 'ok': count = 0 for i in xrange(len(orders['data'])): count = count + orders['data'][i]['filled-amount'] - orders[ 'data'][i]['filled-fees'] return count else: # 第二次还不成功, 返回-1 return -1
# soc_kline = HuobiService.get_kline("socusdt", "1day", "100") ''' 2018-09-18 11:11 今天取百日数据算的 k = 6.9950; n = 0.1150; 用这组数据回测收益较低, 所以这里取106日的数据试试 2018-09-18 106日的数据算出来 k = 9.1002; n = 0.0458 ''' days = 106 soc_kline = HuobiService.get_kline("socusdt", "1day", "%d" % days) soc_day_prices = [] for soc_bean in soc_kline['data']: soc_day_prices.append(float(soc_bean['close'])) print soc_day_prices common_utils.write_json("soc_day_prices.txt", soc_day_prices, list) time.sleep(5) wicc_kline = HuobiService.get_kline("wiccusdt", "1day", "%d" % days) wicc_day_prices = [] for wicc_bean in wicc_kline['data']: wicc_day_prices.append(float(wicc_bean['close'])) print wicc_day_prices common_utils.write_json("wicc_day_prices.txt", wicc_day_prices, list) if __name__ == "__main__": print "test main start" # get_soc_wicc_day_prices() # content = HuobiService.orders_matchresults("socusdt") # 12350913620 content = HuobiService.order_matchresults("12808178820") print common_utils.get_json(content, map)