{"id":20111150,"url":"https://github.com/devtography/ibpy_native","last_synced_at":"2025-05-06T10:32:35.766Z","repository":{"id":50169244,"uuid":"255566190","full_name":"Devtography/ibpy_native","owner":"Devtography","description":"Interactive Brokers Native Python API","archived":false,"fork":false,"pushed_at":"2022-12-26T21:39:15.000Z","size":596,"stargazers_count":13,"open_issues_count":3,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-25T21:20:47.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Devtography.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["iamWing"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://paypal.me/iamWing0w0"]}},"created_at":"2020-04-14T09:28:58.000Z","updated_at":"2025-01-19T11:29:26.000Z","dependencies_parsed_at":"2023-01-31T02:00:43.050Z","dependency_job_id":null,"html_url":"https://github.com/Devtography/ibpy_native","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devtography%2Fibpy_native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devtography%2Fibpy_native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devtography%2Fibpy_native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devtography%2Fibpy_native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Devtography","download_url":"https://codeload.github.com/Devtography/ibpy_native/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252666207,"owners_count":21785218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-13T18:14:38.250Z","updated_at":"2025-05-06T10:32:35.454Z","avatar_url":"https://github.com/Devtography.png","language":"Python","funding_links":["https://github.com/sponsors/iamWing","https://paypal.me/iamWing0w0"],"categories":[],"sub_categories":[],"readme":"# IbPy Native - Interactive Brokers Native Python API\n\nA fully asynchronous framework for using the native Python version of\nInteractive Brokers API.\n\nThe whole framework is built on Python's built in `asyncio` and `queue` modules,\nno event emitter nor any other heavy 3rd party library. The only 3rd party\npackage used is `pytz` for timezone related things. In this way the framework\nis being kept as native Python as possible and the performance shouldn't get\nslowed down due to the libraries used.\n\nAdditionally, most if not all public classes implement their corresponding\ninterface. Therefore, it's easy to implement a customised version for most of\nthe classes. Hence, mocking the API calls/data returns for backtest can be\neasily done, and you should be able to use the same set of strategy code on both\nsimulate and live trading sessions.\n\n## Installation\nInstall from PyPI\n```sh\npip install ibpy-native\n```\n\nAlternatively, install from source. Execute `setup.py` from the root directory.\n```sh\npython setup.py install\n```\n\n__*Always use the newest version while the project is still in alpha!*__\n\n## Usage\n```python\nimport pytz\nfrom ibapi import contract as ib_contract\nfrom ibpy_native import bridge as ibpy_bridge\n\n# Set the timezone to match the timezone specified in TWS or IB Gateway when login\n# Default timezone - 'America/New_York'\nibpy_native.IBBridge.set_timezone(pytz.timezone('America/New_York'))\n\n\n# Connect to a running TWS or IB Gateway instance\nbridge = ibpy_bridge.IBBridge(\n    host='127.0.0.1', port=4001, client_id=1, auto_conn=True\n)\n\n# Search the US stock contract of Apple Inc.\naapl_contract = ib_contract.Contract()\naapl_contract.symbol = 'AAPL'\naapl_contract.secType = 'STK'\naapl_contract.exchange = 'SMART'\naapl_contract.currency = 'USD'\n\n# Sometimes just defining the `Contract` object yourself is enough to match an\n# unique contract on IB and make requests for the contract, but performing a\n# search can ensure you get the valid \u0026 unique contract to work with.\nsearch_results = await bridge.search_detailed_contracts(\n    contract=aapl_contract\n)\n\n# Ask for the earliest available data point of AAPL\nhead_timestamp = await bridge.get_earliest_data_point(\n    contract=search_results[0].contract\n)\n```\n\nFor more, please have a look on the sample scripts in `samples` folder. There's\none script that shows how to request for historical tick data atm, but there\nwill be more as I keep developing my own system based on this framework.\n\nIn the meantime, you may want to read the doc and checkout the unittest for the\nideas of how the APIs work.\n\n_**Do make sure you are using a paper account while running the unittest cases,\nas some of those tests do place real orders to IB and orders will get filled.**_\n\n## System requirements\n- Python \u003e= 3.7; Pervious versions are not supported (development is based on \nPython 3.7.9)\n- _Included IB API version - `9.79.01`_\n\n## Development status (a.k.a. Words from developers)\nAlthough the project is under the stage of active development, up until now\n(`v1.0.0`) it focuses on working with FX, stock \u0026 future contracts from IB.\nOther security types (e.g. options) may work but those are not yet tested.\n\nThis project is not providing full features of IB API yet, but `v1.0.0` is\nalready capable to retrieve \u0026 manage account and orders data, placing and\ncancelling the orders, so as requesting historical and live tick data. More\nfeatures will be supported if my internal trading system needs (that's the\nhighest priority), or by request on the issues board.\n\n## Contributions\nContributions via pull requests are welcome and encouraged. If there's any \nfeature you think is missing, please don't hesitate to implement yourself and \nmake a pull request :)\n\n_Please follow the [Google Python Style Guide] as much as possible for all the\ncode included in your pull request. Otherwise the pull request may be rejected._\n\n## Donation\nThis framework has spent me a whole year to develop from scratch until the first\nstable release (`v1.0.0`). Hopefully you'll find this framework useful as much\nas I do. \n\nIf you wanna support my work, please consider [donate/sponsor] me. Thus I can\nkeep on investing time to further develop the framework alongside my job and\nother projects.\n\n## Author\n[Wing Chau] [@Devtography]\n\n## License\nModules included in `ibpy_native`, except `ibapi` is licensed under the \n[Apache License, Version 2.0](LICENSE.md).\n\nThe `ibapi` is 100% developed \u0026 owned by Interactive Brokers LLC (\"IB\"). By \nusing this package (`ibpy-native`), you are assumed that you agreed the \n[TWS API Non-Commercial License].\n\n## Remarks\n`ibpy_native` is not a product of Interactive Brokers, nor is this project \naffiliated with IB. If you'd like to use `ibpy_native` in any commercial \napplication/product, you must contact Interactive Brokers LLC for permission \nof using IB API commercially.\n\n[Google Python Style Guide]: https://google.github.io/styleguide/pyguide.html\n[donate/sponsor]: https://github.com/sponsors/iamWing\n[Wing Chau]: https://github.com/iamWing\n[@Devtography]: https://github.com/Devtography\n[TWS API Non-Commercial License]: https://interactivebrokers.github.io/index.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtography%2Fibpy_native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtography%2Fibpy_native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtography%2Fibpy_native/lists"}