-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathibc_start.py
35 lines (31 loc) · 936 Bytes
/
ibc_start.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
import os
import logging
import json
import base64
from ib_insync import ibcontroller
from ib_insync import IB
from ib_insync.ibcontroller import Watchdog
import ib_insync.util as util
from updateConfig import updateIbcConfig, updateTwsConfig
util.logToConsole(logging.DEBUG)
logger = logging.getLogger(name=__name__)
ibcPath = os.getenv("IBC_PATH", "/opt/ibc")
homePath = os.getenv("HOME", "/root")
twsPath = os.getenv("TWS_PATH", "/root/Jts")
twsLiveorPaperMode = os.getenv("TWS_LIVE_PAPER", "paper") # live or paper
twsPort = os.getenv("TWS_PORT", "4001")
ibcConfigFile = ibcPath + "/config.ini"
twsConfigFile = ibcPath + "/jts.ini"
logger.info("Updating config files")
updateIbcConfig(ibcConfigFile)
updateTwsConfig(twsConfigFile)
ibc = ibcontroller.IBC(
twsVersion=1019,
gateway=True,
ibcPath=ibcPath,
tradingMode=twsLiveorPaperMode,
twsSettingsPath=twsPath,
ibcIni=ibcConfigFile,
)
ibc.start()
IB.run()