MCPcopy Create free account
hub / github.com/QuantFans/quantdigger / run

Method run

quantdigger/kernel/engine/execute_unit.py:44–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42 BarTracker(self, pcon)
43
44 def run(self):
45 """"""
46 print 'running...'
47 bar_index = 0
48 while bar_index < self._data_length:
49 #
50 latest_bars = { }
51 for tracker in self.trackers:
52 bar = tracker.update_curbar(bar_index)
53 latest_bars[tracker._main_contract] = bar
54 # 在回测中无需MARKET事件。
55 # 这样可以加速回测速度。
56 for algo in self._strategies:
57 bar = algo.update_curbar(bar_index)
58 algo.exchange.update_datetime(bar.datetime)
59 algo.blotter.update_datetime(bar.datetime)
60 latest_bars[algo._main_contract] = bar
61 algo.blotter.update_bar(latest_bars)
62 #algo.exchange.make_market(bar)
63 # 对新的价格运行算法。
64 algo.execute_strategy()
65 while True:
66 # 事件处理。
67 try:
68 event = algo.events_pool.get()
69 except Queue.Empty:
70 break
71 except IndexError:
72 break
73 else:
74 if event is not None:
75 #if event.type == 'MARKET':
76 #strategy.calculate_signals(event)
77 #port.update_timeindex(event)
78 if event.type == Event.SIGNAL:
79 algo.blotter.update_signal(event)
80
81 elif event.type == Event.ORDER:
82 algo.exchange.update_order(event)
83
84 elif event.type == Event.FILL:
85 algo.blotter.update_fill(event)
86 # 价格撮合。note: bar价格撮合要求撮合置于运算后面。
87 algo.exchange.make_market(bar)
88 bar_index += 1
89
90 def load_data(self, pcontract):
91 """ 加载周期合约数据

Callers 10

iFunction · 0.45
XbFunction · 0.45
tinymce.min.jsFile · 0.45
tickFunction · 0.45
AnimationFunction · 0.45
config.jsFile · 0.45
iFunction · 0.45
XbFunction · 0.45
main.pyFile · 0.45

Calls 9

update_barMethod · 0.80
getMethod · 0.80
update_orderMethod · 0.80
make_marketMethod · 0.80
update_curbarMethod · 0.45
update_datetimeMethod · 0.45
execute_strategyMethod · 0.45
update_signalMethod · 0.45
update_fillMethod · 0.45

Tested by

no test coverage detected