资源加载中... loading...

python 回测时报乱码错误

Author: jklwonder, Created: 2018-03-11 01:03:00, Updated:

Traceback (most recent call last): File “<string>”, line 74, in main File “<string>”, line 24, in Buy_Sold File “<string>”, line 2127, in GetTicker File “<string>”, line 1666, in __delay File “<string>”, line 1685, in rolling O0i1II1Iiii1I11

报错信息如下所示,大致就是调用getticker数据,在N次调用都没有问题的,不知道那次就不能调用了


More

jklwonder 你好 可以加你qq沟通一下么

发明者量化-小小梦 您好 这个问题 可能需要看下代码, 可以 贴下代码 看下么。

jklwonder 报错的信息 是 Traceback (most recent call last): File "<string>", line 27, in main File "<string>", line 14, in ComparePrice File "<string>", line 2127, in GetTicker File "<string>", line 1665, in __delay File "<string>", line 978, in Sleep O0i1II1Iiii1I11

jklwonder '''backtest start: 2018-02-03 00:00:00 end: 2018-02-10 12:00:00 period: 1m exchanges: [{"eid":"Bitfinex","currency":"BTC","balance":100000,"stocks":30},{"eid":"OKCoin_EN","currency":"BTC","balance":100000,"stocks":30}] ''' import traceback import time import numpy as np import pandas as pd import os def ComparePrice(B0P1Diff,B1P0Diff,j): #比较两个交易所的价差 price0=exchanges[0].GetTicker() price1=exchanges[1].GetTicker() #如果e0价格高于e1 B0P1Diff[j]=price0['Buy']/(price1['Sell']) B1P0Diff[j]=price0['Sell']/(price1['Buy']) def main(): B0P1Diff={} B1P0Diff={} i=0 Amount=0.01 #一次买卖的币的量 while(True): try: ComparePrice(B0P1Diff,B1P0Diff,i) i=i+1 except Exception: Log(traceback.format_exc()) Log(i) exit(0) B0P1Array=np.array(list(B0P1Diff.values())) B1P0Array=np.array(list(B1P0Diff.values())) ratioB0P1=np.mean([B0P1Array]) #在Num次迭代下发现的两个交易所的价差 ratioB1P0=np.mean([B1P0Array]) Log('meanB0P1',(ratioB0P1)) Log('meanB1P0',(ratioB1P0)) # exchange[2].Buy(11600,1) def onerror(): Log("Error")