def __init__( self, stage_list: list, data: simData, config: Config = arg_not_supplied, log: logger = logtoscreen("base_system"), ): """ Create a system object for doing simulations or live trading :param stage_list: A list of stages :type stage_list: list of systems.stage.SystemStage (or anything that inherits from it) :param data: data for doing simulations :type data: sysdata.data.simData (or anything that inherits from that) :param config: Optional configuration :type config: sysdata.configdata.Config :returns: new system object >>> from systems.stage import SystemStage >>> stage=SystemStage() >>> from sysdata.sim.csv_futures_sim_data import csvFuturesSimData >>> data=csvFuturesSimData() >>> System([stage], data) System base_system with .config, .data, and .stages: Need to replace method when inheriting """ if config is arg_not_supplied: # Default - for very dull systems this is sufficient config = Config() self._data = data self._config = config self._log = log self.config.system_init(self) self.data.system_init(self) self._setup_stages(stage_list) self._cache = systemCache(self)
def __init__(self, stage_list, data, config=None, log=logtoscreen("base_system")): """ Create a system object for doing simulations or live trading :param stage_list: A list of stages :type stage_list: list of systems.stage.SystemStage (or anything that inherits from it) :param data: data for doing simulations :type data: sysdata.data.simData (or anything that inherits from that) :param config: Optional configuration :type config: sysdata.configdata.Config :returns: new system object >>> from systems.stage import SystemStage >>> stage=SystemStage() >>> from sysdata.sim.csv_futures_sim_data import csvFuturesSimData >>> data=csvFuturesSimData() >>> System([stage], data) System base_system with .config, .data, and .stages: unnamed """ if config is None: # Default - for very dull systems this is sufficient config = Config() setattr(self, "data", data) setattr(self, "config", config) self._log = log self.config._system_init(self) self.data._system_init(self) stage_names = [] try: iter(stage_list) except AssertionError: raise Exception( "You didn't pass a list into this System instance; even just one stage should be System([stage_instance])" ) for stage in stage_list: """ This is where we put the methods to store various stages of the process """ # Stages have names, which are also how we find them in the system # attributes sub_name = stage.name # Each stage has a link back to the parent system # This init sets this, and also passes the system logging object stage._system_init(self) if sub_name in stage_names: raise Exception( "You have duplicate subsystems with the name %s. Remove " "one of them, or change a name." % sub_name) setattr(self, sub_name, stage) stage_names.append(sub_name) setattr(self, "_stage_names", stage_names) """ The cache hides all intermediate results We call optimal_positions and then that propogates back finding all the data we need The results are then cached in the object. Should we call delete_instrument_data (in base class system) then everything related to a particular instrument is removed from these 'nodes' except for protected items This is very useful in live trading when we don't want to update eg cross sectional data every sample """ setattr(self, "cache", systemCache(self)) self.name = "base_system" # makes caching work and for general consistency
def __init__(self, stage_list, data, config=None, log=logtoscreen("base_system")): """ Create a system object for doing simulations or live trading :param stage_list: A list of stages :type stage_list: list of systems.stage.SystemStage (or anything that inherits from it) :param data: data for doing simulations :type data: sysdata.data.simData (or anything that inherits from that) :param config: Optional configuration :type config: sysdata.configdata.Config :returns: new system object >>> from systems.stage import SystemStage >>> stage=SystemStage() >>> from sysdata.csv.csv_sim_futures_data import csvFuturesSimData >>> data=csvFuturesSimData() >>> System([stage], data) System base_system with .config, .data, and .stages: unnamed """ if config is None: # Default - for very dull systems this is sufficient config = Config() setattr(self, "data", data) setattr(self, "config", config) setattr(self, "log", log) self.config._system_init(self) self.data._system_init(self) stage_names = [] try: iter(stage_list) except AssertionError: raise Exception( "You didn't pass a list into this System instance; even just one stage should be System([stage_instance])" ) for stage in stage_list: """ This is where we put the methods to store various stages of the process """ # Stages have names, which are also how we find them in the system # attributes sub_name = stage.name # Each stage has a link back to the parent system # This init sets this, and also passes the system logging object stage._system_init(self) if sub_name in stage_names: raise Exception( "You have duplicate subsystems with the name %s. Remove " "one of them, or change a name." % sub_name) setattr(self, sub_name, stage) stage_names.append(sub_name) setattr(self, "_stage_names", stage_names) """ The cache hides all intermediate results We call optimal_positions and then that propogates back finding all the data we need The results are then cached in the object. Should we call delete_instrument_data (in base class system) then everything related to a particular instrument is removed from these 'nodes' except for protected items This is very useful in live trading when we don't want to update eg cross sectional data every sample """ setattr(self, "cache", systemCache(self)) self.name = "base_system" # makes caching work and for general consistency