Skip to content

Commit

Permalink
Chore: Make release 1.2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
martinroberson authored and razvan-dorobantu committed Jan 8, 2025
1 parent d33224b commit 2e78d2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gs_quant/backtests/predefined_asset_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 12 additions & 5 deletions gs_quant/backtests/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e78d2a

Please sign in to comment.