forked from robcarver17/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
65 lines (48 loc) · 2.14 KB
/
config.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
from sysdata.config.production_config import get_production_config
from sysobjects.production.tradeable_object import listOfInstrumentStrategies
###### stale
def remove_stale_instruments_and_strategies_from_list_of_instrument_strategies(
list_of_instrument_strategies: listOfInstrumentStrategies,
) -> listOfInstrumentStrategies:
filtered_list = remove_stale_instruments_from_list_of_instrument_strategies(
list_of_instrument_strategies
)
twice_filtered_list = remove_stale_strategies_from_list_of_instrument_strategies(
filtered_list
)
return twice_filtered_list
def remove_stale_instruments_from_list_of_instrument_strategies(
list_of_instrument_strategies: listOfInstrumentStrategies,
) -> listOfInstrumentStrategies:
list_of_stale_instruments = get_list_of_stale_instruments()
filtered_list = list_of_instrument_strategies.filter_to_remove_list_of_instruments(
list_of_stale_instruments
)
return filtered_list
def remove_stale_instruments_from_list_of_instruments(
list_of_instrument_codes: list,
) -> list:
list_of_stale_instruments = get_list_of_stale_instruments()
filtered_list = [
instrument_code
for instrument_code in list_of_instrument_codes
if instrument_code not in list_of_stale_instruments
]
return filtered_list
def remove_stale_strategies_from_list_of_instrument_strategies(
list_of_instrument_strategies: listOfInstrumentStrategies,
) -> listOfInstrumentStrategies:
list_of_stale_strategies = get_list_of_stale_strategies()
filtered_list = list_of_instrument_strategies.filter_to_remove_list_of_strategies(
list_of_stale_strategies
)
return filtered_list
def get_list_of_stale_instruments() -> list:
config = get_production_config()
return get_list_of_stale_instruments_given_config(config)
def get_list_of_stale_instruments_given_config(config) -> list:
stale_instruments = config.get_element_or_default("stale_instruments", [])
return stale_instruments
def get_list_of_stale_strategies() -> list:
config = get_production_config()
return config.get_element_or_default("stale_strategies", [])