Skip to content

Commit

Permalink
##update
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Oct 17, 2019
1 parent 2ff72aa commit caf43a0
Show file tree
Hide file tree
Showing 3 changed files with 48 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

__version__ = '1.2'
__version__ = '1.3'
__author__ = 'yutiansut'


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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__':
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)
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 caf43a0

Please sign in to comment.