From 2ff72aaf784cd74ad993a81b419f7caf2e56165e Mon Sep 17 00:00:00 2001 From: Vincent yu Date: Thu, 26 Sep 2019 15:28:36 +0800 Subject: [PATCH 1/2] Update readme.md --- readme.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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密码 +``` From caf43a037ca529681647128ae0d96a84472f30fa Mon Sep 17 00:00:00 2001 From: yutiansut Date: Thu, 17 Oct 2019 14:43:02 +0800 Subject: [PATCH 2/2] ##update --- QACTPBeeBroker/__init__.py | 11 ++++++++--- beebroker.py | 39 ++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 beebroker.py diff --git a/QACTPBeeBroker/__init__.py b/QACTPBeeBroker/__init__.py index 97d1f59..cf558df 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 -__version__ = '1.2' +__version__ = '1.3' __author__ = 'yutiansut' @@ -37,6 +37,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) @@ -99,8 +100,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) + if __name__ == '__main__': 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/setup.py b/setup.py index 62363c2..dbaf3ef 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'