掘金社区
下载了最新的python sdk,运行其中的sample,如test_stratepy.py。
默认设置mode=1
运行提示:无法连接服务器
修改成mode=2,3都是同样提示
但是修改成mode=4后,返回值变成了1502,查了一下是日期格式非法,但是这个例子中没有任何日期参数啊,请问这是为什么呢?其他例子也是同样的问题。
谢谢!
from gmsdk.api import StrategyBase
from gmsdk.util import bar_to_dict
class MyStrategy(StrategyBase):
def init(self, *args, **kwargs):
super(MyStrategy, self).init(*args, **kwargs)
self.oc = True
def on_login(self):
print('logged in')
def on_error(self, err_code, msg):
print('get error: %s - %s' % (err_code, msg))
def on_bar(self, bar):
print(bar_to_dict(bar))
if self.oc:
self.open_long(bar.exchange, bar.sec_id, 0, 100)
else:
self.close_long(bar.exchange, bar.sec_id, 0, 100)
self.oc = not self.oc
if name == 'main':
ret = MyStrategy(
username='username',
password='ps',
strategy_id='strategy_2',
subscribe_symbols='CFFEX.IF1603.bar.60',
mode=4
).run()
print(('exit code: ', ret))
评论: 1