diff --git a/dockering/ib/README.rst b/dockering/ib/README.rst index 9be11cc5..ad441213 100644 --- a/dockering/ib/README.rst +++ b/dockering/ib/README.rst @@ -24,9 +24,8 @@ here is an example using ``vncclient`` on ``linux``:: vncviewer localhost:5900 - -now enter the pw you set via an (see second code blob) `.env file`_ -or pw-file according to the `credentials section`_. +now enter the pw (password) you set via an (see second code blob) +`.env file`_ or pw-file according to the `credentials section`_. If you want to change away from their default config see the example `docker-compose.yml`-config issue and config-section of the readme, @@ -39,6 +38,74 @@ If you want to change away from their default config see the example .. _credentials section: https://github.com/gnzsnz/ib-gateway-docker?tab=readme-ov-file#credentials +Connecting to the API from `piker` +--------------------------------- +In order to expose the container's API endpoint to the +`brokerd/datad/ib` actor, we need to add a section to the user's +`brokers.toml` config (note the below is similar to the repo-shipped +template file), + +.. code:: toml + + [ib] + # define the (set of) host-port socketaddrs that + # brokerd.ib will scan to connect to an API endpoint + # (ib-gw or ib-tws listening instances) + hosts = [ + '127.0.0.1', + ] + ports = [ + 4002, # gw + 7497, # tws + ] + + # When API endpoints are being scanned durin startup, the order + # of user-defined-account "names" (as defined below) here + # determines which py-client connection is given priority to be + # used for data-feed-requests by according to whichever client + # connected to an API endpoing which reported the equivalent + # account number for that name. + prefer_data_account = [ + 'paper', + 'margin', + 'ira', + ] + + # define "aliases" (names) for each account number + # such that the names can be reffed and logged throughout + # `piker.accounting` subsys and more easily + # referred to by the user. + # + # These keys will be the set exposed through the order-mode + # account-selection UI so that numbers are never shown. + [ib.accounts] + paper = 'XX0000000' + margin = 'X0000000' + ira = 'X0000000' + + +the broker daemon can also connect to the container's VNC server for +added functionalies including, + +- viewing the API endpoint program's GUI for manual interventions, +- workarounds for historical data throttling using hotkey hacks, + +Add a further section to `brokers.toml` which maps each API-ep's +port to a table of VNC server connection info like, + +.. code:: toml + + [ib.vnc_addrs] + 4002 = {host = 'localhost', port = 5900, pw = 'doggy'} + +The `pw = 'doggy'` here ^ should the same value as the particular +container instances `.env` file setting (when it was run), + +.. code:: ini + + VNC_SERVER_PASSWORD='doggy' + + IF you also want to run ``TWS`` ------------------------------- You can also run it containerized, diff --git a/dockering/ib/docker-compose.yml b/dockering/ib/docker-compose.yml index 2f2db58f..54d62ca9 100644 --- a/dockering/ib/docker-compose.yml +++ b/dockering/ib/docker-compose.yml @@ -1,10 +1,15 @@ -# rework from the original @ -# https://github.com/waytrade/ib-gateway-docker/blob/master/docker-compose.yml -version: "3.5" - +# a community maintained IB API container! +# +# https://github.com/gnzsnz/ib-gateway-docker +# +# For piker we (currently) include some minor deviations +# for some config files in the `volumes` section. +# +# See full configuration settings @ +# - https://github.com/gnzsnz/ib-gateway-docker?tab=readme-ov-file#configuration +# - https://github.com/gnzsnz/ib-gateway-docker/discussions/103 services: - ib_gw_paper: # apparently java is a mega cukc: @@ -50,16 +55,22 @@ services: target: /root/scripts/run_x11_vnc.sh read_only: true - # NOTE:to fill these out, define an `.env` file in the same dir as - # this compose file which looks something like: - # TWS_USERID='myuser' - # TWS_PASSWORD='guest' + # NOTE: an alt method to fill these out is to + # define an `.env` file in the same dir as + # this compose file. environment: TWS_USERID: ${TWS_USERID} + # TWS_USERID: 'myuser' TWS_PASSWORD: ${TWS_PASSWORD} - TRADING_MODE: 'paper' - VNC_SERVER_PASSWORD: 'doggy' - VNC_SERVER_PORT: '3003' + # TWS_PASSWORD: 'guest' + TRADING_MODE: ${TRADING_MODE} + # TRADING_MODE: 'paper' + VNC_SERVER_PASSWORD: ${VNC_SERVER_PASSWORD} + # VNC_SERVER_PASSWORD: 'doggy' + + # TODO, see if we can get this supported like it + # was on the old `waytrade` image? + # VNC_SERVER_PORT: '3003' # ports: # - target: 4002 @@ -76,6 +87,9 @@ services: # - "127.0.0.1:4002:4002" # - "127.0.0.1:5900:5900" + # TODO, a masked but working example of dual paper + live + # ib-gw instances running in a single app run! + # # ib_gw_live: # image: waytrade/ib-gateway:1012.2i # restart: no