From b8f62519f65017a856c3741c93f65ebba8f0a944 Mon Sep 17 00:00:00 2001 From: "Roberson, Martin [GBM Public]" Date: Mon, 12 Aug 2024 16:49:18 +0000 Subject: [PATCH] Chore: Make release 1.0.109 --- gs_quant/backtests/generic_engine.py | 5 +- gs_quant/test/timeseries/test_measures.py | 111 +++++++++++++++++++++- gs_quant/timeseries/measures.py | 43 +++++++++ 3 files changed, 156 insertions(+), 3 deletions(-) diff --git a/gs_quant/backtests/generic_engine.py b/gs_quant/backtests/generic_engine.py index de4f4b2a..41f6576f 100644 --- a/gs_quant/backtests/generic_engine.py +++ b/gs_quant/backtests/generic_engine.py @@ -605,6 +605,7 @@ def new_pricing_context(self): is_batch=is_batch, use_historical_diddles_only=True) context._max_concurrent = 10000 + context._dates_per_batch = 200 return context @@ -792,7 +793,7 @@ def _price_semi_det_triggers(self, backtest, risks): p.results = port.calc(tuple(risks)) def _process_triggers_and_actions_for_date(self, d, strategy, backtest, risks): - logger.info(f'{d}: Processing triggers and actions') + logger.debug(f'{d}: Processing triggers and actions') # path dependent for trigger in strategy.triggers: if trigger.calc_type == CalcType.path_dependent: @@ -892,7 +893,7 @@ def _calc_new_trades(self, backtest, risks): leaves = [] for leaf in portfolio: if leaf.name not in trades_for_date: - logger.info(f'{day}: new portfolio position {leaf} scheduled for calculation') + logger.debug(f'{day}: new portfolio position {leaf.name} scheduled for calculation') leaves.append(leaf) if len(leaves): diff --git a/gs_quant/test/timeseries/test_measures.py b/gs_quant/test/timeseries/test_measures.py index b6e31351..8824c0c5 100644 --- a/gs_quant/test/timeseries/test_measures.py +++ b/gs_quant/test/timeseries/test_measures.py @@ -4601,7 +4601,17 @@ def test_weighted_average_valuation_curve_for_calendar_strip(): def test_fundamental_metrics(): replace = Replacer() mock_spx = Index('MA890', AssetClass.Equity, 'SPX') - mock_rb = CustomBasket(GsAsset(AssetClass.Equity, AssetType.Research_Basket, 'GSTEST01')) + mock_rb = CustomBasket(GsAsset(AssetClass.Equity, AssetType.Research_Basket, 'GSTEST01', None, None, None, None, + None, None, None, None, None, None, None, None, None, None, None, None, None, None, + None, None, {'flagship': True})) + mock_non_flagship = CustomBasket(GsAsset(AssetClass.Equity, AssetType.Research_Basket, 'GSTEST01', None, None, None, + None, None, None, None, None, None, None, None, None, None, None, None, + None, None, None, None, None, {'flagship': False})) + mock_basket_no_parameters = CustomBasket(GsAsset(AssetClass.Equity, AssetType.Research_Basket, 'GSTEST01')) + mock_basket_no_flagship_parameter = CustomBasket(GsAsset(AssetClass.Equity, AssetType.Research_Basket, 'GSTEST01', + None, None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, None, + None, None, {})) replace('gs_quant.timeseries.measures.GsDataApi.get_market_data', mock_eq) period = '1y' direction = tm.FundamentalMetricPeriodDirection.FORWARD @@ -4744,6 +4754,105 @@ def test_fundamental_metrics(): with pytest.raises(NotImplementedError): tm.current_constituents_sales_per_share(..., period, direction, real_time=True) + with pytest.raises(NotImplementedError): + tm.current_constituents_dividend_yield(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_earnings_per_share(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_earnings_per_share_positive(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_net_debt_to_ebitda(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_book(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_cash(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_earnings(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_earnings_positive(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_sales(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_return_on_equity(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_sales_per_share(mock_non_flagship, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_dividend_yield(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_earnings_per_share(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_earnings_per_share_positive(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_net_debt_to_ebitda(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_book(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_cash(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_earnings(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_earnings_positive(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_sales(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_return_on_equity(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_sales_per_share(mock_basket_no_parameters, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_dividend_yield(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_earnings_per_share(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_earnings_per_share_positive(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_net_debt_to_ebitda(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_book(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_cash(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_earnings(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_earnings_positive(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_price_to_sales(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_return_on_equity(mock_basket_no_flagship_parameter, period, direction) + + with pytest.raises(NotImplementedError): + tm.current_constituents_sales_per_share(mock_basket_no_flagship_parameter, period, direction) + replace.restore() diff --git a/gs_quant/timeseries/measures.py b/gs_quant/timeseries/measures.py index 8fe2b121..d6b96028 100644 --- a/gs_quant/timeseries/measures.py +++ b/gs_quant/timeseries/measures.py @@ -3632,6 +3632,10 @@ def current_constituents_dividend_yield(asset: Asset, period: str, period_direct if real_time: raise NotImplementedError('real-time current_constituents_dividend_yield not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_dividend_yield not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_DIVIDEND_YIELD.value @@ -3667,6 +3671,9 @@ def current_constituents_earnings_per_share(asset: Asset, period: str, if real_time: raise NotImplementedError('real-time current_constituents_earnings_per_share not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_earnings_per_share not implemented for this basket. ' + 'Only available for flagship baskets') mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_EARNINGS_PER_SHARE.value @@ -3702,6 +3709,10 @@ def current_constituents_earnings_per_share_positive(asset: Asset, period: str, if real_time: raise NotImplementedError('real-time current_constituents_earnings_per_share_positive not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_earnings_per_share_positive not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_EARNINGS_PER_SHARE_POSITIVE.value @@ -3737,6 +3748,10 @@ def current_constituents_net_debt_to_ebitda(asset: Asset, period: str, if real_time: raise NotImplementedError('real-time current_constituents_net_debt_to_ebitda not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_net_debt_to_ebitda not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_NET_DEBT_TO_EBITDA.value @@ -3771,6 +3786,10 @@ def current_constituents_price_to_book(asset: Asset, period: str, period_directi if real_time: raise NotImplementedError('real-time current_constituents_price_to_book not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_price_to_book not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_PRICE_TO_BOOK.value @@ -3805,6 +3824,10 @@ def current_constituents_price_to_cash(asset: Asset, period: str, period_directi if real_time: raise NotImplementedError('real-time current_constituents_price_to_cash not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_price_to_cash not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_PRICE_TO_CASH.value @@ -3840,6 +3863,10 @@ def current_constituents_price_to_earnings(asset: Asset, period: str, if real_time: raise NotImplementedError('real-time current_constituents_price_to_earnings not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_price_to_earnings not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_PRICE_TO_EARNINGS.value @@ -3875,6 +3902,10 @@ def current_constituents_price_to_earnings_positive(asset: Asset, period: str, if real_time: raise NotImplementedError('real-time current_constituents_price_to_earnings_positive not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_price_to_earnings_positive not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_PRICE_TO_EARNINGS_POSITIVE.value @@ -3909,6 +3940,10 @@ def current_constituents_price_to_sales(asset: Asset, period: str, period_direct if real_time: raise NotImplementedError('real-time current_constituents_price_to_sales not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_price_to_sales not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_PRICE_TO_SALES.value @@ -3943,6 +3978,10 @@ def current_constituents_return_on_equity(asset: Asset, period: str, period_dire if real_time: raise NotImplementedError('real-time current_constituents_return_on_equity not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_return_on_equity not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_RETURN_ON_EQUITY.value @@ -3977,6 +4016,10 @@ def current_constituents_sales_per_share(asset: Asset, period: str, period_direc if real_time: raise NotImplementedError('real-time current_constituents_sales_per_share not implemented') + if not asset.get_entity().get('parameters', {'flagship': False}).get('flagship', False): + raise NotImplementedError('current_constituents_sales_per_share not implemented for this basket. ' + 'Only available for flagship baskets') + mqid = asset.get_marquee_id() metric = DataMeasure.CURRENT_CONSTITUENTS_SALES_PER_SHARE.value