Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Minimal, self-contained CLI tools and library for quantitative finance.
## Modules

- **[estimators](src/quantlib_st/estimators/README.md)**: Volatility and Forecast Scalar estimators — contains `robust_vol_calc` and `mixed_vol_calc` for daily volatility estimation, and `forecast_scalar` for scaling forecasts.
- **[accounts](src/quantlib_st/accounts/README.md)**: P&L calculation framework — contains `account_forecast` for generating P&L curves from forecasts and prices.
- **[accounts](src/quantlib_st/systems/accounts/README.md)**: P&L calculation framework — contains `account_forecast` for generating P&L curves from forecasts and prices.

## Install (editable - for developers)

Expand Down
36 changes: 31 additions & 5 deletions src/quantlib_st/systems/accounts/account_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@
class accountForecast(accountCosts):
@diagnostic(not_pickable=True)
def pandl_for_instrument_forecast_weighted_within_trading_rule(
self, instrument_code: str, rule_variation_name: str, delayfill: bool = True
self,
instrument_code: str,
rule_variation_name: str,
delayfill: bool = True,
roundpositions: bool = False,
) -> accountCurve:
pandl_for_instrument_forecast = self.pandl_for_instrument_forecast(
instrument_code, rule_variation_name, delayfill=delayfill
instrument_code,
rule_variation_name,
delayfill=delayfill,
roundpositions=roundpositions,
)

weight = (
Expand All @@ -40,10 +47,17 @@ def pandl_for_instrument_forecast_weighted_within_trading_rule(

@diagnostic(not_pickable=True)
def pandl_for_instrument_forecast_weighted(
self, instrument_code: str, rule_variation_name: str, delayfill: bool = True
self,
instrument_code: str,
rule_variation_name: str,
delayfill: bool = True,
roundpositions: bool = False,
) -> accountCurve:
pandl_for_instrument_forecast = self.pandl_for_instrument_forecast(
instrument_code, rule_variation_name, delayfill=delayfill
instrument_code,
rule_variation_name,
delayfill=delayfill,
roundpositions=roundpositions,
)

weight = self._normalised_weight_for_forecast_and_instrument(
Expand Down Expand Up @@ -156,7 +170,11 @@ def _unnormalised_weight_for_forecast_and_instrument(

@diagnostic(not_pickable=True)
def pandl_for_instrument_forecast(
self, instrument_code: str, rule_variation_name: str, delayfill: bool = True
self,
instrument_code: str,
rule_variation_name: str,
delayfill: bool = True,
roundpositions: bool = False,
) -> accountCurve:
"""
Get the p&l for one instrument and forecast; as % of arbitrary capital
Expand All @@ -170,6 +188,9 @@ def pandl_for_instrument_forecast(
:param delayfill: Lag fills by one day
:type delayfill: bool

:param roundpositions: Round positions to nearest integer
:type roundpositions: bool

:returns: accountCurve

>>> from systems.basesystem import System
Expand Down Expand Up @@ -219,6 +240,7 @@ def pandl_for_instrument_forecast(
target_abs_forecast=target_abs_forecast,
SR_cost=SR_cost,
delayfill=delayfill,
roundpositions=roundpositions,
value_per_point=value_per_point,
)

Expand All @@ -235,6 +257,7 @@ def pandl_for_instrument_forecast(
target_abs_forecast: float = 10.0,
SR_cost=0.0,
delayfill=True,
roundpositions: bool = False,
value_per_point=ARBITRARY_VALUE_OF_PRICE_POINT,
) -> accountCurve:
if daily_returns_volatility is None:
Expand Down Expand Up @@ -263,6 +286,7 @@ def pandl_for_instrument_forecast(
capital=capital,
value_per_point=value_per_point,
delayfill=delayfill,
roundpositions=roundpositions,
price=price,
)

Expand All @@ -278,6 +302,7 @@ def pandl_for_position(
daily_returns_volatility: Optional[pd.Series] = None,
SR_cost=0.0,
delayfill=True,
roundpositions: bool = False,
value_per_point=ARBITRARY_VALUE_OF_PRICE_POINT,
) -> accountCurve:
pandl_calculator = pandlCalculationWithSRCosts(
Expand All @@ -290,6 +315,7 @@ def pandl_for_position(
capital=capital,
value_per_point=value_per_point,
delayfill=delayfill,
roundpositions=roundpositions,
)

return accountCurve(pandl_calculator)
Expand Down
Loading