Skip to content

Commit

Permalink
#update for realtime_stock
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Aug 29, 2019
1 parent f5d20f5 commit 77b7fbb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions QARealtimeCollector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ def resample(code, freq, model):
def random(code, date, price, interval):
r = QARTC_RandomTick(code, date, price, interval)
r.start()


def stock_collector():
QARTC_Stock().start()
2 changes: 1 addition & 1 deletion QARealtimeCollector/collectors/stockcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run(self):


if __name__ == "__main__":
r = QARTC_Stock('yutiansut', '940809')
r = QARTC_Stock()
r.subscribe('000001')
r.subscribe('000002')
r.start()
Expand Down
7 changes: 6 additions & 1 deletion QARealtimeCollector/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tornado.web import Application, RequestHandler, authenticated

import QUANTAXIS as QA
from QAPUBSUB.producer import publisher, publisher_routing
from QARealtimeCollector.collectors import (QARTC_CtpBeeCollector,
QARTC_CTPTickCollector,
QARTC_RandomTick, QARTC_Stock,
Expand Down Expand Up @@ -47,7 +48,11 @@ def post(self):
self.handler[market_type][code].start()
self.write({'result': 'success'})
else:
pass
publisher_routing(exchange='QARealtime_Market', routing_key='stock').pub(json.dumps({
'topic': 'subscribe',
'code': code
}), routing_key='stock')
self.handler[market_type][code] = True

else:
self.write({'result': 'already exist'})
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def read(fname):
'QARC_Resample = QARealtimeCollector.__init__:resample',
'QARC_Random = QARealtimeCollector.__init__:random',
'QARC_CTP = QARealtimeCollector.__init__:start_ctp',
'QARC_Stock = QARealtimeCollector.__init__:stock_collector',
'QARC_WEBSERVER = QARealtimeCollector.webserver:main'
]
},
Expand Down

0 comments on commit 77b7fbb

Please # to comment.