Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run_day_of_month_analysis(self, trading_model, resample_freq='B'):
from finmarketpy.economics.seasonality import Seasonality
logger = LoggerManager().getLogger(__name__)
calculations = Calculations()
seas = Seasonality()
trading_model.construct_strategy()
pnl = trading_model.strategy_pnl()
# get seasonality by day of the month
pnl = pnl.resample('B').mean()
rets = calculations.calculate_returns(pnl)
bus_day = seas.bus_day_of_month_seasonality(rets, add_average=True, resample_freq=resample_freq)
# get seasonality by month
pnl = pnl.resample('BM').mean()
rets = calculations.calculate_returns(pnl)
month = seas.monthly_seasonality(rets)
logger.info("About to plot seasonality...")
style = Style()