vnpy-ib


Namevnpy-ib JSON
Version 10.19.1.10 PyPI version JSON
download
home_pagehttps://www.vnpy.com
SummaryIB gateway for VeighNa quant trading framework.
upload_time2024-09-23 07:36:37
maintainerNone
docs_urlNone
authorXiaoyou Chen
requires_python>=3.10
licenseMIT
keywords quant quantitative investment trading algotrading
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # VeighNa框架的InteractiveBrokers交易接口

<p align="center">
  <img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
</p>

<p align="center">
    <img src ="https://img.shields.io/badge/version-10.19.1.10-blueviolet.svg"/>
    <img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
    <img src ="https://img.shields.io/badge/python-3.10|3.11|3.12-blue.svg" />
    <img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>

## 说明

基于ibapi的10.19.1版本开发的InteractiveBrokers交易接口。

IbGateway中的合约代码支持两种风格:数字代码和字符串代码。

数字代码基于IB平台的ConId,查询方式:在TWS软件中【右键点击任意合约】->【金融产品信息】->【详情】,然后在弹出的网页上即可找到合约的ConId。

字符串代码基于合约的具体描述信息,命名规则和举例:

|合约类型|代码规则|代码(symbol)|交易所(exchange)|
|---|---|---|---|
|股票|名称-货币-类别|SPY-USD-STK|SMART|
|外汇|名称-货币-类别|EUR-USD-CASH|IDEALPRO|
|贵金属|名称-货币-类别|XAUUSD-USD-CMDTY|SMART|
|期货|名称-到期年月-货币-类别|ES-202002-USD-FUT|GLOBEX|
|期货(指定乘数)|名称-到期年月-合约乘数-类别|SI-202006-1000-USD-FUT|NYMEX|
|期货期权|名称-到期年月-期权类型-行权价-合约乘数-货币-类别|ES-2020006-C-2430-50-USD-FOP|GLOBEX|

委托、成交、持仓信息中的合约代码,默认采用数字代码。如果用户使用字符串代码订阅过行情,则使用字符串代码。

## 安装

安装环境推荐基于3.9.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。

### 安装ibapi

