forked from 51bitquant/binance_grid_trader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_futures_script.py
54 lines (37 loc) · 1.44 KB
/
main_futures_script.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
from time import sleep
from logging import INFO
from gridtrader.event import EventEngine
from gridtrader.trader.setting import SETTINGS
from gridtrader.trader.engine import MainEngine, CtaEngine
SETTINGS["log.active"] = True
SETTINGS["log.level"] = INFO
SETTINGS["log.console"] = True
def run_futures_strategy():
SETTINGS["log.file"] = True
event_engine = EventEngine()
main_engine: MainEngine = MainEngine(event_engine)
main_engine.write_log("create main engine")
main_engine.connect(futures_settings, "Futures")
main_engine.write_log("Connect Binance Futures Api")
sleep(10)
cta_engine: CtaEngine = main_engine.get_engine('strategy')
cta_engine.init_engine()
main_engine.write_log("Init Strategy Engine.")
cta_engine.init_all_strategies()
sleep(60) # Leave enough time to complete strategy initialization
main_engine.write_log("Init All Strategies.")
cta_engine.start_all_strategies()
main_engine.write_log("Start All Strategies.")
while True:
sleep(10)
if __name__ == "__main__":
# the futures script, no ui, if you want to use the window UI, please use the main.py
# before running, remember to past your api here.
futures_settings = {
"key": "past your api key from binance exchange",
"secret": "past your api secret from binance exchange",
"futures_type": "USDT",
"proxy_host": "",
"proxy_port": 0
}
run_futures_strategy()