{ "info": { "author": "Jesse Liu", "author_email": "jesseliu0@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Intended Audience :: Developers", "Intended Audience :: Financial and Insurance Industry", "License :: OSI Approved :: MIT License", "Operating System :: POSIX", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Office/Business :: Financial :: Investment", "Topic :: Scientific/Engineering" ], "description": "ibstract\n========\n\n|Pyversion| |PyPIVersion| |Status| |License|\n\n**ibstract** is a Python 3 package for trading data acquiring and\nmanagement. Thanks to Python's asyncio_ library, it can accesses `Interactive\nBrokers API`_ for concurrent remote data downloading, and a MySQL database as\nlocal cache for concurrent data archiving and offline query. Classes in the\npackage also combine, transform, and maintain trading data, and provide\norganized and aggregated data or signals for algorithmic trading. **ibstract**\nusers can focus on trading algorithms without worrying about the hassels of\nhandling a broker API or the tedious and error-prone trading data management.\n\n\nFeatures\n--------\n* Concurrent data acquiring and processing with asynchronous access to remote\n IB API server and local MySQL database, powered by ``async/await`` syntax of\n `asyncio`_ module in Python_ 3.6+ and 3rd-party `aio-libs`_.\n* Automatically analyze and split a user's historical data request, and\n dispatch data acquiring tasks to local MySQL database (preferred) or remote\n IB API server. In this way much downloading efforts could be saved for\n repeating requests for the same data pieces.\n* MarketDataBlock class manages and merges historical data pieces with\n different symbols, types, durations and date/time in an organized and\n standardized way. Data time zone is region-based using pytz, and\n automatically converted and maintained.\n\n\nPlanned Features:\n^^^^^^^^^^^^^^^^^\n* Asynchronously generating technical signals from user-specified historical data.\n* Concurrent real-time market data streaming and real-time trading signal generating.\n* Background order submission, status monitoring, and logging.\n\n\nInstallation\n------------\n\n::\n\n pip3 install -U ibstract\n\nRequirements\n^^^^^^^^^^^^\n* Python_ 3.6+ (Anaconda_ 4.4.0+)\n* `Interactive Brokers API`_ 9.73.2+\n* `IB gateway latest`_ 967+\n* `ib_insync`_ 0.8.5+\n* aiomysql_ 0.0.9+\n* sqlalchemy_ 1.1.9+\n* pandas_ 0.20.1+\n* tzlocal_ 1.4+\n\n\nDocumentation\n-------------\n`Full Documentation `_\n\n\nExamples\n--------\nFor **full explanation and detailed examples**, please take a look at the example notebooks:\n\n* `Historical data operations example notebook`_\n* `MarketDataBlock class example notebook`_\n* `IB class example notebook`_\n\nExample 1: Concurrently acquire data from local MySql database and remote IB API server.\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nA user coroutine requests wider range of historical data than those existing in\nMySQL. The data pieces existing in MySQL will not be downloaded, but will be\nqueried and combined with those downloaded. A request could be split into\nmultiple downloading tasks and perfored concurrently and asynchronously, as\nwell as inserting the downloaded data to MySQL in the background.\n\n**Data pre-existing** in MySQL database:\n\n::\n\n opening high low closing volume barcount average\n Symbol DataType BarSize TickerTime \n GS TRADES 1d 2017-08-31 00:00:00-04:00 223.25 224.49 222.58 223.74 15491 10053 223.764\n 2017-09-01 00:00:00-04:00 224.55 227.56 223.53 225.88 16940 11739 226.350\n 2017-09-05 00:00:00-04:00 223.85 224.00 217.30 217.78 45499 28392 218.901\n\n**Request for wider range of data:**\n\n.. code-block:: python\n\n async def user_coro(req, broker, mysql):\n blk_ret = await get_hist_data(req, broker, mysql)\n return blk_ret\n\n # Request daily data of 8 days, from 8/29 - 9/8.\n # Data from 8/31 - 9/5 exist in local database and will not be downloaded.\n req = HistDataReq('Stock', 'GS', '1d', '8d', dtest(2017, 9, 9))\n broker = IB('127.0.0.1', 4002)\n db_info = {'host': '127.0.0.1', 'user': 'root', 'password': 'ibstract',\n 'db': 'ibstract_test'}\n \n loop = asyncio.get_event_loop()\n mysql={**db_info, 'loop': loop}\n blk_ret = loop.run_until_complete(user_coro(req, broker, mysql))\n blk_ret.df\n\n**Output data** is the combination of those in database and downloaded:\n\n::\n\n opening high low closing volume barcount average\n Symbol DataType BarSize TickerTime \n GS\t TRADES 1d 2017-08-29 00:00:00-04:00 217.27 220.14 215.75 219.96 18795 12617 218.7545\n 2017-08-30 00:00:00-04:00 220.25 224.22 220.09 222.42 18580 12085 222.7730\n 2017-08-31 00:00:00-04:00 223.25 224.49 222.58 223.74 15491\t 10053 223.7635\n 2017-09-01 00:00:00-04:00 224.55 227.56 223.53 225.88 16940\t 11739 226.3505\n 2017-09-05 00:00:00-04:00 223.85 224.00 217.30 217.78 45499\t 28392 218.9010\n 2017-09-06 00:00:00-04:00 218.98 221.02 217.61 218.83 26158\t 15960 219.5335\n 2017-09-07 00:00:00-04:00 218.73 218.81 214.64 215.84 27963\t 17892 215.7020\n 2017-09-08 00:00:00-04:00 215.51 219.28 215.40 217.21 23250\t 15562 217.5120\n \nExample 2: Create, update and combine MarketDataBlock instances.\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n**Input pandas.DataFrames** having different columns, symbols, barsize, and dates/times:\n\n.. code-block:: python\n\n print(df_gs1)\n print(df_gs2)\n print(df_fb5m)\n print(df_fb1m)\n print(df_amzn)\n\n::\n\n symbol barsize date close\n 0 GS 5 min 2016-07-12 10:35:00-07:00 140.05\n 1 GS 5 min 2016-07-12 11:20:00-07:00 141.34\n\n symbol barSize datetime close volume\n 0 GS 5 min 2016-07-12 10:35:00-07:00 140.05 344428\n\n time c vol\n 0 2016-07-21 09:30:00 120.05 234242\n 1 2016-07-21 09:35:00 120.32 410842\n\n time c vol\n 0 2016-07-25 09:40:00 120.47 579638\n 1 2016-07-25 09:41:00 120.82 192476\n\n symb bar date close volume\n 0 AMZN 1 day 2016-07-21 749.22 27917\n 1 AMZN 1 day 2016-07-22 738.87 36662\n 2 AMZN 1 day 2016-07-23 727.23 8766\n\n**MarketDatablock organizes DataFrames together:**\n\n.. code-block:: python\n\n import pytz\n from ibstract import MarketDataBlock\n\n east = pytz.timezone('US/Eastern')\n \n blk = MarketDataBlock(df_gs1, datatype='TRADES', tz=east)\n blk.update(df_gs2, datatype='TRADES', tz=east)\n blk.update(df_fb5m, symbol='FB', datatype='TRADES', barsize='5m', tz=east)\n blk.update(df_fb1m, symbol='FB', datatype='TRADES', barsize='1m', tz=east)\n blk_amzn = MarketDataBlock(df_amzn, datatype='TRADES', tz=east)\n blk.combine(blk_amzn)\n\n**Output MarketDataBlock:** ::\n\n closing volume\n Symbol DataType BarSize TickerTime \n AMZN TRADES 1d 2016-07-21 00:00:00-04:00 749.22 27917\n 2016-07-22 00:00:00-04:00 738.87 36662\n 2016-07-23 00:00:00-04:00 727.23 8766\n FB TRADES 1m 2016-07-25 09:40:00-04:00 120.47 579638\n 2016-07-25 09:41:00-04:00 120.82 192476\n 5m 2016-07-21 09:30:00-04:00 120.05 234242\n 2016-07-21 09:35:00-04:00 120.32 410842\n GS TRADES 5m 2016-07-12 13:35:00-04:00 140.05 344428\n 2016-07-12 14:20:00-04:00 141.34 -1 \n\n\nReferences\n----------\n* `Interactive Brokers API Documentation`_\n* `Interactive Brokers API User Group`_\n\n\nChangelog\n---------\n\nVersion 1.0.0\n^^^^^^^^^^^^^^^\n* Migrated to native Python IB API.\n* Asynchronous operations based on asyncio and aio-libs.\n* New structures and features.\n* Added documentation and test cases.\n\nVersion 0.1.0 (Deprecated)\n^^^^^^^^^^^^^^^^^^^^^^^^^^\n* This experimental version was developed based on IB API v9.72 or older, using swigibpy v0.5.0.\n\n\n.. |PyVersion| image:: https://img.shields.io/badge/python-3.6+-blue.svg\n.. |PyPiVersion| image:: https://badge.fury.io/py/ibstract.svg\n :target: https://badge.fury.io/py/ibstract\n.. |License| image:: https://img.shields.io/github/license/mashape/apistatus.svg\n :target: https://github.com/jesseliu0/ibstract/blob/master/LICENSE\n.. |Status| image:: https://img.shields.io/badge/status-alpha-orange.svg\n\n.. _`Historical data operations example notebook`: http://nbviewer.jupyter.org/github/jesseliu0/ibstract/blob/master/examples/example_histdata.ipynb\n.. _`MarketDataBlock class example notebook`: http://nbviewer.jupyter.org/github/jesseliu0/ibstract/blob/master/examples/example_MarketDataBlock.ipynb\n.. _`IB class example notebook`: http://nbviewer.jupyter.org/github/jesseliu0/ibstract/blob/master/examples/example_brokers.ipynb\n\n.. _`Interactive Brokers API`: https://interactivebrokers.github.io\n.. _`IB gateway latest`: https://www.interactivebrokers.com/en/index.php?f=16454\n.. _`Interactive Brokers API Documentation`: http://interactivebrokers.github.io/tws-api/\n.. _`Interactive Brokers API User Group`: https://groups.io/g/twsapi/topics\n\n.. _Python: https://www.python.org\n.. _Anaconda: https://www.anaconda.com/download/\n.. _asyncio: https://docs.python.org/3/library/asyncio.html\n.. _aio-libs: https://github.com/aio-libs\n.. _pandas: http://pandas.pydata.org/\n.. _`ib_insync`: https://github.com/erdewit/ib_insync\n.. _sqlalchemy: http://www.sqlalchemy.org\n.. _aiomysql: https://github.com/aio-libs/aiomysql\n.. _pytz: https://github.com/newvem/pytz\n.. _tzlocal: https://github.com/regebro/tzlocal", "description_content_type": null, "docs_url": null, "download_url": "https://pypi.python.org/pypi/ibstract", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jesseliu0/ibstract", "keywords": "ibapi asyncio interactive brokers async algorithmicquantitative trading finance", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ibstract", "package_url": "https://pypi.org/project/ibstract/", "platform": "POSIX", "project_url": "https://pypi.org/project/ibstract/", "project_urls": { "Download": "https://pypi.python.org/pypi/ibstract", "Homepage": "https://github.com/jesseliu0/ibstract" }, "release_url": "https://pypi.org/project/ibstract/1.0.0a2/", "requires_dist": null, "requires_python": ">=3.6.0", "summary": "Asynchronous financial trading data management", "version": "1.0.0a2" }, "last_serial": 3221362, "releases": { "1.0.0a2": [ { "comment_text": "", "digests": { "md5": "b3a6f5e6497c3bafc7cad78ea8fd2360", "sha256": "a40b994f76595ee63e2d4a9c09df2aeea7b2b0c7c5adb71fcaf2d9e274e0b30f" }, "downloads": -1, "filename": "ibstract-1.0.0a2-py3-none-any.whl", "has_sig": true, "md5_digest": "b3a6f5e6497c3bafc7cad78ea8fd2360", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 59948, "upload_time": "2017-10-03T07:41:46", "url": "https://files.pythonhosted.org/packages/a7/43/c175008d19a488d61d1f169df563205791a49a160e6aabaffa9e938b76c7/ibstract-1.0.0a2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "81943ccecdb28d4e20fdd94efbded05b", "sha256": "6760084a609afae478c365900e35b992b791ee60b754830341d35d6f8920028c" }, "downloads": -1, "filename": "ibstract-1.0.0a2.tar.gz", "has_sig": true, "md5_digest": "81943ccecdb28d4e20fdd94efbded05b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 57444, "upload_time": "2017-10-03T07:41:21", "url": "https://files.pythonhosted.org/packages/45/f1/19a0e4d9a02de0be8cf4af865f280802623beaf5d3a1f05f0d9a788f7e8b/ibstract-1.0.0a2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b3a6f5e6497c3bafc7cad78ea8fd2360", "sha256": "a40b994f76595ee63e2d4a9c09df2aeea7b2b0c7c5adb71fcaf2d9e274e0b30f" }, "downloads": -1, "filename": "ibstract-1.0.0a2-py3-none-any.whl", "has_sig": true, "md5_digest": "b3a6f5e6497c3bafc7cad78ea8fd2360", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 59948, "upload_time": "2017-10-03T07:41:46", "url": "https://files.pythonhosted.org/packages/a7/43/c175008d19a488d61d1f169df563205791a49a160e6aabaffa9e938b76c7/ibstract-1.0.0a2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "81943ccecdb28d4e20fdd94efbded05b", "sha256": "6760084a609afae478c365900e35b992b791ee60b754830341d35d6f8920028c" }, "downloads": -1, "filename": "ibstract-1.0.0a2.tar.gz", "has_sig": true, "md5_digest": "81943ccecdb28d4e20fdd94efbded05b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 57444, "upload_time": "2017-10-03T07:41:21", "url": "https://files.pythonhosted.org/packages/45/f1/19a0e4d9a02de0be8cf4af865f280802623beaf5d3a1f05f0d9a788f7e8b/ibstract-1.0.0a2.tar.gz" } ] }