sysdata.csvdata.csvFuturesData

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

17 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: test_forecasts.py
View license
    def testCarryRule(self):
        data = csvFuturesData("sysdata.tests")

        rawdata = FuturesRawData()
        rules = Rules()
        system = System([rawdata, rules], data)
        rule = TradingRule(carry,
                           ["rawdata.daily_annualised_roll",
                            "rawdata.daily_returns_volatility"],
                           dict(smooth_days=90))
        ans = rule.call(system, "EDOLLAR")
        self.assertAlmostEqual(ans.iloc[-1][0], 0.411686026, 5)

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)

Example 17

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

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

        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.iloc[-1][0], 2.1384223788141838, 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.iloc[-1][0], 0.029376, 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.iloc[-1][0], 3.84426755)