From 03d6facbd22a8362573fdfe7f8b7d3eb3b45c5a8 Mon Sep 17 00:00:00 2001 From: Young Date: Tue, 6 Jul 2021 10:02:20 +0000 Subject: [PATCH] fix TWAP strategy --- qlib/contrib/strategy/rule_strategy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qlib/contrib/strategy/rule_strategy.py b/qlib/contrib/strategy/rule_strategy.py index d18eb2a27..e2e34e112 100644 --- a/qlib/contrib/strategy/rule_strategy.py +++ b/qlib/contrib/strategy/rule_strategy.py @@ -108,8 +108,8 @@ class TWAPStrategy(BaseStrategy): start_idx, end_idx = get_start_end_idx(self, self.outer_trade_decision) trade_len = end_idx - start_idx + 1 - if trade_step < start_idx: - # It is not time to start trading + if trade_step < start_idx or trade_step > end_idx: + # It is not time to start trading or trading has ended. return TradeDecisionWO(order_list=[], strategy=self) rel_trade_step = trade_step - start_idx # trade_step relative to start_idx