在[IB官网](https://interactivebrokers.github.io/#)下载TWS API的msi安装文件,并运行安装。

找到安装目录下的source\pythonclient文件夹,在cmd中运行下述命令安装:

```
python setup.py install
```

### 安装vnpy_ib

直接使用pip命令:

```
pip install vnpy_ib
```

或者下载源代码后,解压后在cmd中运行:

```
pip install .
```

## 使用

以脚本方式启动(script/run.py):

```
from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp

from vnpy_ib import IbGateway


def main():
    """主入口函数"""
    qapp = create_qapp()

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)
    main_engine.add_gateway(IbGateway)

    main_window = MainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()


if __name__ == "__main__":
    main()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.vnpy.com",
    "name": "vnpy-ib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "quant, quantitative, investment, trading, algotrading",
    "author": "Xiaoyou Chen",
    "author_email": "xiaoyou.chen@mail.vnpy.com",
    "download_url": "https://files.pythonhosted.org/packages/78/25/4b1a69f785aa9404633eb7e2e41697b88ce6edf92ec10f83024f87ccd361/vnpy_ib-10.19.1.10.tar.gz",
    "platform": null,
    "description": "# VeighNa\u6846\u67b6\u7684InteractiveBrokers\u4ea4\u6613\u63a5\u53e3\r\n\r\n<p align=\"center\">\r\n  <img src =\"https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png\"/>\r\n</p>\r\n\r\n<p align=\"center\">\r\n    <img src =\"https://img.shields.io/badge/version-10.19.1.10-blueviolet.svg\"/>\r\n    <img src =\"https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg\"/>\r\n    <img src =\"https://img.shields.io/badge/python-3.10|3.11|3.12-blue.svg\" />\r\n    <img src =\"https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange\"/>\r\n</p>\r\n\r\n## \u8bf4\u660e\r\n\r\n\u57fa\u4e8eibapi\u768410.19.1\u7248\u672c\u5f00\u53d1\u7684InteractiveBrokers\u4ea4\u6613\u63a5\u53e3\u3002\r\n\r\nIbGateway\u4e2d\u7684\u5408\u7ea6\u4ee3\u7801\u652f\u6301\u4e24\u79cd\u98ce\u683c\uff1a\u6570\u5b57\u4ee3\u7801\u548c\u5b57\u7b26\u4e32\u4ee3\u7801\u3002\r\n\r\n\u6570\u5b57\u4ee3\u7801\u57fa\u4e8eIB\u5e73\u53f0\u7684ConId\uff0c\u67e5\u8be2\u65b9\u5f0f\uff1a\u5728TWS\u8f6f\u4ef6\u4e2d\u3010\u53f3\u952e\u70b9\u51fb\u4efb\u610f\u5408\u7ea6\u3011->\u3010\u91d1\u878d\u4ea7\u54c1\u4fe1\u606f\u3011->\u3010\u8be6\u60c5\u3011\uff0c\u7136\u540e\u5728\u5f39\u51fa\u7684\u7f51\u9875\u4e0a\u5373\u53ef\u627e\u5230\u5408\u7ea6\u7684ConId\u3002\r\n\r\n\u5b57\u7b26\u4e32\u4ee3\u7801\u57fa\u4e8e\u5408\u7ea6\u7684\u5177\u4f53\u63cf\u8ff0\u4fe1\u606f\uff0c\u547d\u540d\u89c4\u5219\u548c\u4e3e\u4f8b\uff1a\r\n\r\n|\u5408\u7ea6\u7c7b\u578b|\u4ee3\u7801\u89c4\u5219|\u4ee3\u7801\uff08symbol\uff09|\u4ea4\u6613\u6240\uff08exchange\uff09|\r\n|---|---|---|---|\r\n|\u80a1\u7968|\u540d\u79f0-\u8d27\u5e01-\u7c7b\u522b|SPY-USD-STK|SMART|\r\n|\u5916\u6c47|\u540d\u79f0-\u8d27\u5e01-\u7c7b\u522b|EUR-USD-CASH|IDEALPRO|\r\n|\u8d35\u91d1\u5c5e|\u540d\u79f0-\u8d27\u5e01-\u7c7b\u522b|XAUUSD-USD-CMDTY|SMART|\r\n|\u671f\u8d27|\u540d\u79f0-\u5230\u671f\u5e74\u6708-\u8d27\u5e01-\u7c7b\u522b|ES-202002-USD-FUT|GLOBEX|\r\n|\u671f\u8d27\uff08\u6307\u5b9a\u4e58\u6570\uff09|\u540d\u79f0-\u5230\u671f\u5e74\u6708-\u5408\u7ea6\u4e58\u6570-\u7c7b\u522b|SI-202006-1000-USD-FUT|NYMEX|\r\n|\u671f\u8d27\u671f\u6743|\u540d\u79f0-\u5230\u671f\u5e74\u6708-\u671f\u6743\u7c7b\u578b-\u884c\u6743\u4ef7-\u5408\u7ea6\u4e58\u6570-\u8d27\u5e01-\u7c7b\u522b|ES-2020006-C-2430-50-USD-FOP|GLOBEX|\r\n\r\n\u59d4\u6258\u3001\u6210\u4ea4\u3001\u6301\u4ed3\u4fe1\u606f\u4e2d\u7684\u5408\u7ea6\u4ee3\u7801\uff0c\u9ed8\u8ba4\u91c7\u7528\u6570\u5b57\u4ee3\u7801\u3002\u5982\u679c\u7528\u6237\u4f7f\u7528\u5b57\u7b26\u4e32\u4ee3\u7801\u8ba2\u9605\u8fc7\u884c\u60c5\uff0c\u5219\u4f7f\u7528\u5b57\u7b26\u4e32\u4ee3\u7801\u3002\r\n\r\n## \u5b89\u88c5\r\n\r\n\u5b89\u88c5\u73af\u5883\u63a8\u8350\u57fa\u4e8e3.9.0\u7248\u672c\u4ee5\u4e0a\u7684\u3010[**VeighNa Studio**](https://www.vnpy.com)\u3011\u3002\r\n\r\n### \u5b89\u88c5ibapi\r\n\r\n\u5728[IB\u5b98\u7f51](https://interactivebrokers.github.io/#)\u4e0b\u8f7dTWS API\u7684msi\u5b89\u88c5\u6587\u4ef6\uff0c\u5e76\u8fd0\u884c\u5b89\u88c5\u3002\r\n\r\n\u627e\u5230\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684source\\pythonclient\u6587\u4ef6\u5939\uff0c\u5728cmd\u4e2d\u8fd0\u884c\u4e0b\u8ff0\u547d\u4ee4\u5b89\u88c5\uff1a\r\n\r\n```\r\npython setup.py install\r\n```\r\n\r\n### \u5b89\u88c5vnpy_ib\r\n\r\n\u76f4\u63a5\u4f7f\u7528pip\u547d\u4ee4\uff1a\r\n\r\n```\r\npip install vnpy_ib\r\n```\r\n\r\n\u6216\u8005\u4e0b\u8f7d\u6e90\u4ee3\u7801\u540e\uff0c\u89e3\u538b\u540e\u5728cmd\u4e2d\u8fd0\u884c\uff1a\r\n\r\n```\r\npip install .\r\n```\r\n\r\n## \u4f7f\u7528\r\n\r\n\u4ee5\u811a\u672c\u65b9\u5f0f\u542f\u52a8\uff08script/run.py\uff09\uff1a\r\n\r\n```\r\nfrom vnpy.event import EventEngine\r\nfrom vnpy.trader.engine import MainEngine\r\nfrom vnpy.trader.ui import MainWindow, create_qapp\r\n\r\nfrom vnpy_ib import IbGateway\r\n\r\n\r\ndef main():\r\n    \"\"\"\u4e3b\u5165\u53e3\u51fd\u6570\"\"\"\r\n    qapp = create_qapp()\r\n\r\n    event_engine = EventEngine()\r\n    main_engine = MainEngine(event_engine)\r\n    main_engine.add_gateway(IbGateway)\r\n\r\n    main_window = MainWindow(main_engine, event_engine)\r\n    main_window.showMaximized()\r\n\r\n    qapp.exec()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    main()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "IB gateway for VeighNa quant trading framework.",
    "version": "10.19.1.10",
    "project_urls": {
        "Homepage": "https://www.vnpy.com"
    },
    "split_keywords": [
        "quant",
        " quantitative",
        " investment",
        " trading",
        " algotrading"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97ec6ca7d2366a524d71ee496e19bf67df14a2089850188a2299180363f4d2ae",
                "md5": "a8a152bb154678bae9c6db4a40e00493",
                "sha256": "6facacaae21934e95727615a7d8c809f79af3d3852c38672ca136da31fa38a66"
            },
            "downloads": -1,
            "filename": "vnpy_ib-10.19.1.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a8a152bb154678bae9c6db4a40e00493",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 13729,
            "upload_time": "2024-09-23T07:36:35",
            "upload_time_iso_8601": "2024-09-23T07:36:35.934311Z",
            "url": "https://files.pythonhosted.org/packages/97/ec/6ca7d2366a524d71ee496e19bf67df14a2089850188a2299180363f4d2ae/vnpy_ib-10.19.1.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "78254b1a69f785aa9404633eb7e2e41697b88ce6edf92ec10f83024f87ccd361",
                "md5": "e0f9e1c5b7c7435730d53ab34e4dac79",
                "sha256": "47f709e474f572db3ce2f98feff1e9ae968654aac70b8485fc1a4f388493bdcf"
            },
            "downloads": -1,
            "filename": "vnpy_ib-10.19.1.10.tar.gz",
            "has_sig": false,
            "md5_digest": "e0f9e1c5b7c7435730d53ab34e4dac79",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 14443,
            "upload_time": "2024-09-23T07:36:37",
            "upload_time_iso_8601": "2024-09-23T07:36:37.981414Z",
            "url": "https://files.pythonhosted.org/packages/78/25/4b1a69f785aa9404633eb7e2e41697b88ce6edf92ec10f83024f87ccd361/vnpy_ib-10.19.1.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-23 07:36:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "vnpy-ib"
}
        
Elapsed time: 0.35950s