MCPcopy Create free account
hub / github.com/shidenggui/easyquant / ClockIntervalHandler

Class ClockIntervalHandler

easyquant/push_engine/clock_engine.py:21–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20
21class ClockIntervalHandler:
22 def __init__(self, clock_engine, interval, trading=True, call=None):
23 """
24 :param interval: float(minute)
25 :param trading: 在交易阶段才触发
26 :return:
27 """
28 self.clock_engine = clock_engine
29 self.clock_type = interval
30 self.interval = interval
31 self.second = int(interval * 60)
32 self.trading = trading
33 self.call = call or (lambda: None)
34
35 def is_active(self):
36 if self.trading:
37 if not self.clock_engine.trading_state:
38 return False
39 return int(self.clock_engine.now) % self.second == 0
40
41 def __eq__(self, other):
42 if isinstance(other, ClockIntervalHandler):
43 return self.interval == other.interval
44 else:
45 return False
46
47 def __hash__(self):
48 return self.second
49
50
51class ClockMomentHandler:

Callers 1

_register_intervalMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected