del (config.instrument_weights) config.notional_trading_capital = 10000000 system.config.forecast_weights = dict([(rule, 1.0) for rule in rulename]) config.use_forecast_scale_estimates = True system.config.notional_trading_capital = 10000000 system = System([ Account(), Portfolios(), PositionSizing(), FuturesRawData(), ForecastCombine(), ForecastScaleCap(), Rules() ], csvFuturesData(), config) system.set_logging_level("on") a2 = system.accounts.portfolio() from syscore.accounting import account_test print("Filtered:") print(a1.stats()) print("") print("No filter") print(a2.stats()) print("Test") print(account_test(a1, a2)) a3 = pd.concat([a1.curve(), a2.curve()], axis=1) a3.columns = ["filter", "nofilter"] a3.plot() show()
# will do all instruments we have data for del (my_config.instruments) # temporarily remove breakout rules my_config.rule_variations = evariations my_config.forecast_weight_estimate["method"] = "equal_weights" system_old = futures_system(config=my_config, log_level="on") # new system has all trading rules new_config = Config("examples.breakout.breakoutfuturesestimateconfig.yaml") new_config.rule_variations = bvariations new_config.forecast_weight_estimate["method"] = "equal_weights" del (new_config.instruments) system_new = futures_system(config=new_config, log_level="on") curve1 = system_old.accounts.portfolio() curve2 = system_new.accounts.portfolio() print(curve1.stats()) print(curve2.stats()) print(account_test(curve2, curve1)) curves_to_plot = pd.concat([curve1.as_df(), curve2.as_df()], axis=1) curves_to_plot.columns = ["ewmac", "breakout"] print(curves_to_plot.corr()) curves_to_plot.cumsum().plot() show()
del(config.instrument_weights) config.notional_trading_capital = 10000000 config.use_instrument_weight_estimates = True config.use_forecast_weight_estimates = True config.forecast_weight_estimate = dict( pool_instruments=True, method="one_period") system = System([Account(), Portfolios(), PositionSizing(), FuturesRawData(), ForecastCombine(), ForecastScaleCap(), Rules()], csvFuturesData(), config) system.set_logging_level("on") a2 = system.accounts.portfolio() from syscore.accounting import account_test print("Fit by instrument out of sample:") print(a1.stats()) print("") print("Fit across instruments out of sample") print(a2.stats()) print("Test ") print(account_test(a1, a2)) a3 = pd.concat([a1.curve(), a2.curve()], axis=1) a3.columns = ["byinstr", "pooled"] a3.plot() show()