MCPcopy
hub / github.com/shidenggui/easyquant / __init__

Method __init__

easyquant/push_engine/clock_engine.py:52–80  ·  view source on GitHub ↗

:param clock_type: :param moment: datetime.time :param is_trading_date: bool(是否只有在交易日触发) :param makeup: 注册时,如果已经过了触发时机,是否立即触发 :return:

(self, clock_engine, clock_type, moment=None, is_trading_date=True, makeup=False, call=None)

Source from the content-addressed store, hash-verified

50
51class ClockMomentHandler:
52 def __init__(self, clock_engine, clock_type, moment=None, is_trading_date=True, makeup=False, call=None):
53 """
54 :param clock_type:
55 :param moment: datetime.time
56 :param is_trading_date: bool(是否只有在交易日触发)
57 :param makeup: 注册时,如果已经过了触发时机,是否立即触发
58 :return:
59 """
60 self.clock_engine = clock_engine
61 self.clock_type = clock_type
62 self.moment = moment
63 self.is_trading_date = is_trading_date
64 self.makeup = makeup
65 self.call = call or (lambda: None)
66 #只在交易日执行定时任务(is_trading_date == True),当天为非交易日时,取最近一个交易日来设置next_time
67 if self.is_trading_date == True and not etime.is_trade_date(self.clock_engine.now_dt):
68 next_date = etime.get_next_trade_date(self.clock_engine.now_dt)
69 self.next_time = datetime.datetime.combine(
70 next_date,
71 self.moment
72 )
73 else:
74 self.next_time = datetime.datetime.combine(
75 self.clock_engine.now_dt.date(),
76 self.moment,
77 )
78
79 if not self.makeup and self.is_active():
80 self.update_next_time()
81
82 def update_next_time(self):
83 """

Callers

nothing calls this directly

Calls 2

is_activeMethod · 0.95
update_next_timeMethod · 0.95

Tested by

no test coverage detected