Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
spot_df2 : pandas.DataFrame
Secondary Market time series for generated signals (can be of different frequency)
tech_params : TechParams
Parameters for generating signals
contract_value_df : pandas.DataFrame
Dataframe with the contract sizes for each asset
Returns
-------
portfolio_cum : pandas.DataFrame
backtest : Backtest
"""
backtest = Backtest()
logger = LoggerManager().getLogger(__name__)
logger.info("Calculating trading signals for " + key + "...")
signal = self.construct_signal(spot_df, spot_df2, tech_params, br, run_in_parallel=run_in_parallel)
logger.info("Calculated trading signals for " + key)
backtest.calculate_trading_PnL(br, asset_df, signal,
contract_value_df,
run_in_parallel) # calculate P&L (and adjust signals for vol etc)
if br.write_csv: backtest.pnl_cum().to_csv(self.DUMP_CSV + key + ".csv")
if br.calc_stats: