Skip to content

Commit ae82bda

Browse files
author
rob
committed
2 parents aabc318 + 880bbba commit ae82bda

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

sysdata/production/TEMP_old_capital_objects.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pandas as pd
44

55
from syscore.exceptions import missingData
6-
from syscore.constants import missing_data, arg_not_supplied, failure
6+
from syscore.constants import arg_not_supplied, failure
77
from syscore.pandas.pdutils import uniquets
88

99
from sysdata.data_blob import dataBlob
@@ -82,10 +82,7 @@ def get_current_pandl_account(self) -> float:
8282
return self.get_current_capital_for_strategy(ACC_PROFIT_VALUES)
8383

8484
def get_current_capital_for_strategy(self, strategy_name: str) -> float:
85-
try:
86-
current_capital_entry = self.get_last_entry_for_strategy(strategy_name)
87-
except missingData:
88-
return missing_data
85+
current_capital_entry = self.get_last_entry_for_strategy(strategy_name)
8986

9087
capital_value = current_capital_entry.capital_value
9188

@@ -352,14 +349,6 @@ def get_all_capital_calcs(self) -> pd.DataFrame:
352349
acc_pandl = self.get_profit_and_loss_account()
353350
broker_acc = self.get_broker_account()
354351

355-
if (
356-
total_capital is missing_data
357-
or max_capital is missing_data
358-
or acc_pandl is missing_data
359-
or broker_acc is missing_data
360-
):
361-
return missing_data
362-
363352
all_capital = pd.concat(
364353
[total_capital, max_capital, acc_pandl, broker_acc], axis=1
365354
)
@@ -421,8 +410,9 @@ def _init_capital_updater(
421410
def _get_prev_broker_account_value_create_if_no_data(
422411
self, new_broker_account_value: float
423412
) -> float:
424-
prev_broker_account_value = self.capital_data.get_broker_account_value()
425-
if prev_broker_account_value is missing_data:
413+
try:
414+
prev_broker_account_value = self.capital_data.get_broker_account_value()
415+
except missingData:
426416
# No previous capital, need to set everything up
427417
self.create_initial_capital(
428418
new_broker_account_value, are_you_really_sure=True
@@ -469,11 +459,13 @@ def adjust_broker_account_for_delta(self, delta_value: float):
469459
:return: None
470460
"""
471461

472-
prev_broker_account_value = self.capital_data.get_broker_account_value()
473-
if prev_broker_account_value is missing_data:
462+
try:
463+
prev_broker_account_value = self.capital_data.get_broker_account_value()
464+
except missingData:
474465
self._capital_data.log.warn(
475466
"Can't apply a delta to broker account value, since no value in data"
476467
)
468+
raise
477469

478470
broker_account_value = prev_broker_account_value + delta_value
479471

0 commit comments

Comments
 (0)