-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulator_simple_dict.py
More file actions
74 lines (62 loc) · 2.16 KB
/
simulator_simple_dict.py
File metadata and controls
74 lines (62 loc) · 2.16 KB
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
72
73
74
""" examples/simulator_simple_dict.py
A simple example of how to use Tradeforce in simulation mode.
Config loaded from a dictionary, here defined as CONFIG.
Single simulations without hyperparameter optimization are run with the
run_sim() method of the Tradeforce class. If no pre_process, buy_strategy
or sell_strategy functions are passed to run_sim(), the default
implementations will be applied.
See `examples/simulator_custom.py` for details about the default pre_process,
buy_strategy, sell_strategy implementations and how to customize them.
See Config Documentation: https://tradeforce.readthedocs.io/en/latest/config.html
for more information about the Tradeforce configuration options.
"""
from tradeforce import Tradeforce
CONFIG = {
"market_history": {
"name": "bitfinex_history",
"exchange": "bitfinex",
"base_currency": "USD",
"candle_interval": "5min",
"fetch_init_timeframe_days": 100,
"update_mode": "none",
"check_db_sync": False,
},
"backend": {
"dbms": "postgresql",
"dbms_host": "docker_db",
"dbms_port": 5433,
"dbms_connect_db": "postgres",
"dbms_user": "postgres",
"dbms_pw": "postgres",
"local_cache": True,
},
"trader": {
"budget": 1000,
"maker_fee": 0.10,
"taker_fee": 0.20,
"strategy": {
"amount_invest_per_asset": 100,
"moving_window_hours": 180,
"buy_signal_score": 0.10,
"buy_signal_boundary": 0.05,
"buy_signal_preference": 1,
"profit_factor_target": 1.10,
"hold_time_days": 4,
"profit_factor_target_min": 1.01,
},
},
"simulation": {
"subset_size_days": 100,
"subset_amount": 10,
"train_val_split_ratio": 0.8,
},
}
def main() -> None:
sim_result = Tradeforce(config=CONFIG).run_sim()
# Score is calculated by:
# mean(profit subset) - std(profit subset)
# See docs for more info about the score calculation.
print("Score training:", sim_result["score"])
print("Score validation:", sim_result["score_val"])
if __name__ == "__main__":
main()