Skip to main content

A proxy service for the Interactive Brokers API

Project description

IBKR Proxy

PyPI - Version PyPI - Downloads Codecov

Setup

You need to have the following files in the local directory to enable the use of the IBKR OAuth service:

  • config.yaml and
  • privatekey.pem.

See the README for the ibauth project for documentation of the config.yaml content.

Running Locally

uv sync
uv run ibproxy --debug

Running on EC2

To run on an EC2 instance you'd do precisely the same thing as for running locally. Since the proxy is configured to only answer requests from localhost this will mean that requests from outside will not reach the proxy. In general this is a good thing.

There are ways that you can expose the proxy to the outside world. For the purpose of illustration suppose that you are running the proxy on an EC2 instance at 3.218.141.190.

Sending a Request

Just send your request to the proxy as if you were sending it to the IBKR API. For example, if you were going to request

curl "http://api.ibkr.com/v1/api/iserver/accounts"

then do this instead

curl "http://127.0.0.1:9000/v1/api/iserver/accounts"

NGINX

Unless you set up authentication this would definitely open up a can of worms.

SSH Tunnel

This is a simple and secure approach. Presumably you have SSH access to the EC2 instance. Run the following on your local machine to set up an SSH tunnel to the EC2 instance:

ssh -N -L 9000:127.0.0.1:9000 ubuntu@3.218.141.190

That will connect port 9000 on your local machine to port 9000 on the EC2 instance. Local requests on port 9000 will then be relayed via the secure tunnel to the proxy on the EC2 instance.

Development

uv sync
uv run ibproxy --debug

You can access the Swagger interface at http://127.0.0.1:9000/docs.

Local IBKR Authentication Workflow

If you are testing changes to ibauth then you can install a local copy.

  1. Add this to the end of pyproject.toml:

    [tool.uv.sources]
    ibauth = { path = "../ibauth", editable = true }
    
  2. uv lock --upgrade

  3. uv sync

You can also set this up in one quick move:

uv add --editable ../ibauth

Tests

To run tests:

uv run pytest

The integration tests require a running proxy. To run those, first launch a proxy process and then run:

uv run pytest -m integration

There are also some tests that are marked specifically for infrequent use. To run those:

uv run pytest -m seldom

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ibproxy-0.2.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ibproxy-0.2.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file ibproxy-0.2.0.tar.gz.

File metadata

  • Download URL: ibproxy-0.2.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ibproxy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8d2cf3ed1cc33a395a3ed3ed005a4c5d06f79c70c26a7a7666251077cad6a255
MD5 41bb0beb0d65d76df6c5c80932a90f8d
BLAKE2b-256 55868b8edc339ceab02719b5dd9087a09be3aaba6c04152a5409884809a74e65

See more details on using hashes here.

File details

Details for the file ibproxy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ibproxy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ibproxy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af4f0b333efffb2c6a1991acded9c66191ea443e8aa005739b3dcbdff35f44ec
MD5 802561a7f0772a9cc0b763b72d269d02
BLAKE2b-256 1297ae27c32b8498c4b41030dd13eb82f78851ade99684b9375a650feca602a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page