def pandl_for_instrument_forecast( forecast: pd.Series, price: pd.Series, daily_returns_volatility: pd.Series = arg_not_supplied, target_abs_forecast: float = 10.0, SR_cost=0.0, delayfill=True) -> accountCurve: if daily_returns_volatility is arg_not_supplied: daily_returns_volatility = robust_daily_vol_given_price(price) normalised_forecast = _get_normalised_forecast( forecast, target_abs_forecast=target_abs_forecast) average_notional_position = -_get_average_notional_position( daily_returns_volatility) notional_position = _get_notional_position_for_forecast( normalised_forecast, average_notional_position=average_notional_position) pandl_calculator = pandlCalculationWithSRCosts( price, SR_cost=SR_cost, positions=notional_position, daily_returns_volatility=daily_returns_volatility, average_position=average_notional_position, capital=ARBITRARY_FORECAST_CAPITAL, value_per_point=ARBITRARY_VALUE_OF_PRICE_POINT, delayfill=delayfill) account_curve = accountCurve(pandl_calculator) return account_curve
def _pandl_for_instrument_with_SR_costs( self, instrument_code: str, delayfill: bool = True, roundpositions: bool = True) -> accountCurve: price = self.get_daily_price(instrument_code) positions = self.get_buffered_position(instrument_code, roundpositions=roundpositions) fx = self.get_fx_rate(instrument_code) value_of_price_point = self.get_value_of_block_price_move( instrument_code) daily_returns_volatility = self.get_daily_returns_volatility( instrument_code) capital = self.get_notional_capital() SR_cost_per_trade = self.get_SR_cost_per_trade_for_instrument( instrument_code) instrument_turnover = self.instrument_turnover( instrument_code, roundpositions=roundpositions) annualised_SR_cost = SR_cost_per_trade * instrument_turnover average_position = self.get_average_position_for_instrument_at_portfolio_level( instrument_code) pandl_calculator = pandlCalculationWithSRCosts( price, SR_cost=annualised_SR_cost, positions=positions, average_position=average_position, daily_returns_volatility=daily_returns_volatility, capital=capital, value_per_point=value_of_price_point, delayfill=delayfill, fx=fx, roundpositions=roundpositions) account_curve = accountCurve(pandl_calculator, weighted=True) return account_curve
def _pandl_for_subsystem_with_SR_costs( self, instrument_code, delayfill=True, roundpositions=False) -> accountCurve: price = self.get_daily_price(instrument_code) positions = self.get_subsystem_position(instrument_code) fx = self.get_fx_rate(instrument_code) value_of_price_point = self.get_value_of_block_price_move( instrument_code) daily_returns_volatility = self.get_daily_returns_volatility( instrument_code) average_position = self.get_volatility_scalar(instrument_code) SR_cost_per_trade = self.get_SR_cost_per_trade_for_instrument( instrument_code) subsystem_turnover = self.subsystem_turnover(instrument_code) annualised_SR_cost = SR_cost_per_trade * subsystem_turnover capital = self.get_notional_capital() pandl_calculator = pandlCalculationWithSRCosts( price, SR_cost=annualised_SR_cost, positions=positions, average_position=average_position, daily_returns_volatility=daily_returns_volatility, capital=capital, value_per_point=value_of_price_point, delayfill=delayfill, fx=fx, roundpositions=roundpositions) account_curve = accountCurve(pandl_calculator) return account_curve