From f71dca4cfa7c53f23dbf4c18ae96d891d02caf20 Mon Sep 17 00:00:00 2001 From: todd Date: Wed, 7 Dec 2022 06:01:36 -0700 Subject: [PATCH] Removed last usage of missing_contact --- syscore/objects.py | 1 - sysproduction/reporting/data/pandl.py | 20 +++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/syscore/objects.py b/syscore/objects.py index 82484861db..72c2ccaccb 100755 --- a/syscore/objects.py +++ b/syscore/objects.py @@ -13,7 +13,6 @@ def __repr__(self): return self._name -missing_contract = named_object("missing contract") missing_instrument = named_object("missing instrument") missing_order = named_object("missing order") diff --git a/sysproduction/reporting/data/pandl.py b/sysproduction/reporting/data/pandl.py index f89542f310..21d613aec2 100644 --- a/sysproduction/reporting/data/pandl.py +++ b/sysproduction/reporting/data/pandl.py @@ -4,7 +4,7 @@ import pandas as pd from syscore.exceptions import missingContract -from syscore.objects import arg_not_supplied, missing_data, missing_contract +from syscore.objects import arg_not_supplied, missing_data from sysobjects.contracts import futuresContract from sysobjects.production.tradeable_object import instrumentStrategy @@ -177,10 +177,11 @@ def get_period_perc_pandl_for_instrument_all_strategies_in_date_range( ) -> float: print("Getting p&l for %s" % instrument_code) - pandl_across_contracts = self.pandl_for_instrument_across_contracts( - instrument_code - ) - if pandl_across_contracts is missing_contract: + try: + pandl_across_contracts = self.pandl_for_instrument_across_contracts( + instrument_code + ) + except missingContract: return 0.0 pandl_series = pandl_across_contracts.sum(axis=1) @@ -211,12 +212,9 @@ def instrument_pandl_store(self): def _get_pandl_for_instrument_across_contracts( self, instrument_code: str ) -> pd.DataFrame: - try: - pandl_df_all_data = get_df_of_perc_pandl_series_for_instrument_all_strategies_across_contracts_in_date_range( - self.data, instrument_code, self.start_date, self.end_date - ) - except missingContract: - return missing_contract + pandl_df_all_data = get_df_of_perc_pandl_series_for_instrument_all_strategies_across_contracts_in_date_range( + self.data, instrument_code, self.start_date, self.end_date + ) pandl_df = pandl_df_all_data[self.start_date : self.end_date]