|
3 | 3 | import pandas as pd
|
4 | 4 |
|
5 | 5 | 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 |
7 | 7 | from syscore.pandas.pdutils import uniquets
|
8 | 8 |
|
9 | 9 | from sysdata.data_blob import dataBlob
|
@@ -82,10 +82,7 @@ def get_current_pandl_account(self) -> float:
|
82 | 82 | return self.get_current_capital_for_strategy(ACC_PROFIT_VALUES)
|
83 | 83 |
|
84 | 84 | 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) |
89 | 86 |
|
90 | 87 | capital_value = current_capital_entry.capital_value
|
91 | 88 |
|
@@ -352,14 +349,6 @@ def get_all_capital_calcs(self) -> pd.DataFrame:
|
352 | 349 | acc_pandl = self.get_profit_and_loss_account()
|
353 | 350 | broker_acc = self.get_broker_account()
|
354 | 351 |
|
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 |
| - |
363 | 352 | all_capital = pd.concat(
|
364 | 353 | [total_capital, max_capital, acc_pandl, broker_acc], axis=1
|
365 | 354 | )
|
@@ -421,8 +410,9 @@ def _init_capital_updater(
|
421 | 410 | def _get_prev_broker_account_value_create_if_no_data(
|
422 | 411 | self, new_broker_account_value: float
|
423 | 412 | ) -> 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: |
426 | 416 | # No previous capital, need to set everything up
|
427 | 417 | self.create_initial_capital(
|
428 | 418 | new_broker_account_value, are_you_really_sure=True
|
@@ -469,11 +459,13 @@ def adjust_broker_account_for_delta(self, delta_value: float):
|
469 | 459 | :return: None
|
470 | 460 | """
|
471 | 461 |
|
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: |
474 | 465 | self._capital_data.log.warn(
|
475 | 466 | "Can't apply a delta to broker account value, since no value in data"
|
476 | 467 | )
|
| 468 | + raise |
477 | 469 |
|
478 | 470 | broker_account_value = prev_broker_account_value + delta_value
|
479 | 471 |
|
|
0 commit comments