A brief tutorial on setting up the Interactive Brokers Gateway on Linux.
I’m working on a project that uses data acquired from the Interactive Brokers API. The API is not accessible directly but rather via a local client which is installed on your machine. You have two options for this client:
- Interactive Brokers Trader Workstation (TWS) and
- Interactive Brokers Gateway.
The former provides a fully featured trading interface, while the latter simply provides and interface to the API. I’m going with the latter.
Download
Download the Gateway installer. There are two versions: stable
and latest
.
IBDOWNLOAD=https://download.interactivebrokers.com/installers/ibgateway
# Stable version
curl -o ibgateway-standalone-linux-x64.sh $IBDOWNLOAD/stable-standalone/ibgateway-stable-standalone-linux-x64.sh
# Latest version
curl -o ibgateway-standalone-linux-x64.sh $IBDOWNLOAD/latest-standalone/ibgateway-latest-standalone-linux-x64.sh
Install
Next you need to run the installer.
chmod u+x ibgateway-standalone-linux-x64.sh
./ibgateway-standalone-linux-x64.sh
You can safely accept all of the defaults in the installation process.
Launch
During the installation a Jts
directory will be created. Beneath that you’ll find a sub-directory named with the version of the gateway (for example, 1015
) and within that you’ll find the executable, ibgateway
. Run the executable.
Choose the IB API option for API type. Fill in your username and password. Press the Log In button.
From time to time you’ll find that you are unable to login because the servers are down for maintenance. Just be patient and the service will be restored. Maintenance seems to typically occur around midnight UTC on a Friday night, but this seems to vary.
Once connected you should see an interface showing the connection status.
Conclusion
Once the Gateway is running and you’re connected you’ll immediately be able to interact with the API. You can do this from a variety of languages. Unless timing is hyper-critical for what you’re doing then I’d suggest exploring either the Python or R interface to the API.
Resources
Visit datawookie blog for additional insight on this topic: https://datawookie.dev/blog/2022/04/setting-up-interactive-brokers-gateway/.
Disclosure: datawookie blog
Nasdaq® is a registered trademark of Nasdaq, Inc. The information contained above is provided for informational and educational purposes only, and nothing contained herein should be construed as investment advice, either on behalf of a particular security or an overall investment strategy. Neither Nasdaq, Inc. nor any of its affiliates makes any recommendation to buy or sell any security or any representation about the financial condition of any company. Statements regarding Nasdaq-listed companies or Nasdaq proprietary indexes are not guarantees of future performance. Actual results may differ materially from those expressed or implied. Past performance is not indicative of future results. Investors should undertake their own due diligence and carefully evaluate companies before investing. ADVICE FROM A SECURITIES PROFESSIONAL IS STRONGLY ADVISED.
© 2023. Nasdaq, Inc. All Rights Reserved.
Options
For the sake of simplicity, the examples included do not take into consideration commissions and other transaction fees, tax considerations, or margin requirements, which are factors that may significantly affect the economic consequences of a given strategy. An investor should review transaction costs, margin requirements and tax considerations with a broker and tax advisor before entering into any options strategy.
Options involve risk and are not suitable for everyone. Prior to buying or selling an option, a person must receive a copy of Characteristics and Risks of Standardized Options. Copies may be obtained from your broker, one of the exchanges or The Options Clearing Corporation, One North Wacker Drive, Suite 500, Chicago, IL 60606 or call 1-888-OPTIONS or visit www.888options.com.
Any strategies discussed, including examples using actual securities and price data, are strictly for illustrative and education purposes and are not to be construed as an endorsement, recommendation or solicitation to buy or sell securities.
© 2023. Nasdaq, Inc. All Rights Reserved.
Disclosure: Interactive Brokers
Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.
This material is from datawookie blog and is being posted with its permission. The views expressed in this material are solely those of the author and/or datawookie blog and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.
Disclosure: API Examples Discussed
Throughout the lesson, please keep in mind that the examples discussed are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.