Metadata-Version: 2.5
Name: optrabot
Version: 0.37.3
Summary: QuantX OptraBot is a Options Trading Bot for automatically trading options strategies with an Interactive Brokers account.
Author: QuantX GmbH
License: MIT
Keywords: tws
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Requires-Python: <3.14,>=3.13
Requires-Dist: aeventkit<3.0.0,>=2.1.0
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: alembic>=1.13.1
Requires-Dist: apscheduler==3.11.0
Requires-Dist: bcrypt>=4.0.0
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: fastapi==0.117.0
Requires-Dist: httpx==0.28.1
Requires-Dist: ib-async==2.1.0
Requires-Dist: inquirerpy>=0.3.4
Requires-Dist: loguru==0.7.3
Requires-Dist: lxml>=5.0.0
Requires-Dist: ntplib>=0.4.0
Requires-Dist: numpy<2.4.0
Requires-Dist: packaging>=24.2
Requires-Dist: pandas-market-calendars>=5.1.3
Requires-Dist: pandas<3.0.0
Requires-Dist: pyjwt>=2.8.0
Requires-Dist: pyotp>=2.9.0
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: pytz>=2025.2
Requires-Dist: ruyaml==0.91.0
Requires-Dist: simpleeval>=0.9.13
Requires-Dist: sqlalchemy==2.0.36
Requires-Dist: tzdata>=2023.3
Requires-Dist: uvicorn==0.32.1
Requires-Dist: websockets>=12.0
Description-Content-Type: text/markdown

# OptraBot
OptraBot is a Options Trading Bot which can be used to run fully automated options trading strategies using your Interactive Brokers or Tastytrade trading account.

## System requirements
Microsoft Windows, MacOS or Linux operating system

Python 3.13

For Interactive Brokers (native installation): Trader Workstation (TWS) or IB Gateway version 10.50 or later, or IB Client Portal Gateway. Interactive Brokers no longer supports TWS / IB Gateway 10.45 and older from December 15, 2026.

For the Interactive Brokers Web API: Java 8 or newer (https://www.java.com/download/). OptraBot downloads the IB Client Portal Gateway from Interactive Brokers at the first login into `ib-gateway/` in its working directory and starts it automatically. Alternatively, an own gateway directory or a gateway started by yourself can be configured in the broker settings.

## Installation

OptraBot uses the Python Package Manager UV from Astral (https://docs.astral.sh/uv/).

Use the following command for automatic installation procedure depending on your Operating System.

Windows: `powershell -ExecutionPolicy ByPass -c "irm https://app.optrabot.io/static/assets/scripts/install-optrabot.ps1 | iex"`

Windows Server: `powershell -ExecutionPolicy ByPass -c "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; irm https://app.optrabot.io/static/assets/scripts/install-optrabot.ps1 | iex"`

MacOS/Linux: `curl -LsSf https://app.optrabot.io/static/assets/scripts/install-optrabot.sh | bash`

This will download and automatically install UV if necessary, the correct Python version and the OptraBot itself.

## Updating

The OptraBot got a auto-update functionality integrated. There is no need to update it manually.

The UV Package Manager can be updated with the command `uv self update`

## Run OptraBot

OptraBot can be started with the following command: `optrabot`

## Docker

OptraBot is also available as a Docker image (`quantxgmbh/optrabot:latest`).

### Quick Start

Create a `docker-compose.yaml` and a `data/` directory for the configuration and database:

```yaml
services:
  optrabot:
    image: quantxgmbh/optrabot:latest
    container_name: optrabot
    ports:
      - "8080:8080"   # HTTP – for CDN/reverse proxy origin or direct access
      # - "8443:8443" # Optional: direct local HTTPS access (required for IB Web SSO)
    volumes:
      - ./data:/optrabot  # config.yaml and database are stored here
    environment:
      - IBGW=true         # Set to true to use the IB Client Portal Gateway inside the container
    restart: unless-stopped
```

Then start the container:

```bash
docker compose up -d
```

The OptraBot UI is then accessible at `http://<host>:8080`.

### Environment Variables

| Variable | Values | Description |
|---|---|---|
| `IBGW` | `true` / `false` (default) | Enables the IB Client Portal Gateway inside the container (started by OptraBot) and routes IB API traffic via nginx |

### Ports

| Port | Protocol | Description |
|---|---|---|
| `8080` | HTTP | Main entry point – suitable as CDN/reverse proxy origin or for direct access |
| `8443` | HTTPS (self-signed) | Optional – required for local browser-based IB Web SSO login (Secure cookies) |

> **Note:** When using Interactive Brokers Web API (`ibweb`) with local SSO login, use the HTTPS port `8443`.

### Interactive Brokers in Docker

When running OptraBot in Docker with `IBGW=true`, the connection to Interactive Brokers is established via the **IB Client Portal Gateway**. OptraBot downloads it from Interactive Brokers at the first start into `ib-gateway/` in the mounted `data/` directory and starts it inside the container; the image contains Java but no IB software.

The IB Client Portal Gateway requires a one-time browser-based login (SSO). Because the SSO session cookie is set as `Secure`, **this login must be performed over HTTPS**. Make sure to:

1. Add the port mapping `8443:8443` in your `docker-compose.yaml`
2. Open `https://<host>:8443` in your browser to complete the IB login
3. Accept the self-signed certificate warning in the browser

After a successful login, OptraBot can communicate with Interactive Brokers via the gateway running inside the container.

> **Note:** Port `8080` (HTTP) is not suitable for the IB SSO login — use `8443` (HTTPS) for any browser-based IB authentication.

### Configuration

On first start, the setup wizard launches automatically if no `config.yaml` is found in the mounted `data/` directory. It guides through the initial configuration step by step. An existing `config.yaml` can also be imported directly in the setup wizard.

### Health Check

OptraBot exposes a health check endpoint at `/up`. Use this path for load balancer and container health checks:

```
http://<host>:8080/up
```

The endpoint returns HTTP `200` when OptraBot is running.

## Log files

OptraBot writes its log to `logs/optrabot_<date>.log`. Credentials (API keys, tokens, client secrets, passwords) are masked in the log. Log files written by versions before 0.37.0 can still contain credentials in plain text in some cases, before 0.34.1 also in the configuration listed at start: check or delete those files before you share them, and rotate the affected credentials if such a file has already been passed on.

---

## Disclaimer
Be aware that you're using this software at your own risk. The author is not liable for any losses occuring with using this software.
