Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Apr 7, 2020
2 parents 12c57c7 + caf43a0 commit 9fdca64
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
11 changes: 8 additions & 3 deletions QACTPBeeBroker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
39 changes: 39 additions & 0 deletions beebroker.py
Original file line number Diff line number Diff line change
@@ -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)
23 changes: 23 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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密码
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9fdca64

Please sign in to comment.