def test_estimated_dm(self): config = copy.copy(self.config) config.use_instrument_weight_estimates = True system2 = System( [ self.rawdata, self.rules, self.possizing, self.forecast_combine, self.fcs, Account(), self.portfolios(), ], self.data, config, ) ans = system2.portfolio.get_instrument_correlation_matrix().corr_list[-1] self.assertAlmostEqual(ans[0][1], 0.3889, places=3) self.assertAlmostEqual(ans[0][2], 0.5014, places=3) self.assertAlmostEqual(ans[1][2], 0.8771, places=3) ans = system2.portfolio.get_estimated_instrument_diversification_multiplier() self.assertAlmostEqual(ans.values[-1], 1.1855, places=3)
def test_simple_system_config_object(self, data, ewmac_8, ewmac_32): my_config = Config( dict( trading_rules=dict(ewmac8=ewmac_8, ewmac32=ewmac_32), instrument_weights=dict(US10=0.1, EDOLLAR=0.4, CORN=0.3, SP500=0.2), instrument_div_multiplier=1.5, forecast_scalars=dict(ewmac8=5.3, ewmac32=2.65), forecast_weights=dict(ewmac8=0.5, ewmac32=0.5), forecast_div_multiplier=1.1, percentage_vol_target=25.00, notional_trading_capital=500000, base_currency="GBP", risk_overlay=arg_not_supplied, exclude_instrument_lists=dict( ignore_instruments=["MILK"], trading_restrictions=["BUTTER"], bad_markets=["CHEESE"], ), ) ) print(my_config) my_system = System( [ Account(), Portfolios(), PositionSizing(), ForecastCombine(), ForecastScaleCap(), Rules(), RawData(), ], data, my_config, ) print(my_system.portfolio.get_notional_position("EDOLLAR").tail(5))
def testCallingTradingRule(self): # config=Config(dict(trading_rules=dict(ewmac=dict(function="systems.provided.example.rules.ewmac_forecast_with_defaults")))) NOTUSEDrawdata, data, NOTUSEDconfig = get_test_object() rawdata = RawData() rules = Rules() system = System([rawdata, rules], data) # Call with default data and config rule = TradingRule(ewmac_forecast_with_defaults) ans = rule.call(system, "EDOLLAR") self.assertAlmostEqual(ans.tail(1).values[0], -3.280028, 5) # Change the data source rule = TradingRule(( "systems.provided.example.rules.ewmac_forecast_with_defaults_no_vol", ["rawdata.get_daily_prices", "rawdata.daily_returns_volatility"], dict(), )) ans = rule.call(system, "EDOLLAR") self.assertAlmostEqual(ans.tail(1).values[0], -1.24349, 5) rule = TradingRule( dict( function= "systems.provided.example.rules.ewmac_forecast_with_defaults_no_vol", data=[ "rawdata.get_daily_prices", "rawdata.daily_returns_volatility" ], other_args=dict(Lfast=50, Lslow=200), )) ans = rule.call(system, "EDOLLAR") self.assertAlmostEqual(ans.tail(1).values[0], -3.025001057146)
def setUp(self): (rawdata, data, config) = get_test_object() system = System([rawdata], data) self.system = system
from systems.forecasting import Rules from systems.forecasting import TradingRule from systems.portfolio import PortfoliosEstimated from systems.positionsizing import PositionSizing data = csvFuturesData() my_config = Config() my_config.instruments = ["US20", "SP500"] ewmac_8 = TradingRule((ewmac, [], dict(Lfast=8, Lslow=32))) ewmac_32 = TradingRule( dict(function=ewmac, other_args=dict(Lfast=32, Lslow=128))) my_rules = Rules(dict(ewmac8=ewmac_8, ewmac32=ewmac_32)) my_system = System([ Account(), PortfoliosEstimated(), PositionSizing(), ForecastScaleCap(), my_rules, ForecastCombine() ], data, my_config) my_system.config.forecast_weight_estimate['method'] = "equal_weights" my_system.config.instrument_weight_estimate['method'] = "bootstrap" my_system.config.instrument_weight_estimate["monte_runs"] = 1 my_system.config.instrument_weight_estimate["bootstrap_length"] = 250 print(my_system.portfolio.get_instrument_weights()) print(my_system.portfolio.get_instrument_diversification_multiplier()) # 10,250 weights=0.75,0.25 idm=1.26 # 30,250 weights=0.75,0.25
def testName(self): stage = SystemStage() stage.name = "test" data=Data() stage._protected = ["protected"] system = System([stage], data, None) print(system._cache) system.set_item_in_cache(3, ("test","a"), "US10") print(system._cache) self.assertEqual(system.get_item_from_cache(("test","a"), "US10"), 3) def afunction(system, instrument_code, stage, wibble, another_wibble=10): return instrument_code + wibble + str(another_wibble) + stage.name def anestedfunction(system, instrument_code, keyname, stage, wibble, another_wibble=10): return instrument_code + wibble + keyname + str(another_wibble) + stage.name ans = system.calc_or_cache("b", "c", afunction, stage, "d") print(system._cache) ans = system.calc_or_cache("b", "c", afunction, stage, "d", 20.0) print(system._cache) ans = system.calc_or_cache_nested( "c", "SP500", "thing", anestedfunction, stage, "k") print(system._cache) ans = system.calc_or_cache("b", ALL_KEYNAME, afunction, stage, "e", 120.0) print(system._cache) ans = system.calc_or_cache( "protected", ALL_KEYNAME, afunction, stage, "e", 120.0) ans = system.get_item_from_cache(("test""c"), "SP500", "thing") print(system._cache) system._delete_item_from_cache(("test","b"), "c") print(system._cache) ans = system.set_item_in_cache(10.0, ("test", "protected"), "SP500") print(system._cache) print(system.get_item_from_cache(("test","b"), ALL_KEYNAME)) ans = system.set_item_in_cache( "protected", ("test2",10.0), "SP500") print(system._cache) print(system.get_items_across_system()) print(system.get_items_with_data()) print(system.get_protected_items()) print(system.get_items_for_instrument("SP500")) print(system.get_itemnames_for_stage("test")) system.delete_items_for_stage("test2") print(system._cache) system.delete_items_across_system() print(system._cache) system.delete_items_across_system(True) print(system._cache) system.delete_items_for_instrument("SP500") print(system._cache) system.delete_items_for_instrument("SP500", True) print(system._cache) system.delete_item(("test","a")) print(system._cache)
""" from systems.forecasting import Rules """ We can create rules in a number of different ways Note that to make our rule work it needs to have """ my_rules = Rules(ewmac) print(my_rules.trading_rules()) my_rules = Rules(dict(ewmac=ewmac)) print(my_rules.trading_rules()) from systems.basesystem import System my_system = System([my_rules], data) print(my_system) print(my_system.rules.get_raw_forecast("EDOLLAR", "ewmac").tail(5)) """ Define a TradingRule """ from systems.forecasting import TradingRule ewmac_rule = TradingRule(ewmac) my_rules = Rules(dict(ewmac=ewmac_rule)) ewmac_rule """ ... or two... """
from systems.account import Account from systems.forecast_combine import ForecastCombine from systems.forecast_scale_cap import ForecastScaleCap from systems.basesystem import System from sysdata.csvdata import csvFuturesData from systems.forecasting import Rules from systems.forecasting import TradingRule data = csvFuturesData() my_config = Config() ewmac_8 = TradingRule((ewmac, [], dict(Lfast=8, Lslow=32))) ewmac_32 = TradingRule(dict(function=ewmac, other_args=dict(Lfast=32, Lslow=128))) my_rules = Rules(dict(ewmac8=ewmac_8, ewmac32=ewmac_32)) my_config.trading_rules = dict(ewmac8=ewmac_8, ewmac32=ewmac_32) #my_config.instruments=[ "US20", "NASDAQ", "SP500"] my_config.instruments=[ "SP500"] my_config.forecast_weight_estimate=dict(method="bootstrap") my_config.forecast_weight_estimate['monte_runs']=50 my_config.use_forecast_weight_estimates=True my_system = System([Account(), ForecastScaleCap(), my_rules, ForecastCombine()], data, my_config) logging.debug(my_system.combForecast.get_forecast_weights("SP500").tail(5)) # DEBUG:root: ewmac32 ewmac8 # 2015-12-07 0.632792 0.367208 # 2015-12-08 0.632930 0.367070 # 2015-12-09 0.633066 0.366934 # 2015-12-10 0.633201 0.366799 # 2015-12-11 0.633335 0.366665
def test_get_returns_for_optimisation(self): # Note: More thorough tests will be run inside optimisation module # (FIXME next refactoring) At this point we don't run proper tests but # just check all the plumbing works with new caching code # FIXME rewrite proper tests once refactored optimisation generally system = self.setUpWithEstimatedReturns() print( system.combForecast.get_SR_cost_for_instrument_forecast( "EDOLLAR", "ewmac8")) print( system.combForecast.get_SR_cost_for_instrument_forecast( "BUND", "ewmac8")) print( system.combForecast.get_SR_cost_for_instrument_forecast( "US10", "ewmac8")) print(system.combForecast.has_same_cheap_rules_as_code("EDOLLAR")) print(system.combForecast.has_same_cheap_rules_as_code("BUND")) print(system.combForecast.has_same_cheap_rules_as_code("US10")) print( system.combForecast.get_returns_for_optimisation( "EDOLLAR").to_frame()) print( system.combForecast.get_returns_for_optimisation( "BUND").to_frame()) print( system.combForecast.get_returns_for_optimisation( "US10").to_frame()) print(system.combForecast.has_same_cheap_rules_as_code("EDOLLAR")) print(system.combForecast.has_same_cheap_rules_as_code("BUND")) print(system.combForecast.has_same_cheap_rules_as_code("US10")) # default - don't pool costs, pool gross print(system.combForecast.get_raw_forecast_weights("BUND")) # pool neithier gross or costs config = copy.copy(system.config) config.forecast_weight_estimate['pool_gross_returns'] = False config.forecast_weight_estimate['forecast_cost_estimates'] = False system2 = System([ self.rawdata, self.rules, self.fcs, self.forecast_combine(), Account() ], self.data, config) print(system2.combForecast.get_raw_forecast_weights("BUND")) # pool gross, not costs config = copy.copy(system.config) config.forecast_weight_estimate['pool_gross_returns'] = True config.forecast_weight_estimate['forecast_cost_estimates'] = False system2 = System([ self.rawdata, self.rules, self.fcs, self.forecast_combine(), Account() ], self.data, config) print(system2.combForecast.get_raw_forecast_weights("BUND")) # pool both (special function) config = copy.copy(system.config) config.forecast_weight_estimate['pool_gross_returns'] = True config.forecast_weight_estimate['forecast_cost_estimates'] = True system2 = System([ self.rawdata, self.rules, self.fcs, self.forecast_combine(), Account() ], self.data, config) print(system2.combForecast.get_raw_forecast_weights("BUND"))
from systems.provided.example.rules import ewmac_forecast_with_defaults as ewmac from systems.forecasting import Rules from systems.provided.futures_chapter15.basesystem import futures_system """ to make our rule work it needs to have: """ my_rules = Rules(ewmac) print("\n", my_rules.trading_rules(), end=space) my_rules = Rules(dict(ewmac=ewmac)) print("\n", my_rules.trading_rules(), end=space) from systems.basesystem import System my_system = System([my_rules], data) print("\n", my_system, end=space) df = my_system.rules.get_raw_forecast("EDOLLAR", "ewmac").tail(5) message = "\nmy_system.rules.get_raw_forecast('EDOLLAR', 'ewmac')"\ "\nreturns a Pandas DataFrame with the forecast of each day\n"\ "Example:"\ "\n{}\n" print(message.format(df), end=space) """ Define a TradingRule """ from systems.forecasting import TradingRule
def test_simple_system(self): """ This is (mostly) the code from 'examples.introduction.simplesystem', but without graph plotting """ data = csvFuturesSimData() my_rules = Rules(ewmac) print(my_rules.trading_rules()) my_rules = Rules(dict(ewmac=ewmac)) print(my_rules.trading_rules()) my_system = System([my_rules], data) print(my_system) print(my_system.rules.get_raw_forecast("EDOLLAR", "ewmac").tail(5)) ewmac_rule = TradingRule(ewmac) my_rules = Rules(dict(ewmac=ewmac_rule)) print(ewmac_rule) ewmac_8 = TradingRule((ewmac, [], dict(Lfast=8, Lslow=32))) ewmac_32 = TradingRule( dict(function=ewmac, other_args=dict(Lfast=32, Lslow=128))) my_rules = Rules(dict(ewmac8=ewmac_8, ewmac32=ewmac_32)) print(my_rules.trading_rules()["ewmac32"]) my_system = System([my_rules], data) my_system.rules.get_raw_forecast("EDOLLAR", "ewmac32").tail(5) my_config = Config() print(my_config) empty_rules = Rules() my_config.trading_rules = dict(ewmac8=ewmac_8, ewmac32=ewmac_32) my_system = System([empty_rules], data, my_config) my_system.rules.get_raw_forecast("EDOLLAR", "ewmac32").tail(5) # we can estimate these ourselves my_config.instruments = ["US10", "EDOLLAR", "CORN", "SP500"] my_config.use_forecast_scale_estimates = True fcs = ForecastScaleCap() my_system = System([fcs, my_rules], data, my_config) my_config.forecast_scalar_estimate["pool_instruments"] = False print( my_system.forecastScaleCap.get_forecast_scalar( "EDOLLAR", "ewmac32").tail(5)) # or we can use the values from the book my_config.forecast_scalars = dict(ewmac8=5.3, ewmac32=2.65) my_config.use_forecast_scale_estimates = False fcs = ForecastScaleCap() my_system = System([fcs, my_rules], data, my_config) print( my_system.forecastScaleCap.get_capped_forecast( "EDOLLAR", "ewmac32").tail(5)) # defaults combiner = ForecastCombine() my_system = System([fcs, my_rules, combiner], data, my_config) print(my_system.combForecast.get_forecast_weights("EDOLLAR").tail(5)) print( my_system.combForecast.get_forecast_diversification_multiplier( "EDOLLAR").tail(5)) # estimates: my_account = Account() combiner = ForecastCombine() my_config.forecast_weight_estimate = dict(method="one_period") my_config.use_forecast_weight_estimates = True my_config.use_forecast_div_mult_estimates = True my_system = System([my_account, fcs, my_rules, combiner], data, my_config) # this is a bit slow, better to know what's going on my_system.set_logging_level("on") print(my_system.combForecast.get_forecast_weights("US10").tail(5)) print( my_system.combForecast.get_forecast_diversification_multiplier( "US10").tail(5)) # fixed: my_config.forecast_weights = dict(ewmac8=0.5, ewmac32=0.5) my_config.forecast_div_multiplier = 1.1 my_config.use_forecast_weight_estimates = False my_config.use_forecast_div_mult_estimates = False combiner = ForecastCombine() my_system = System( [fcs, empty_rules, combiner], data, my_config) # no need for accounts if no estimation done my_system.combForecast.get_combined_forecast("EDOLLAR").tail(5) # size positions possizer = PositionSizing() my_config.percentage_vol_target = 25 my_config.notional_trading_capital = 500000 my_config.base_currency = "GBP" my_system = System([fcs, my_rules, combiner, possizer], data, my_config) print(my_system.positionSize.get_price_volatility("EDOLLAR").tail(5)) print(my_system.positionSize.get_block_value("EDOLLAR").tail(5)) print(my_system.positionSize.get_underlying_price("EDOLLAR")) print( my_system.positionSize.get_instrument_value_vol("EDOLLAR").tail(5)) print(my_system.positionSize.get_volatility_scalar("EDOLLAR").tail(5)) print(my_system.positionSize.get_vol_target_dict()) print(my_system.positionSize.get_subsystem_position("EDOLLAR").tail(5)) # portfolio - estimated portfolio = Portfolios() my_config.use_instrument_weight_estimates = True my_config.use_instrument_div_mult_estimates = True my_config.instrument_weight_estimate = dict(method="shrinkage", date_method="in_sample") my_system = System( [my_account, fcs, my_rules, combiner, possizer, portfolio], data, my_config) my_system.set_logging_level("on") print(my_system.portfolio.get_instrument_weights().tail(5)) print(my_system.portfolio.get_instrument_diversification_multiplier(). tail(5)) # or fixed portfolio = Portfolios() my_config.use_instrument_weight_estimates = False my_config.use_instrument_div_mult_estimates = False my_config.instrument_weights = dict(US10=0.1, EDOLLAR=0.4, CORN=0.3, SP500=0.2) my_config.instrument_div_multiplier = 1.5 my_system = System([fcs, my_rules, combiner, possizer, portfolio], data, my_config) print(my_system.portfolio.get_notional_position("EDOLLAR").tail(5)) my_system = System( [fcs, my_rules, combiner, possizer, portfolio, my_account], data, my_config) profits = my_system.accounts.portfolio() print(profits.percent().stats()) # have costs data now print(profits.gross.percent().stats()) print(profits.net.percent().stats()) my_config = Config( dict(trading_rules=dict(ewmac8=ewmac_8, ewmac32=ewmac_32), instrument_weights=dict(US10=0.1, EDOLLAR=0.4, CORN=0.3, SP500=0.2), instrument_div_multiplier=1.5, forecast_scalars=dict(ewmac8=5.3, ewmac32=2.65), forecast_weights=dict(ewmac8=0.5, ewmac32=0.5), forecast_div_multiplier=1.1, percentage_vol_target=25.00, notional_trading_capital=500000, base_currency="GBP")) print(my_config) my_system = System( [ Account(), Portfolios(), PositionSizing(), ForecastCombine(), ForecastScaleCap(), Rules() ], data, my_config, ) print(my_system.portfolio.get_notional_position("EDOLLAR").tail(5)) my_config = Config("systems.provided.example.simplesystemconfig.yaml") print(my_config) my_system = System( [ Account(), Portfolios(), PositionSizing(), ForecastCombine(), ForecastScaleCap(), Rules() ], data, my_config, ) print(my_system.rules.get_raw_forecast("EDOLLAR", "ewmac32").tail(5)) print(my_system.rules.get_raw_forecast("EDOLLAR", "ewmac8").tail(5)) print( my_system.forecastScaleCap.get_capped_forecast( "EDOLLAR", "ewmac32").tail(5)) print( my_system.forecastScaleCap.get_forecast_scalar( "EDOLLAR", "ewmac32")) print(my_system.combForecast.get_combined_forecast("EDOLLAR").tail(5)) print(my_system.combForecast.get_forecast_weights("EDOLLAR").tail(5)) print(my_system.positionSize.get_subsystem_position("EDOLLAR").tail(5)) print(my_system.portfolio.get_notional_position("EDOLLAR").tail(5))
def setUp(self): system = System([testStage1(), testStage2()], Data(), Config(dict(instruments=["code", "another_code"]))) self.system = system
import inspect import sys; sys.path.append('../..') import numpy as np from systems.basesystem import System from systems.forecast_combine import ForecastCombineEstimated from sysdata.csvdata import csvFuturesData from systems.futures.rawdata import FuturesRawData from systems.forecasting import Rules from sysdata.configdata import Config from systems.forecast_scale_cap import ForecastScaleCapFixed, ForecastScaleCapEstimated from systems.account import Account data = csvFuturesData("sysdata.tests") rawdata = FuturesRawData() rules = Rules() config = Config("examples.test14.yaml") fcs = ForecastScaleCapEstimated() accounts=Account() from systems.portfolio import PortfoliosEstimated from systems.positionsizing import PositionSizing system=System([accounts, rawdata, rules, fcs, ForecastCombineEstimated(), PositionSizing(), PortfoliosEstimated()], data, config) print (system.portfolio.get_instrument_correlation_matrix().corr_list) #array([[ 1. , 0.87041785], # [ 0.87041785, 1. ]])
from systems.forecasting import Rules from systems.forecasting import TradingRule data = csvFuturesData() ewmac_8 = TradingRule((ewmac, [], dict(Lfast=8, Lslow=32))) ewmac_32 = TradingRule(dict(function=ewmac, other_args=dict(Lfast=32, Lslow=128))) my_rules = Rules(dict(ewmac8=ewmac_8, ewmac32=ewmac_32)) my_config = Config() my_config my_config.trading_rules = dict(ewmac8=ewmac_8, ewmac32=ewmac_32) ## we can estimate these ourselves #my_config.instruments=[ "US20", "NASDAQ", "SP500"] my_config.instruments=[ "SP500"] #my_config.forecast_weight_estimate=dict(method="one_period") my_config.forecast_weight_estimate=dict(method="bootstrap") my_config.forecast_weight_estimate['monte_runs']=50 my_config.use_forecast_weight_estimates=True my_account = Account() combiner = ForecastCombine() fcs=ForecastScaleCap() my_system = System([my_account, fcs, my_rules, combiner], data, my_config) print(my_system.combForecast.get_forecast_weights("SP500").tail(5)) print('forecast_diversification_multiplier') print(my_system.combForecast.get_forecast_diversification_multiplier("SP500").tail(5))
def setUp(self): (accounts, fcs, rules, rawdata, data, config)=get_test_object_futures_with_rules_and_capping_estimate() system=System([accounts, rawdata, rules, fcs, ForecastCombineEstimated()], data, config) setattr(self, "system", system)
def futures_system(data=None, config=None, trading_rules=None, log_level="on"): """ :param data: data object (defaults to reading from csv files) :type data: sysdata.data.simData, or anything that inherits from it :param config: Configuration object (defaults to futuresconfig.yaml in this directory) :type config: sysdata.configdata.Config :param trading_rules: Set of trading rules to use (defaults to set specified in config object) :type trading_rules: list or dict of TradingRules, or something that can be parsed to that :param log_level: How much logging to do :type log_level: str >>> system=futures_system(log_level="off") >>> system System with stages: accounts, portfolio, positionSize, rawdata, combForecast, forecastScaleCap, rules >>> system.rules.get_raw_forecast("EDOLLAR", "ewmac2_8").dropna().head(2) ewmac2_8 1983-10-10 0.695929 1983-10-11 -0.604704 ewmac2_8 2015-04-21 0.172416 2015-04-22 -0.477559 >>> system.rules.get_raw_forecast("EDOLLAR", "carry").dropna().head(2) carry 1983-10-10 0.952297 1983-10-11 0.854075 carry 2015-04-21 0.350892 2015-04-22 0.350892 """ if data is None: data = csvFuturesSimData() if config is None: config = Config( "systems.provided.futures_chapter15.futuresconfig.yaml") rules = Rules(trading_rules) system = System( [ Account(), Portfolios(), PositionSizing(), FuturesRawData(), ForecastCombine(), ForecastScaleCap(), rules, ], data, config, ) system.set_logging_level(log_level) return system
""" from systems.forecasting import Rules """ We can create rules in a number of different ways Note that to make our rule work it needs to have """ my_rules = Rules(ewmac) print(my_rules.trading_rules()) my_rules = Rules(dict(ewmac=ewmac)) print(my_rules.trading_rules()) from systems.basesystem import System my_system = System([my_rules], data) print(my_system) print(my_system.rules.get_raw_forecast("EDOLLAR", "ewmac").tail(5)) """ Define a TradingRule """ from systems.forecasting import TradingRule ewmac_rule = TradingRule(ewmac) my_rules = Rules(dict(ewmac=ewmac_rule)) ewmac_rule """ ... or two... """
def test_get_trading_rule_list(self): # fixed weights ans = self.system.combForecast.get_trading_rule_list("EDOLLAR") self.assertEqual(ans, ["ewmac16", "ewmac8"]) ans2 = self.system.combForecast.get_trading_rule_list("BUND") self.assertEqual(ans2, ["ewmac8"]) # fixed weights - non nested dict config = copy.copy(self.config) config.forecast_weights = dict(ewmac8=0.5, ewmac16=0.5) system2 = System( [self.rawdata, self.rules, self.fcs, self.forecast_combine()], self.data, config, ) ans3 = system2.combForecast.get_trading_rule_list("EDOLLAR") self.assertEqual(ans3, ["ewmac16", "ewmac8"]) ans4 = system2.combForecast.get_trading_rule_list("BUND") self.assertEqual(ans4, ans3) # fixed weights - missing del config.forecast_weights system3 = System( [self.rawdata, self.rules, self.fcs, self.forecast_combine()], self.data, config, ) ans5 = system3.combForecast.get_trading_rule_list("EDOLLAR") self.assertEqual(ans5, ["ewmac16", "ewmac8"]) # estimated weights - missing config.use_forecast_weight_estimates = True system4 = System( [self.rawdata, self.rules, self.fcs, self.forecast_combine()], self.data, config, ) ans6 = system4.combForecast.get_trading_rule_list("EDOLLAR") self.assertEqual(ans6, ["ewmac16", "ewmac8"]) # estimated weights - non nested setattr(config, "rule_variations", ["ewmac8"]) system5 = System( [self.rawdata, self.rules, self.fcs, self.forecast_combine()], self.data, config, ) ans6 = system5.combForecast.get_trading_rule_list("EDOLLAR") self.assertEqual(ans6, ["ewmac8"]) # estimated weights - nested dict setattr( config, "rule_variations", dict( EDOLLAR=["ewmac8"], BUND=["ewmac16"], US10=[ "ewmac8", "ewmac16"]), ) system6 = System( [self.rawdata, self.rules, self.fcs, self.forecast_combine()], self.data, config, ) ans7 = system6.combForecast.get_trading_rule_list("EDOLLAR") self.assertEqual(ans7, ["ewmac8"]) ans8 = system6.combForecast.get_trading_rule_list("BUND") self.assertEqual(ans8, ["ewmac16"]) ans8 = system6.combForecast.get_trading_rule_list("US10") self.assertEqual(ans8, ["ewmac16", "ewmac8"]) # missing