{"id":41922385,"url":"https://github.com/justfairdev/pairs-ibkr","last_synced_at":"2026-01-25T17:01:52.527Z","repository":{"id":276696356,"uuid":"880961401","full_name":"justfairdev/pairs-ibkr","owner":"justfairdev","description":"Pair-Trading bot developed with Python and Interactive Brokers Trader Workstation (TWS) API","archived":false,"fork":false,"pushed_at":"2024-10-30T17:08:10.000Z","size":125,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T19:25:18.887Z","etag":null,"topics":["ibkr-api","pair-trading","python","trading","tws-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justfairdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T17:08:02.000Z","updated_at":"2025-02-07T13:30:42.000Z","dependencies_parsed_at":"2025-02-09T22:40:45.274Z","dependency_job_id":null,"html_url":"https://github.com/justfairdev/pairs-ibkr","commit_stats":null,"previous_names":["silkgod/pairs-ibkr","justfairdev/pairs-ibkr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/justfairdev/pairs-ibkr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justfairdev%2Fpairs-ibkr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justfairdev%2Fpairs-ibkr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justfairdev%2Fpairs-ibkr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justfairdev%2Fpairs-ibkr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justfairdev","download_url":"https://codeload.github.com/justfairdev/pairs-ibkr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justfairdev%2Fpairs-ibkr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28755561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ibkr-api","pair-trading","python","trading","tws-api"],"created_at":"2026-01-25T17:01:51.767Z","updated_at":"2026-01-25T17:01:52.517Z","avatar_url":"https://github.com/justfairdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pairs-IBKR Python Pair Trading Bot using Interactive Brokers TWS API\n\nFor trading tickers in pairs (also possible to trade a single stock, fx, crypto).\n\n* Trades on Interactive Brokers using [TWS-API](https://interactivebrokers.github.io/tws-api/introduction.html)\n* Integrated with [Pairs-API](https://github.com/ozdemirozcelik/pairs-api)\n* Recommended to use with [IB Gateway](https://www.interactivebrokers.com/en/trading/ibgateway-stable.php)\n* Compatible with TradingView webhooks\n\n# Watch Demo\n\n[![Watch on YouTube](https://ozdemirozcelik.github.io/utubelink.png)](https://www.youtube.com/watch?v=-jfJ6g-fZpI \"Watch on YouTube\")\n\n\n# Use Cases\n\nWith Pairs-API you can:\n- integrate with [Pairs-API](https://github.com/ozdemirozcelik/pairs-api) trade platform\n- validate orders (ticker information, order size, dublicate orders, pair synchronization, minimum funds etc.) \n- send real time orders (Relative, Market, Limit) to Interactive Brokers\n- get filled order information\n- get account summary\n- \n# Considerations\n\nConsidering for the next version:\n\n- improve error handling, add unit tests\n- using historical data from Interactive Brokers for:\n  - automated pair selection by using historical data from IB\n  - custom signal generator\n\n# Requirements\n\n* ibapi==9.76.1 (TWS API - manual installation for the newest version)\n* nest_asyncio\n* pytz\n* pandas\n* requests\n\n\n# Installation\n\nDownload and install IB API for the latest version:\n[Installing \u0026 Configuring TWS for the Python API](https://www.youtube.com/watch?v=xqLkzDMvLz4)\n\ninherited \"ibapi\" folder in the repository from TWS-API docs.\n\n### clone git repository:\n```bash\n$ git clone https://github.com/ozdemirozcelik/pairs-ibkr.git pairs-ibkr\n````\n### create and activate virtual environment:\n````bash\n$ pip install virtualenv\n(conda install virtualenv)\n\n$ cd pairs-ibkr\ncd pairs-ibkr (windows)\n\n$ python -m venv ibkr-env\n(conda create --name ibkr-env)\n\n$ source ibkr-env/bin/activate\n.\\ibkr-env\\scripts\\activate (windows)\n(conda activate ibkr-env)\n````\n### install requirements:\n\n````\n$ pip install -r requirements.txt\n(conda install --file requirements_conda.txt)\n````\ntry this if conda fails to install requirements:\n````\n(conda config --append channels conda-forge)\n````\ncheck this out if you get an invalidversionspec error:\n\nhttps://github.com/conda/conda/issues/9519#issuecomment-690486632\n\n\n# Configuration\n\n* configure config.ini file in line with [Pairs-API](https://github.com/ozdemirozcelik/pairs-api-v4) and IB account details:\n\n```ini\n# DESCRIPTIONS:\n# CHECK_FUNDS_FOR_TRADE=\u003e Check available fund floor before sending an order\n# AVAILABLE_FUND_FLOOR=\u003e available funds contingency amount, less than this amount will result 'no trade'\n# CONNECTION_PORT=\u003e define port for socket connection\n# SYNC_PAIR=\u003e if True: change hedge parameter according to the active position of ticker 2 (sync from flat to pos only)\n# NO_DUBS=\u003e if True: do no create order if duplicate ticker1 is used\n# PASSPHRASE=\u003e  this is the passphrase for webhooks\n# API_PUT_SIGNAL=\u003e API resource to PUT (update) signals\n# API_PUT_PRICE=\u003e API resource to PUT (update) order fill prices\n# API_GET_SIGNAL=\u003e  API resource to GET signal rowid\n# API_GET_SIGNAL_WAITING=\u003e  API resource to GET signals with the status of waiting\n# API_GET_SIGNAL_ROUTE=\u003e  API resource to GET signals with the status of rerouted\n# ACCOUNT_NUMBER=\u003e  IB account number to get account and position details\n# LOGFILE_NAME=\u003e  folder and filename for logs\n\n[environment]\n# enable environment to work with\nENV : development\n# ENV : stage\n# ENV : production\n\n[development]\nCHECK_FUNDS_FOR_TRADE : False\nAVAILABLE_FUND_FLOOR : 5000\nCONNECTION_PORT : 7497\nPASSPHRASE : webhook\nSYNC_PAIR : True\nAPI_PUT_SIGNAL : http://127.0.0.1:5000/v4/webhook\nAPI_PUT_UPDATE : http://127.0.0.1:5000/v4/signal/updateorder\nAPI_GET_SIGNAL : http://127.0.0.1:5000/v4/signal/\nAPI_GET_PAIR : http://127.0.0.1:5000/v4/pair/\nAPI_GET_TICKER : http://127.0.0.1:5000/v4/ticker/\nAPI_UPDATE_PNL : http://127.0.0.1:5000/v4/ticker/updatepnl\nAPI_PUT_PNL : http://127.0.0.1:5000/v4/regpnl\nAPI_GET_PNL : http://127.0.0.1:5000/v4/pnl/1\nAPI_GET_SIGNAL_WAITING : http://127.0.0.1:5000/v4/signals/status/waiting/0\nAPI_GET_SIGNAL_ROUTE : http://127.0.0.1:5000/v4/signals/status/rerouted/0\nACCOUNT_NUMBER = DU######\nLOGFILE_NAME : logs\\logdev_\n\n[stage]\n...\n\n[production]\n...\n````\n* double check your config file name. config.ini has the account number and webhook passphrase so pay attention before pushing to your public repository:\n````python\n(app.py)\n# get configuration variables\nconfig = configparser.ConfigParser()\n# change to your config file name\nconfig.read(\"config_private.ini\")\n...\n````\n\n\n# Contributing\n\nPull requests are welcome.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustfairdev%2Fpairs-ibkr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustfairdev%2Fpairs-ibkr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustfairdev%2Fpairs-ibkr/lists"}