-
|
I am trying to put together a simple example of using this container, but I am running into some issues. I think they ultimately boil down to me incorrectly configuring ports. I will note that I am using the ib_async wrapper for accessing the api. My application consists of the following files:
Here are the contents of the files: docker-compose.yml name: algo-trader
services:
ib-gateway:
# Here i use the unmodified ib-gateway service provided by this repo
bot:
build: .
environment:
GATEWAY_HOST: "0.0.0.0"
GATEWAY_PORT: 4004dockerfile main.py import os
import time
from ib_async import *
if __name__ == '__main__':
# This is a hacky way of making sure the gateway is ready
print("Waiting 20s for gateway to start...")
time.sleep(20)
host = os.environ["GATEWAY_HOST"] or "127.0.0.1"
port = os.environ["GATEWAY_PORT"] or 4002
print(f"Attempting to connect to gateway at {host}:{port}...")
ib = IB()
ib.connect(host=host, port=port, clientId=1)
summary = ib.accountSummary()
print(summary)When I run the docker-compose, I get the following error: Am I using the wrong IP/ports? Additionally, is there an alternative to using the my hacky |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
ib_async documentation is clear on the usage of not sure what's your expectation with |
Beta Was this translation helpful? Give feedback.
ib_async documentation is clear on the usage of
time.sleep--> DON'T USE IT, please read the documentation.not sure what's your expectation with
GATEWAY_HOSTandGATEWAY_PORTibgateway does not use those values. by default you can access services by their service name (or hostname if you set it), so in this case from your bot you can access ibgateway asib-gatewayas that's the service name in yourdocker-compose.ymlexample. please check docker and docker compose documentation