-
Notifications
You must be signed in to change notification settings - Fork 113
Runtime environment
Whether running using an image or as standalone, IBeam expects IBKR credentials to be provided as environment variables. We recommend you start using IBeam with your paper account credentials, and only switch to production account once you're ready to trade.
-
IBEAM_ACCOUNT
- IBKR account name -
IBEAM_PASSWORD
- IBKR account password
IBeam expects an optional third credential IBEAM_KEY
. If provided, it will be used to decrypt the password given in the IBEAM_PASSWORD
variable. cryptography.fernet decryption is used, therefore to encrypt your password use:
from cryptography.fernet import Fernet
key = Fernet.generate_key()
f = Fernet(key)
password = f.encrypt(b"your_ibkr_password123")
print(f'IBEAM_PASSWORD={password}, IBEAM_KEY={key}')
If any of the required credentials environment variables is not found, user will be prompted to enter them directly in the terminal.
For example your credentials may be set as:
IBEAM_ACCOUNT=my_account_name
IBEAM_PASSWORD=gAAAAABh96EWoJqeRDznN_Lwhojs6CYK5PNH-_U6zMLH1Mz0GS_0Ybn55szSAMfV-86Z-I_GcUR-4BnkR1Ku-xctvTx_0Axu04OUEg65P9h8FbdBOl7cwSNVgbw21htjaleIzUnol92I
IBEAM_KEY=O8yhCTp0WekfQ90Hn4hepnQjrPfiuhXRBMkGuJeumDQ=
When running standalone, IBeam requires the following to be present:
Additionally, the following environment variables:
-
IBEAM_CHROME_DRIVER_PATH
- path to the Chome Driver executable -
IBEAM_GATEWAY_DIR
- path to the root of the Gateway
Note that you can chose to not use the ibeam_starter.py
script and instantiate and use the ibeam.gateway_client.GatewayClient
directly in your script instead. This way you will be able to provide any of the credentials, as well as the Chrome Driver and Gateway paths directly upon construction of the GatewayClient
.
This section was contributed by @bfoz 👏
IBKR only permits a single login at a time for any given set of credentials. Consequently, you can't use the IBKR website while the Gateway (or IBeam) is running. If you try to anyway, the Gateway will be disconnected, which will trigger a re-authentication attempt, which will potentially disconnect your website session. If you then log in to the website again, you'll just start the loop all over again. An easy solution is to stop IBeam before using the website, but that can be tedious.
A more convenient solution is to create a second username for your account and use that for IBeam. From the client portal API documentation section "Multiple usernames":
Clients wishing to use multiple IBKR products at the same time (TWS, IBKR Mobile or Client Portal) can do so by creating a new username that can then be used to log into other services while using the Client Portal API. To create a second username please see the following IBKR Knowledege Base article.
The Knowledge Base article linked above is slightly out of date with respect to the current layout of the IBKR Client Portal:
- The "Manage Account" item in the User menu (upper right corner) is now called "Settings"
- The "Users & Access Rights" panel is no longer on the Settings page, but you can find a similarly named link at the very bottom-left of the page (you may have to scroll to find it)
- The resulting page doesn't have a "Configure (gear) icon". It does have a plus sign button in the "Users" header that does the same thing.
From there you'll be shown a fairly standard-looking username and password dialog. Fill it out in the normal fashion, then click through the many many pages of boilerplate and settings. Feel free to disable many of the notification settings for the new username. Otherwise you'll start getting duplicate emails from IBKR.
At the end of the process, you'll get an email with a confirmation code, but no indication as to what to do with it. Log out and log back in using the new username and password that you just created. You'll then be prompted to enter the confirmation code. Note that you need to be quick about this part because the code expires fast. If you're not fast enough you'll get another automated email with a new code a few minutes after the previous one expired. In fact, you'll keep getting new codes until you get it right.
After entering the confirmation code you'll likely be prompted to change the password for the secondary user.
The final screen of the process says that the request for account creation will be reviewed on the next business day. Some time later you'll receive an email asking you to upload a "Proof of trader authority" for the new username. The verbiage implies that you need to generate a document to upload, however that isn't the case. Simply log in using your primary username (not the secondary!) and you'll be prompted to upload the requested document. At the bottom of the pop-up will be a button titled "Click Here to Upload Documents". Click that and you'll be shown a EULA and a signature block. Type your name (not the new user's name) and click Submit.
After that you should be back at the normal dashboard page, with little indication that you're logged in as the second user. Log out and the new credentials will be ready to use with IBeam. In the future be sure to only use your primary credentials on the website and the secondary credentials for IBeam.
Nota Bene: The username restrictions for the second user are very loose. In fact, it's possible to use the domain name of the machine that hosts your instance of IBeam. A customer service agent suggested that API users typically do exactly that, but there's no requirement to do so.
Learn about Inputs And Outputs and IBeam Configuration
See any error on this page? Create an Issue and let us know.