Skip to content

Commit

Permalink
remove future warning properly speed up percentage calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Carver committed Dec 6, 2023
1 parent 30eab73 commit 7bf683a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sysquant/estimators/vol.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def apply_vol_floor(
floor_days: int = 500,
) -> pd.Series:
# Find the rolling 5% quantile point to set as a minimum
vol_min = vol.rolling(min_periods=floor_min_periods, window=floor_days).q(
quantile=floor_min_quant
vol_min = vol.rolling(min_periods=floor_min_periods, window=floor_days).quantile(
q=floor_min_quant
)

# set this to zero for the first value then propagate forward, ensures
Expand Down
5 changes: 4 additions & 1 deletion systems/accounts/pandl_calculators/pandl_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def percentage_pandl(self) -> pd.Series:

def _percentage_pandl_given_pandl(self, pandl_in_base: pd.Series):
capital = self.capital
capital_aligned = capital.reindex(pandl_in_base.index, method="ffill")
if type(capital) is pd.Series:
capital_aligned = capital.reindex(pandl_in_base.index, method="ffill")
elif type(capital) is float or type(capital) is int:
capital_aligned = capital

return 100.0 * pandl_in_base / capital_aligned

Expand Down

0 comments on commit 7bf683a

Please sign in to comment.