forked from robcarver17/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathestimatedsystem.py
71 lines (52 loc) · 1.93 KB
/
estimatedsystem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
This is a variation of the chapter 15 system which estimates rather than uses
fixed parameters
A system consists of a system, plus a config
"""
from syscore.constants import arg_not_supplied
from sysdata.sim.csv_futures_sim_data import csvFuturesSimData
from sysdata.config.configdata import Config
from systems.forecasting import Rules
from systems.basesystem import System
from systems.forecast_combine import ForecastCombine
from systems.forecast_scale_cap import ForecastScaleCap
from systems.rawdata import RawData
from systems.positionsizing import PositionSizing
from systems.portfolio import Portfolios
from systems.accounts.accounts_stage import Account
def futures_system(
data=None, config=None, trading_rules=arg_not_supplied, 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)
: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 = csvFuturesSimData()
if config is None:
config = Config("systems.provided.futures_chapter15.futuresestimateconfig.yaml")
rules = Rules(trading_rules)
system = System(
[
Account(),
Portfolios(),
PositionSizing(),
RawData(),
ForecastCombine(),
ForecastScaleCap(),
rules,
],
data,
config,
)
system.set_logging_level(log_level)
return system
if __name__ == "__main__":
import doctest
doctest.testmod()