From 2e78d2ae9d60e7738d922dc1e22e00bc5fe8e204 Mon Sep 17 00:00:00 2001 From: "Roberson, Martin [GBM Public]" Date: Wed, 8 Jan 2025 13:20:41 +0000 Subject: [PATCH] Chore: Make release 1.2.16 --- gs_quant/backtests/predefined_asset_engine.py | 2 +- gs_quant/backtests/triggers.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gs_quant/backtests/predefined_asset_engine.py b/gs_quant/backtests/predefined_asset_engine.py index 490b3520..8716a6ce 100644 --- a/gs_quant/backtests/predefined_asset_engine.py +++ b/gs_quant/backtests/predefined_asset_engine.py @@ -45,7 +45,7 @@ def generate_orders(self, state: dt.datetime, backtest: PredefinedAssetBacktest, orders = [] for pricable in self.action.priceables: - quantity = pricable.instrument_quantity * 1 if info is None else info.scaling + quantity = pricable.instrument_quantity * 1 if info is None or info.scaling is None else info.scaling orders.append(OrderAtMarket(instrument=pricable, quantity=quantity, generation_time=state, diff --git a/gs_quant/backtests/triggers.py b/gs_quant/backtests/triggers.py index cacc09c5..3939f087 100644 --- a/gs_quant/backtests/triggers.py +++ b/gs_quant/backtests/triggers.py @@ -266,12 +266,19 @@ def __post_init__(self): def has_triggered(self, state: Union[dt.date, dt.datetime], backtest: BackTest = None) -> TriggerInfo: if self.entire_day: + dates = sorted(self.dates_from_datetimes) if isinstance(state, dt.datetime): - return TriggerInfo(state.date() in self.dates_from_datetimes) - elif isinstance(state, dt.date): - return TriggerInfo(state in self.dates_from_datetimes) - - return TriggerInfo(state in self.dates) + state = state.date() + else: + dates = sorted(self.dates) + if state in dates: + next_state = None + if dates.index(state) < len(dates) - 1: + next_state = dates[dates.index(state) + 1] + return TriggerInfo(True, {AddTradeAction: AddTradeActionInfo(scaling=None, next_schedule=next_state), + AddScaledTradeAction: AddScaledTradeActionInfo(next_schedule=next_state), + HedgeAction: HedgeActionInfo(next_schedule=next_state)}) + return TriggerInfo(False) def get_trigger_times(self): return self.dates_from_datetimes or self.dates