Skip to content

Commit

Permalink
Merge pull request #889 from tgibson11/missing-data
Browse files Browse the repository at this point in the history
Remove last usage of missing_contract
  • Loading branch information
robcarver17 authored Dec 8, 2022
2 parents 4c81ce0 + 77d2e2a commit 16e7dfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion syscore/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 9 additions & 11 deletions sysproduction/reporting/data/pandl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit 16e7dfb

Please sign in to comment.