-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathrun_example.py
44 lines (40 loc) · 1.09 KB
/
run_example.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
# flake8: noqa
from fast_trade import run_backtest
from fast_trade.archive.db_helpers import get_kline
strategy = {
"base_balance": 1000,
"freq": "1h",
"start_date": "2024-06-01",
"end_date": "2024-12-31",
"comission": 0.1,
"datapoints": [
{
"args": [20],
"transformer": "rolling_max",
"name": "highest_high",
"column": "high",
},
{
"args": [15],
"transformer": "rolling_min",
"name": "lowest_low",
"column": "low",
},
],
"enter": [["high", ">=", "highest_high"]],
"exit": [["close", "<=", "lowest_low"]],
"exit_on_end": True,
"exchange": "binanceus",
"symbol": "BTCUSDT",
}
if __name__ == "__main__":
# get the dataframe
# df = get_kline("BTCUSDT", "binanceus", start="2024-09-01", end="2024-12-31")
# print(df)
res = run_backtest(strategy)
print(res.get("summary"))
# print(res.keys())
print(res.get("df"))
# start = "2024-12-19 22:23:00"
# stop = "2024-12-30 00:00:00"
# print(res.tail())