Skip to content

Commit 9fdca64

Browse files
committed
2 parents 12c57c7 + caf43a0 commit 9fdca64

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

QACTPBeeBroker/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from QACTPBeeBroker.setting import eventmq_ip, ip
88
from QAPUBSUB.producer import publisher_routing, publisher_topic
99

10-
__version__ = '1.2'
10+
__version__ = '1.3'
1111
__author__ = 'yutiansut'
1212

1313

@@ -41,6 +41,7 @@ def on_tick(self, tick):
4141
return
4242
try:
4343
x = dumps(tick) #
44+
print(tick.symbol)
4445
self.pub.pub(x, routing_key=tick.symbol)
4546
except Exception as e:
4647
print(e)
@@ -103,8 +104,12 @@ def go(userid, password, brokerid, mdaddr, tdaddr, appid, authcode):
103104
cont['product'] = cont['product'].value
104105
cont['date'] = cur_date
105106
print(cont)
106-
contractdb.update_one({'gateway_name': 'ctp', 'symbol': cont['symbol']}, {
107-
'$set': cont}, upsert=True)
107+
try:
108+
contractdb.update_one({'gateway_name': 'ctp', 'symbol': cont['symbol']}, {
109+
'$set': cont}, upsert=True)
110+
except Exception as e:
111+
print(e)
112+
108113

109114

110115
@click.command()

beebroker.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from time import sleep
2+
3+
from ctpbee.interface.ctp.td_api import BeeTdApi
4+
5+
6+
class TdApi(BeeTdApi):
7+
8+
def __init__(self):
9+
super().__init__(event_engine=None)
10+
11+
def on_event(self, type, data):
12+
print(type, data)
13+
14+
15+
if __name__ == '__main__':
16+
api = TdApi()
17+
login_info = {
18+
"userid": "089131",
19+
"password": "350888",
20+
"brokerid": "9999",
21+
# 24小时
22+
"md_address": "tcp://180.168.146.187:10131",
23+
"td_address": "tcp://180.168.146.187:10130",
24+
# # 移动
25+
# "md_address": "tcp://218.202.237.33:10112",
26+
# "td_address": "tcp://218.202.237.33:10102",
27+
"product_info": "",
28+
"appid": "simnow_client_test",
29+
"auth_code": "0000000000000000",
30+
}
31+
api.connect(login_info)
32+
33+
# api.send_order()
34+
# api.cancel_order()
35+
while True:
36+
api.query_account()
37+
sleep(2)
38+
api.query_position()
39+
sleep(2)

readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,26 @@ ctpbee这个项目用的太爽了...再次感谢somewheve
99

1010

1111

12+
```
13+
pip install QACTPBeeBroker
14+
```
15+
16+
开发版本使用
17+
18+
```
19+
pip install git+https://github.com/yutiansut/QACTPBeeBroker
20+
```
21+
22+
23+
具体使用方法:
24+
25+
```
26+
QACTPBEE --userid xxxx --password xxxx --brokerid xxxx --mdaddr xxxxx --tdaddr xxxx --appid xxx --authcode xxxx
27+
28+
```
29+
30+
默认给出的是一个simnow的连接参数, 你可以快速使用
31+
32+
```
33+
QACTPBEE --userid 你的simnow账户 --password 你的simnow密码
34+
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def read(fname):
6262
'Intended Audience :: Developers',
6363
'Operating System :: OS Independent',
6464
],
65-
install_requires=['quantaxis', 'quantaxis_pubsub==1.6.2'],
65+
install_requires=['quantaxis', 'quantaxis_pubsub>=1.6.3', 'ctpbee<=0.31.2'],
6666
entry_points={
6767
'console_scripts': [
6868
'QACTPBEE = QACTPBeeBroker.__init__:go',

0 commit comments

Comments
 (0)