{ "info": { "author": "Winton Wang", "author_email": "365504029@qq.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: Microsoft", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development", "Topic :: Software Development :: Libraries" ], "description": "# CTP\u671f\u8d27 API Python Wrapper \n\n[![Build Status](https://travis-ci.org/nooperpudd/ctpwrapper.svg?branch=master)](https://travis-ci.org/nooperpudd/ctpwrapper)\n[![Build status](https://ci.appveyor.com/api/projects/status/gvvtcqsjo9nsw0ct/branch/master?svg=true)](https://ci.appveyor.com/project/nooperpudd/ctpwrapper)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9ed5d0e55ed84dfeba30a7630ab5c160)](https://www.codacy.com/app/nooperpudd/ctpwrapper?utm_source=github.com&utm_medium=referral&utm_content=nooperpudd/ctpwrapper&utm_campaign=Badge_Grade)\n[![pypi](https://img.shields.io/pypi/v/ctpwrapper.svg)](https://pypi.python.org/pypi/ctpwrapper)\n[![status](https://img.shields.io/pypi/status/ctpwrapper.svg)](https://pypi.python.org/pypi/ctpwrapper)\n[![pyversion](https://img.shields.io/pypi/pyversions/ctpwrapper.svg)](https://pypi.python.org/pypi/ctpwrapper)\n[![implementation](https://img.shields.io/pypi/implementation/ctpwrapper.svg)](https://pypi.python.org/pypi/ctpwrapper)\n[![Downloads](https://pepy.tech/badge/ctpwrapper)](https://pepy.tech/project/ctpwrapper)\n\n[CTP Website](http://www.sfit.com.cn/5_2_DocumentDown.htm)\n\nVersion: v6.3.15\n\nPlatform: Linux 64bit, Windows 64bit\n\nPython Requirement: x86-64\n\n**Especially Support PyPy3-v5.10.1-3.5.3 Linux 64bit**\n\nInspire By lovelylain \n\n# Install\n\nBefore you install ctpwrapper package, you need to make sure you have \nalready install cython package.\n\n >>>pip install cython --upgrade\n >>>pip install ctpwrapper --upgrade\n\n\n# Donate [\u6350\u52a9]\n\n \n\n\n# Usage\n\n MdApi Class Wrapper\n \n```python\nimport sys\n\nfrom ctpwrapper import ApiStructure\nfrom ctpwrapper import MdApiPy\n\n\nclass Md(MdApiPy):\n \"\"\"\n \"\"\"\n \n def __init__(self, broker_id, investor_id, password, request_id=1):\n\n self.broker_id = broker_id\n self.investor_id = investor_id\n self.password = password\n self.request_id = request_id\n\n def OnRspError(self, pRspInfo, nRequestID, bIsLast):\n\n self.ErrorRspInfo(pRspInfo, nRequestID)\n\n def ErrorRspInfo(self, info, request_id):\n \"\"\"\n :param info:\n :return:\n \"\"\"\n if info.ErrorID != 0:\n print('request_id=%s ErrorID=%d, ErrorMsg=%s',\n request_id, info.ErrorID, info.ErrorMsg.decode('gbk'))\n return info.ErrorID != 0\n\n def OnFrontConnected(self):\n \"\"\"\n :return:\n \"\"\"\n\n user_login = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id,\n UserID=self.investor_id,\n Password=self.password)\n self.ReqUserLogin(user_login, self.request_id)\n\n def OnFrontDisconnected(self, nReason):\n\n print(\"Md OnFrontDisconnected %s\", nReason)\n sys.exit()\n\n def OnHeartBeatWarning(self, nTimeLapse):\n \"\"\"\u5fc3\u8df3\u8d85\u65f6\u8b66\u544a\u3002\u5f53\u957f\u65f6\u95f4\u672a\u6536\u5230\u62a5\u6587\u65f6\uff0c\u8be5\u65b9\u6cd5\u88ab\u8c03\u7528\u3002\n @param nTimeLapse \u8ddd\u79bb\u4e0a\u6b21\u63a5\u6536\u62a5\u6587\u7684\u65f6\u95f4\n \"\"\"\n print('Md OnHeartBeatWarning, time = %s', nTimeLapse)\n\n def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast):\n \"\"\"\n \u7528\u6237\u767b\u5f55\u5e94\u7b54\n :param pRspUserLogin:\n :param pRspInfo:\n :param nRequestID:\n :param bIsLast:\n :return:\n \"\"\"\n if pRspInfo.ErrorID != 0:\n print(\"Md OnRspUserLogin failed error_id=%s msg:%s\",\n pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk'))\n else:\n print(\"Md user login successfully\")\n print(pRspUserLogin)\n print(pRspInfo)\n\n\nBORDKER_ID = \"\"\nINVESTOR_ID = \"\"\nPASSWORD = \"\"\nSERVER = \"\"\n\nmd = Md(BORDKER_ID, INVESTOR_ID, PASSWORD)\nmd.Create()\nmd.RegisterFront(SERVER)\nmd.Init()\nday = md.GetTradingDay()\n\nprint(day)\nprint(\"api worker!\")\n```\n\nTrader Class Wrapper\n\n```python\n\nfrom ctpwrapper import ApiStructure\nfrom ctpwrapper import TraderApiPy\n\nclass Trader(TraderApiPy):\n\n def __init__(self, broker_id, investor_id, password, request_id=1):\n self.request_id = request_id\n self.broker_id = broker_id.encode()\n self.investor_id = investor_id.encode()\n self.password = password.encode()\n\n def OnRspError(self, pRspInfo, nRequestID, bIsLast):\n\n self.ErrorRspInfo(pRspInfo, nRequestID)\n\n def ErrorRspInfo(self, info, request_id):\n \"\"\"\n :param info:\n :return:\n \"\"\"\n if info.ErrorID != 0:\n print('request_id=%s ErrorID=%d, ErrorMsg=%s',\n request_id, info.ErrorID, info.ErrorMsg.decode('gbk'))\n return info.ErrorID != 0\n\n def OnHeartBeatWarning(self, nTimeLapse):\n \"\"\"\u5fc3\u8df3\u8d85\u65f6\u8b66\u544a\u3002\u5f53\u957f\u65f6\u95f4\u672a\u6536\u5230\u62a5\u6587\u65f6\uff0c\u8be5\u65b9\u6cd5\u88ab\u8c03\u7528\u3002\n @param nTimeLapse \u8ddd\u79bb\u4e0a\u6b21\u63a5\u6536\u62a5\u6587\u7684\u65f6\u95f4\n \"\"\"\n print(\"on OnHeartBeatWarning time: \", nTimeLapse)\n\n def OnFrontDisconnected(self, nReason):\n print(\"on FrontDisConnected disconnected\", nReason)\n\n def OnFrontConnected(self):\n\n req = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id,\n UserID=self.investor_id,\n Password=self.password)\n self.ReqUserLogin(req, self.request_id)\n print(\"trader on front connection\")\n\n def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast):\n\n if pRspInfo.ErrorID != 0:\n print(\"Md OnRspUserLogin failed error_id=%s msg:%s\",\n pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk'))\n else:\n print(\"Md user login successfully\")\n\n inv = ApiStructure.QryInvestorField(BrokerID=self.broker_id, InvestorID=self.investor_id)\n\n self.ReqQryInvestor(inv, self.inc_request_id())\n req = ApiStructure.SettlementInfoConfirmField.from_dict({\"BrokerID\": self.broker_id,\n \"InvestorID\": self.investor_id})\n\n self.ReqSettlementInfoConfirm(req, self.inc_request_id())\n\n def OnRspSettlementInfoConfirm(self, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast):\n print(pSettlementInfoConfirm, pRspInfo)\n print(pRspInfo.ErrorMsg.decode(\"GBK\"))\n\n def inc_request_id(self):\n self.request_id += 1\n return self.request_id\n\n def OnRspQryInvestor(self, pInvestor, pRspInfo, nRequestID, bIsLast):\n print(pInvestor, pRspInfo)\n\nif __name__ == \"__main__\":\n investor_id = \"\"\n broker_id = \"\"\n password = \"\"\n server = \"\"\n\n user_trader = Trader(broker_id=broker_id, investor_id=investor_id, password=password)\n\n user_trader.Create()\n user_trader.RegisterFront(server)\n user_trader.SubscribePrivateTopic(2) # \u53ea\u4f20\u9001\u767b\u5f55\u540e\u7684\u6d41\u5185\u5bb9\n user_trader.SubscribePrivateTopic(2) # \u53ea\u4f20\u9001\u767b\u5f55\u540e\u7684\u6d41\u5185\u5bb9\n\n user_trader.Init()\n\n print(\"trader started\")\n print(user_trader.GetTradingDay())\n\n user_trader.Join()\n\n```\n\n# Documentation\n CTP's documentation can be found in the [docs](doc/ctp/)\n\n\n\n# Contact\n\nIf you have any question about the ctpwrapper API, contact 365504029@qq.com", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nooperpudd/ctpwrapper", "keywords": "CTP,Future,SHFE,Shanghai Future Exchange", "license": "LGPLv3", "maintainer": "", "maintainer_email": "", "name": "ctpwrapper", "package_url": "https://pypi.org/project/ctpwrapper/", "platform": "win32", "project_url": "https://pypi.org/project/ctpwrapper/", "project_urls": { "Homepage": "https://github.com/nooperpudd/ctpwrapper" }, "release_url": "https://pypi.org/project/ctpwrapper/6.3.15.3/", "requires_dist": null, "requires_python": ">=3.5", "summary": "CTP client v6.3.15", "version": "6.3.15.3" }, "last_serial": 5341197, "releases": { "6.3.11.15.1": [ { "comment_text": "", "digests": { "md5": "8213d58587e6a82cceb54c0b427ed9b2", "sha256": "5e5a6455f1d773515f417cb82a5d4b4cf26d5afaf01d8d6ac1053a05b85d5698" }, "downloads": -1, "filename": "ctpwrapper-6.3.11.15.1.tar.gz", "has_sig": false, "md5_digest": "8213d58587e6a82cceb54c0b427ed9b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 12671122, "upload_time": "2019-05-29T05:44:19", "url": "https://files.pythonhosted.org/packages/a6/c2/7b2b9ac8c3989342d6dbe81dee9b20d38ed9bb7d60d33c8bffc4a7256704/ctpwrapper-6.3.11.15.1.tar.gz" } ], "6.3.11.3": [ { "comment_text": "", "digests": { "md5": "dfe1a42b506c6726164e3e84764db69c", "sha256": "9a79326ccbd17446fe4d91f5751aab2dd3fbff50c64a9c5b693da53739413434" }, "downloads": -1, "filename": "ctpwrapper-6.3.11.3.tar.gz", "has_sig": false, "md5_digest": "dfe1a42b506c6726164e3e84764db69c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5885427, "upload_time": "2018-05-24T01:17:10", "url": "https://files.pythonhosted.org/packages/84/a8/617f0ff78ee4e849db484c50e56fe324e65b1e5710b1c3a53b27c2cebe69/ctpwrapper-6.3.11.3.tar.gz" } ], "6.3.11.4": [ { "comment_text": "", "digests": { "md5": "957642b5b54c8e4e567a454140c1e406", "sha256": "2458c78eb5cf072f8de6b76fc29c47560c32a044658c8240421b288f90b96a9c" }, "downloads": -1, "filename": "ctpwrapper-6.3.11.4.tar.gz", "has_sig": false, "md5_digest": "957642b5b54c8e4e567a454140c1e406", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5885848, "upload_time": "2018-06-12T16:39:02", "url": "https://files.pythonhosted.org/packages/5e/d0/f3cc49a38f5ad6d158311e8dc44911d4a79969e4b7669ee98f9a2b5dde5a/ctpwrapper-6.3.11.4.tar.gz" } ], "6.3.11.5": [ { "comment_text": "", "digests": { "md5": "5061fee520ea89dfe170400561331ba5", "sha256": "29c4d21fa76bd26d8bfd0682f0c605e33189e01b94e44add8e2c34e328df79b5" }, "downloads": -1, "filename": "ctpwrapper-6.3.11.5.tar.gz", "has_sig": false, "md5_digest": "5061fee520ea89dfe170400561331ba5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5885888, "upload_time": "2018-06-28T01:53:44", "url": "https://files.pythonhosted.org/packages/39/53/1b3914fe393360d3ad59bc512edd53ee9451b5ff45a542610cdcb9d822cf/ctpwrapper-6.3.11.5.tar.gz" } ], "6.3.11.6": [ { "comment_text": "", "digests": { "md5": "2c27f7cdcd946bf6e8d3f49ed58a55ab", "sha256": "6a3ba5b8b574f207f69f01830c50a1dab90d8e005de39c3968af9bec946855ba" }, "downloads": -1, "filename": "ctpwrapper-6.3.11.6.tar.gz", "has_sig": false, "md5_digest": "2c27f7cdcd946bf6e8d3f49ed58a55ab", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5882833, "upload_time": "2018-09-29T03:21:15", "url": "https://files.pythonhosted.org/packages/a0/ff/13077a61a6e8e1ea00f36e2cf614731efd1fa0923c846ae0f8266c813736/ctpwrapper-6.3.11.6.tar.gz" } ], "6.3.15.2": [ { "comment_text": "", "digests": { "md5": "641ab599cef3d10873b6aaf725c9bfc9", "sha256": "a1add1f5462a0e29540dbb5364f8c286a07ea5b0251debe6e93f18cf6e1c7a44" }, "downloads": -1, "filename": "ctpwrapper-6.3.15.2.tar.gz", "has_sig": false, "md5_digest": "641ab599cef3d10873b6aaf725c9bfc9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 12671159, "upload_time": "2019-05-29T05:59:04", "url": "https://files.pythonhosted.org/packages/43/9e/361f173c8b75df2b99c90d6bd9b80f4a000121a3fce8c290534e3488a0f3/ctpwrapper-6.3.15.2.tar.gz" } ], "6.3.15.3": [ { "comment_text": "", "digests": { "md5": "7563888c2b877a989d1a87e20c07172f", "sha256": "871313ed3708c9956eb9800799f5c63b112d1a677798f6da422d2a516d3c56fe" }, "downloads": -1, "filename": "ctpwrapper-6.3.15.3.tar.gz", "has_sig": false, "md5_digest": "7563888c2b877a989d1a87e20c07172f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 12671170, "upload_time": "2019-05-31T06:02:04", "url": "https://files.pythonhosted.org/packages/d9/4e/0ad828efecd12e164eced84c61f18e31c03c42503e6d14c983a6da68b039/ctpwrapper-6.3.15.3.tar.gz" } ], "6.3.6.6": [ { "comment_text": "", "digests": { "md5": "48dd5d76364a0c56e99377493dc490bf", "sha256": "728ddee38ce69f7db2a9d5e1da2f8cba6ee80eed13556e99d6a510551580806b" }, "downloads": -1, "filename": "ctpwrapper-6.3.6.6.tar.gz", "has_sig": false, "md5_digest": "48dd5d76364a0c56e99377493dc490bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4742822, "upload_time": "2018-04-19T06:05:54", "url": "https://files.pythonhosted.org/packages/6b/c1/7f8f496454405e4b34b58a5b23f103e93e60f9ef2138b25e195347073a5a/ctpwrapper-6.3.6.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7563888c2b877a989d1a87e20c07172f", "sha256": "871313ed3708c9956eb9800799f5c63b112d1a677798f6da422d2a516d3c56fe" }, "downloads": -1, "filename": "ctpwrapper-6.3.15.3.tar.gz", "has_sig": false, "md5_digest": "7563888c2b877a989d1a87e20c07172f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 12671170, "upload_time": "2019-05-31T06:02:04", "url": "https://files.pythonhosted.org/packages/d9/4e/0ad828efecd12e164eced84c61f18e31c03c42503e6d14c983a6da68b039/ctpwrapper-6.3.15.3.tar.gz" } ] }