Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug of generating next_time when ClockMomentHandler init #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions easyquant/push_engine/clock_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ def __init__(self, clock_engine, clock_type, moment=None, is_trading_date=True,
self.is_trading_date = is_trading_date
self.makeup = makeup
self.call = call or (lambda: None)
self.next_time = datetime.datetime.combine(
self.clock_engine.now_dt.date(),
self.moment,
)
#只在交易日执行定时任务(is_trading_date == True),当天为非交易日时,取最近一个交易日来设置next_time
if self.is_trading_date == True and not etime.is_trade_date(self.clock_engine.now_dt):
next_date = etime.get_next_trade_date(self.clock_engine.now_dt)
self.next_time = datetime.datetime.combine(
next_date,
self.moment
)
else:
self.next_time = datetime.datetime.combine(
self.clock_engine.now_dt.date(),
self.moment,
)

if not self.makeup and self.is_active():
self.update_next_time()
Expand Down