diff --git a/QACTPBeeBroker/__init__.py b/QACTPBeeBroker/__init__.py index aa812d3..22364c2 100644 --- a/QACTPBeeBroker/__init__.py +++ b/QACTPBeeBroker/__init__.py @@ -7,7 +7,7 @@ from QACTPBeeBroker.setting import eventmq_ip, ip from QAPUBSUB.producer import publisher_routing, publisher_topic -__version__ = '1.2' +__version__ = '1.3' __author__ = 'yutiansut' @@ -41,6 +41,7 @@ def on_tick(self, tick): return try: x = dumps(tick) # + print(tick.symbol) self.pub.pub(x, routing_key=tick.symbol) except Exception as e: print(e) @@ -103,8 +104,12 @@ def go(userid, password, brokerid, mdaddr, tdaddr, appid, authcode): cont['product'] = cont['product'].value cont['date'] = cur_date print(cont) - contractdb.update_one({'gateway_name': 'ctp', 'symbol': cont['symbol']}, { - '$set': cont}, upsert=True) + try: + contractdb.update_one({'gateway_name': 'ctp', 'symbol': cont['symbol']}, { + '$set': cont}, upsert=True) + except Exception as e: + print(e) + @click.command() diff --git a/beebroker.py b/beebroker.py new file mode 100644 index 0000000..a627c8a --- /dev/null +++ b/beebroker.py @@ -0,0 +1,39 @@ +from time import sleep + +from ctpbee.interface.ctp.td_api import BeeTdApi + + +class TdApi(BeeTdApi): + + def __init__(self): + super().__init__(event_engine=None) + + def on_event(self, type, data): + print(type, data) + + +if __name__ == '__main__': + api = TdApi() + login_info = { + "userid": "089131", + "password": "350888", + "brokerid": "9999", + # 24小时 + "md_address": "tcp://180.168.146.187:10131", + "td_address": "tcp://180.168.146.187:10130", + # # 移动 + # "md_address": "tcp://218.202.237.33:10112", + # "td_address": "tcp://218.202.237.33:10102", + "product_info": "", + "appid": "simnow_client_test", + "auth_code": "0000000000000000", + } + api.connect(login_info) + + # api.send_order() + # api.cancel_order() + while True: + api.query_account() + sleep(2) + api.query_position() + sleep(2) \ No newline at end of file diff --git a/readme.md b/readme.md index 3bfb33c..8d89dee 100644 --- a/readme.md +++ b/readme.md @@ -9,3 +9,26 @@ ctpbee这个项目用的太爽了...再次感谢somewheve +``` +pip install QACTPBeeBroker +``` + +开发版本使用 + +``` +pip install git+https://github.com/yutiansut/QACTPBeeBroker +``` + + +具体使用方法: + +``` +QACTPBEE --userid xxxx --password xxxx --brokerid xxxx --mdaddr xxxxx --tdaddr xxxx --appid xxx --authcode xxxx + +``` + +默认给出的是一个simnow的连接参数, 你可以快速使用 + +``` +QACTPBEE --userid 你的simnow账户 --password 你的simnow密码 +``` diff --git a/setup.py b/setup.py index 561c946..7f07ab8 100644 --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ def read(fname): 'Intended Audience :: Developers', 'Operating System :: OS Independent', ], - install_requires=['quantaxis', 'quantaxis_pubsub==1.6.2'], + install_requires=['quantaxis', 'quantaxis_pubsub>=1.6.3', 'ctpbee<=0.31.2'], entry_points={ 'console_scripts': [ 'QACTPBEE = QACTPBeeBroker.__init__:go',