This article describes how to install and setup the OptraBot software on your machine.

Note: It's not required to download any OptraBot installation package because that is done by the Python Package Manager automatically as described below.

Prerequisites

IB TWS / IB Gateway with API enabled (see the article Interactive Brokers TWS Installation and Configuration)

Python 3.10 or newer (see the article Python Installation for details on the Python installation)

Installation

Open a Terminal or Windows Command Line depending on your Operating System and check the version of Python you've installed.

python --version

Python 3.12.1

Create a directory on your machine where you want to install OptraBot e.g. inside your users home directory and navigate into this directory.

mkdir OptraBot
cd OptraBot

Update the Python package installer PIP to the most recent version.

python -m pip install --upgrade pip

You should see a success message at the end of the output. Now you can install the optrabot package with all its dependencies using PIP.

pip install optrabot

You may use the command 'pip list' in order to get a list of all installed packages and check if the optrabot package is there.

Now you're ready to run the OptraBot for the first time. The app is started with the following command and you'll be asked a couple of questions by the configuration assistant in order to generate an initial config.yaml configuration file.

python -m optrabot.main

No config.yaml found. Let's answer some questions and generate the required configuration file.
? What's your OptraBot API key:

Answer these following questions and confirm your answers at the end. You may cancel the configuration at any point in time by pressing CTRL+C.

1) What's your OptraBot API key?:

Enter the API Key which you have received when registering and setting up your account at app.optrabot.com.

2) Give your OptraBot Instance an Id:

You may go with the suggested default value, but when you're running the OptraBot on more than one machine you should enter a unique id for this machine.

3) Port number on which the OptraBot UI will be accessible:

This defines the HTTP Port which the OptraBot instance will be accessible on. If you plan to run multiple OptraBot instances on one machine, every instance will need to have its own port number. Otherwise there will be a conflict during startup if the port number is already in use.

4) Hostname of your TWS/IB Gateway machine:

If your Interactive Brokers Trader Workstation is running on the same machine as OptraBot you just confirm the suggested value 127.0.0.1 otherwise enter the IP Address/Hostname of the machine where the TWS is running on.

5) Port number of your TWS/IB Gateway:

Enter the socket port number which is configured in your TWS API settings. Default value is 7496 which is good in most cases.

6) Client ID to be used for TWS/IB Gateway connection:

Enter the Client ID which should be used for connecting to the TWS API. Default is 21 which should be good. It's important to know that one client application can connect to TWS at one time with the same Client ID.

7. Select a market data type:

Choose which type of market data you're using. You may choose between Live and Delayed. Default is Live.

8. Account number to be used for trading:

Enter the Interactive Brokers account number that the OptraBot should place the orders to.

9. Number of IronFly contracts to be traded:

Enter the number of Iron Fly contracts that OptraBot should trade. Default is 1.

10.  Increment for limit price adjustments ($):

Enter the $ amount of the size in which the limit price of orders shall be adjusted during trying to get filled. Default is $0.10 which is a good value in order to get a quick fill.

11. Minimum premium for an Iron Fly trade ($):

Specify the minimum premium that you would like to receive when OptraBot opens an 0DTE Iron Fly position. Especially in low volatility market environments, the premium for the trade might be to low in order to have a good risk reward ratio. Default value is $14.00 which is a good value based on historical trades.

12. Percentage of captured premium as profit target (%):

Specify the percentage of the captured premium which should be used as profit target level per trade. The default is 8.

13. Percentage of captured premium as stop loss level (%):

Specify the percentage of the captured premium which should be used as stop loss level per trade. The default is 16.

14. Confirm?

If all settings are entered correctly, confirm them by pressing 'Y' otherwise press 'n'. In case you don't confirm, the app will stop and exit.

Otherwise the OptraBot starts up and tries to connect to your Interactive Brokers TWS instance and starts polling the OptraBot Hub for Iron Fly signals every 5 seconds.

Congratulations, your OptraBot instance is now up and running.

You can stop the OptraBot at any time by pressing shortcut Ctrl+C .

Update

For updating OptraBot to the newest available version, open a Terminal / Command Line and navigate into your OptraBot installation directory e.g:

cd OptraBot

Now run the Python based update command for the optrabot package.

pip install -U optrabot

This will download the latest available version from PyPI and update your installation. Afterwards you can run OptraBot as usual with the following command:

python -m optrabot.main