Ejemplo n.º 1
0
 def setUp(self):
     (rules, rawdata, data, config) = get_test_object_futures_with_rules()
     system = System([rawdata, rules, ForecastScaleCap()], data, config)
     self.system = system
     self.config = config
     self.rules = rules
     self.rawdata = rawdata
     self.forecast_scale_cap = ForecastScaleCap
     self.data = data
Ejemplo n.º 2
0
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(
            "pysystemtrade.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
Ejemplo n.º 3
0
def get_test_object_futures_with_rules_and_capping():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config(
        "pysystemtrade.systems.provided.example.exampleconfig.yaml")
    capobject = ForecastScaleCap()
    return (capobject, rules, rawdata, data, config)
Ejemplo n.º 4
0
def get_test_object_futures_with_pos_sizing():
    """
    Returns some standard test data
    """
    data = csvFuturesData("sysdata.tests")
    rawdata = FuturesRawData()
    rules = Rules()
    config = Config(
        "pysystemtrade.systems.provided.example.exampleconfig.yaml")
    capobject = ForecastScaleCap()
    combobject = ForecastCombine()
    posobject = PositionSizing()
    return (posobject, combobject, capobject, rules, rawdata, data, config)
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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(),
        Portfolios(),
        PositionSizing(),
        ForecastCombine(),
        ForecastScaleCap(),
        Rules()
    ], data, config)

    my_system.set_logging_level(log_level)

    return my_system