sysdata.configdata.Config

Here are the examples of the python api sysdata.configdata.Config taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

16 Examples 7

Example 1

Project: pysystemtrade
Source File: simplesystem.py
View license
def simplesystem(data=None, config=None, log_level="on"):
    """
    Example of how to 'wrap' a complete system
    """
    if config is None:
        config = Config("systems.provided.example.simplesystemconfig.yaml")
    if data is None:
        data = csvFuturesData()

    my_system = System([Account(), PortfoliosFixed(), PositionSizing(), ForecastCombineFixed(), ForecastScaleCapFixed(), Rules()
                        ], data, config)

    my_system.set_logging_level(log_level)

    return my_system

Example 2

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = RawData()
    config = Config("systems.provided.example.exampleconfig.yaml")
    return (rawdata, data, config)

Example 3

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    config = Config("systems.provided.example.exampleconfig.yaml")
    return (rawdata, data, config)

Example 4

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_rules():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.exampleconfig.yaml")
    return (rules, rawdata, data, config)

Example 5

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_rules_and_capping():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.exampleconfig.yaml")
    capobject = ForecastScaleCapFixed()
    return (capobject, rules, rawdata, data, config)

Example 6

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_comb_forecasts():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.exampleconfig.yaml")
    capobject = ForecastScaleCapFixed()
    combobject = ForecastCombineFixed()
    return (combobject, capobject, rules, rawdata, data, config)

Example 7

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_pos_sizing():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.exampleconfig.yaml")
    capobject = ForecastScaleCapFixed()
    combobject = ForecastCombineFixed()
    posobject = PositionSizing()
    return (posobject, combobject, capobject, rules, rawdata, data, config)

Example 8

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_portfolios():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.exampleconfig.yaml")
    capobject = ForecastScaleCapFixed()
    combobject = ForecastCombineFixed()
    posobject = PositionSizing()
    portfolio = PortfoliosFixed()
    return (portfolio, posobject, combobject,
            capobject, rules, rawdata, data, config)

Example 9

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_rules_and_capping_estimate():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.estimateexampleconfig.yaml")
    capobject = ForecastScaleCapEstimated()
    account = Account()
    return (account, capobject, rules, rawdata, data, config)

Example 10

Project: pysystemtrade
Source File: testdata.py
View license
def get_test_object_futures_with_pos_sizing_estimates():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config("systems.provided.example.estimateexampleconfig.yaml")
    capobject = ForecastScaleCapEstimated()
    combobject = ForecastCombineEstimated()
    posobject = PositionSizing()
    account = Account()
    return (account, posobject, combobject,
            capobject, rules, rawdata, data, config)

Example 11

Project: pysystemtrade
Source File: testfuturesrawdata.py
View license
def get_test_object():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = RawData()
    config = Config("systems.provided.example.exampleconfig.yaml")
    return (rawdata, data, config)

Example 12

Project: pysystemtrade
Source File: testfuturesrawdata.py
View license
def get_test_object_futures():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    config = Config("systems.provided.example.exampleconfig.yaml")
    return (data, config)

Example 13

Project: pysystemtrade
Source File: basesystem.py
View license
    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.Data (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.csvdata import csvFuturesData
        >>> data=csvFuturesData()
        >>> System([stage], data)
        System with stages: unnamed

        """

        if config is None:
            # Default - for very dull systems this is sufficient
            config = Config()

        config.fill_with_defaults()

        setattr(self, "data", data)
        setattr(self, "config", config)
        setattr(self, "log", log)

        setattr(data, "log", log.setup(stage="data"))
        setattr(config, "log", log.setup(stage="config"))

        protected = []
        nopickle = []
        stage_names = []

        assert isinstance(stage_list, list)

        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
            stage._system_init(self)

            # and a log
            log = log.setup(stage=sub_name)
            setattr(stage, "log", log)

            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)

            # list of attributes / methods of the stage which are protected
            stage_protected = getattr(stage, "_protected", [])
            stage_protected = [(sub_name, protected_item, "*")
                               for protected_item in stage_protected]
            protected += stage_protected

            stage_nopickle = getattr(stage, "_nopickle", [])
            stage_nopickle = [(sub_name, protected_item, "*")
                              for protected_item in stage_nopickle]
            nopickle += stage_nopickle

        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", dict())
        setattr(self, "_protected", protected)
        setattr(self, "_nopickle", nopickle)

Example 14

Project: pysystemtrade
Source File: basesystem.py
View license
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.Data, 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 = csvFuturesData()

    if config is None:
        config = Config(
            "systems.provided.futures_chapter15.futuresconfig.yaml")

    rules = Rules(trading_rules)

    system = System([Account(), PortfoliosFixed(), PositionSizing(), FuturesRawData(), ForecastCombine(),
                     ForecastScaleCap(), rules], data, config)

    system.set_logging_level(log_level)

    return system

Example 15

Project: pysystemtrade
Source File: estimatedsystem.py
View license
def futures_system(data=None, config=None,
                   trading_rules=None, log_level="terse"):
    """

    :param data: data object (defaults to reading from csv files)
    :type data: sysdata.data.Data, 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)
    :param trading_rules: list or dict of TradingRules, or something that can be parsed to that

    :param log_level: Set of trading rules to use (defaults to set specified in config object)
    :type log_level: str

    """

    if data is None:
        data = csvFuturesData()

    if config is None:
        config = Config(
            "systems.provided.futures_chapter15.futuresestimateconfig.yaml")

    rules = Rules(trading_rules)

    system = System([Account(), Portfolios(), PositionSizing(), FuturesRawData(), ForecastCombine(),
                     ForecastScaleCap(), rules], data, config)

    system.set_logging_level(log_level)

    return system

Example 16

Project: pysystemtrade
Source File: test_forecasts.py
View license
    def testRules(self):

        # config=Config(dict(trading_rules=dict(ewmac=dict(function="systems.provided.example.rules.ewmac_forecast_with_defaults"))))
        data = csvFuturesData("sysdata.tests")

        rules = Rules(
            dict(function="systems.provided.example.rules.ewmac_forecast_with_defaults"))
        system = System([rules], data)

        ans = system.rules.get_raw_forecast("EDOLLAR", "rule0")
        self.assertAlmostEqual(ans.iloc[-1][0], 2.1384223788141838, 5)

        config = Config(dict(trading_rules=dict(ewmac=dict(
            function="systems.provided.example.rules.ewmac_forecast_with_defaults"))))
        rules = Rules()
        system = System([rules], data, config)
        ans = system.rules.get_raw_forecast("EDOLLAR", "ewmac")
        self.assertAlmostEqual(ans.iloc[-1][0], 2.1384223788141838, 5)

        config = Config("systems.provided.example.exampleconfig.yaml")
        rawdata = RawData()

        rules = Rules()
        system = System([rules, rawdata], data, config)
        ans = system.rules.get_raw_forecast("EDOLLAR", "ewmac8")
        self.assertAlmostEqual(ans.iloc[-1][0], 0.16438313875, 5)