brndnmtthws / thetagang

ThetaGang is an IBKR bot for collecting money
GNU Affero General Public License v3.0
1.96k stars 261 forks source link

IBC setup on Docker #300

Closed Teles1 closed 1 year ago

Teles1 commented 1 year ago

Hi, I read through the documentation a couple of times but I'm still a little lost. Looking at the dockerfile I noticed that It sets up IBC inside its container as well as looking at the following line: https://github.com/brndnmtthws/thetagang/blob/93ab979a92705592096abd6c9114aee552c179a2/thetagang/thetagang.py#L252 I can deduce that the docker container will start the ibc gateway for me. Well, good. I followed the instructions, changed the configs, added my logins for IBKR but I'm getting the following when trying to run it:


2023-07-19 16:17:14,918 ib_insync.client INFO Connecting to 127.0.0.1:7497 with clientId 1...
2023-07-19 16:17:14,919 ib_insync.client INFO Disconnecting
2023-07-19 16:17:14,919 ib_insync.client ERROR API connection failed: ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 7497)")
2023-07-19 16:17:14,919 ib_insync.client ERROR Make sure API port on TWS/IBG is open
2023-07-19 16:17:14,919 ib_insync.IBC INFO Terminating
2023-07-19 16:17:17,282 ib_insync.IBC INFO Starting```

Another question is regarding the -v level. Does it work? It didn't change the logs on any of the levels. Thanks!
 docker run --pull always --rm -i --net host -v ~/thetagang:/etc/thetagang brndnmtthws/thetagang:main -v DEBUG --config /etc/thetagang/thetagang.toml

-- I'm trying to run the application targeting a paper account for now.
brndnmtthws commented 1 year ago

The logging output is not always helpful, but here are a few things to check:

Sadly the quality of IBKR's tooling is quite low, so we have to jump through various hoops and chant special incantations to make everything work. IBC does a lot of the heavy lifting for us, but it only takes the edge off the pain of using IBKR's software and APIs.

Teles1 commented 1 year ago
$ cat config.ini | grep 7497
OverrideTwsApiPort=7497
$ cat thetagang.toml | grep 7497
port = 7497

Ports match. I'll try running TWS myself to see if i can figure out what's going on. I'll post another reply to this issue with my findings. Thanks in advance tho!

wihoho commented 1 year ago

try

sudo docker run --net='host' --rm -i -v ~/thetagang:/etc/thetagang brndnmtthws/thetagang:main --config /etc/thetagang/thetagang.toml
robby28-11 commented 1 year ago

I get the same error message. @Teles1 have you fixed it?

Teles1 commented 1 year ago

I did not no. My other issue is that I'm in Canada and I noticed that a lot of places the currency is also hard coded to US. I just gave up on trying. I'll get back to this at some point in time