Skip to content

Commit e78e6ec

Browse files
committed
#update for save broker list
1 parent bf64248 commit e78e6ec

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Diff for: .vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"restructuredtext.confPath": ""
2+
"restructuredtext.confPath": "",
3+
"python.pythonPath": "C:\\ProgramData\\Anaconda3\\python.exe"
34
}

Diff for: QACTPBeeBroker/__init__.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
from string import digits
33
import json
44
from json import dumps
5-
from datetime import time, datetime
5+
from datetime import time, datetime, date
66
from time import sleep
77

88
from ctpbee import ExtAbstract
99
from ctpbee import CtpBee
1010
from ctpbee import subscribe
1111

1212
from QAPUBSUB.producer import publisher_routing
13+
import pymongo
1314

1415

1516
def auth_time(timed):
@@ -52,7 +53,7 @@ def on_order(self, order):
5253
def on_tick(self, tick):
5354
"""tick process function"""
5455
symbol = tick.symbol
55-
r = tick.__dict__
56+
r = tick.__dict__
5657
try:
5758
r['exchange'] = str(tick.exchange.value)
5859
r['datetime'] = str(r['datetime'])
@@ -71,9 +72,6 @@ def on_shared(self, shared):
7172
# print(shared)
7273

7374

74-
75-
76-
7775
def go():
7876
app = CtpBee("last", __name__)
7977
info = {
@@ -94,7 +92,17 @@ def go():
9492
app.start()
9593
import time
9694
time.sleep(2)
97-
print(app.recorder.get_all_contracts())
95+
contracts = app.recorder.get_all_contracts()
96+
cur_date = str(date.today())
97+
cur_contract = []
98+
for item in contracts:
99+
cont = item.__dict__
100+
cont['exchange'] =cont['exchange'].value
101+
cont['product'] = cont['product'].value
102+
cur_contract.append(cont)
103+
104+
pymongo.MongoClient().QAREALTIME.contract.update_one({'exchange': 'ctp'}, {
105+
'$set': {'contract': cur_contract, 'date': cur_date}},upsert=True)
98106

99107
for contract in app.recorder.get_all_contracts():
100108
print(contract.symbol)

0 commit comments

Comments
 (0)