mvberg / ib-gateway-docker

Interactive Brokers Trading Gateway running in Docker
MIT License
224 stars 105 forks source link

Update to IB Gateway 978.2b and updates to deploy to Kubernetes using a Helm 3 chart #24

Open forhire opened 3 years ago

forhire commented 3 years ago

I have created this update to download and install the current stable release of Interactive Brokers Gateway v978.2b. I have also updated the runscript to get rid of socat and use the IB Gateway port directly to reduce overhead and to enable deploying this image to Kubernetes with TCP port monitoring and automatic restart when the port is unavailable.

I also created a Helm 3 chart to deploy to Kubernetes at https://github.com/forhire/ibgw to make Kubernetes deployment easy, using Kubernetes secrets to store credentials.

leebailey88 commented 3 years ago

I personally don't need kubernetes, but the main problem I'm trying to solve is make the container more stable / auto restart on exceptions. Right now, I have to kill and remove the docker container and recreate it at least once every day, sometimes more often. Will these changes fix this? Is there a smaller subset of these changes that would fix it, ie. the few lines changed in the runscript.sh alone? Thanks very much!

forhire commented 3 years ago

I'm trying to refactor further to not need socat to redirect to localhost. Socat redirect seems to be resulting in some performance slowdowns and disconnects. Updating the ibg.xml to allow connections not just from localhost should do this, but ibg.xml gets placed in the directory that is created after startup. https://github.com/ajpierce/ib_tws_docker is another Dockerization of IBG that tries to use ibg.xml, but it seems to be currently set up for their specific user, and they create that by starting, killing, and then restarting IBGW which seems very inefficient.

I have been using Kubernetes to monitor and restart IBGW, but there's more refinement that can be done, such as watching for the timestamp, account information, or tick data to ensure it is fully active.

The allowOnlyLocalhost value below is what needs to be changed.

    <ApiSettings varName="api" dde="false" readOnlyApi="false" allowOnlyLocalhost="false" socketClient="true" autoOpenOrdDonwload="true" port="4001" includeFxPositions="true" includeContinuousUpdateChanges="true" sendMessagesInEnglish="false" sendMessagesTranslated="true" logLevel="2" useNegativeAutoRange="true" overridePrecautionaryConstraints="false" bypassBondWarning="false" bypassYtwWarning="false" bypassCalledBondWarning="false" masterClientID="-1" acceptLargeSize="false" showApiMsg="false" includeMktData="false" createApiMsgLogFile="false" showIBGConsole="false" aPINotAllowedShownAfterDenyAPI="false" slowBufferTimeout="30" syncAccounts="false" multichartNetDoNotShowTime="0" multichartDoNotShowTime="0" verifiedAppPortRangeStart="7000" verifiedAppPortRangeEnd="8000" timeOfVerifiedAppShutdown="0" portOfVerifiedAppShutdown="0">
krumware commented 1 year ago

@forhire I still have contributor access to this repository and can participate in some of the deployment/helm testing on my end. even if @mvberg isn't available, I may be able to assist in getting this or other PRs merged. LMK if I can help!

forhire commented 1 year ago

@krumware Thanks, I have been making a lot of updates in my fork of this, including updating to the current stable-standalone release, adding Github actions to build and publish containers automatically, reworking the socat startup, adding health checks to the container, etc. I have recently been working on Semantic Versioning for the Docker Container releases, which has been a little messier than I'd like, but it seems to work. I also made a Helm 3 chart that needs some updates to reflect the changes I've made.

krumware commented 1 year ago

I'm still watching! Feel free to ping me when you think this is at a stopping point

forhire commented 1 year ago

Thanks, I'm still working on a lot of little quirks and issues. It seems like xvfb-run is not reliably starting, so I'm going to try changing to tigervnc-standalone-server. IBGW has stopped responding to API requests, until I change to another port and back, then it starts working again. I want this to be very stable, so it can be used for reliable trading.