1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-03 02:50:58 +08:00

fix TWAP strategy

This commit is contained in:
Young
2021-07-06 10:02:20 +00:00
parent bdac9f4dda
commit 03d6facbd2

View File

@@ -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