{ "info": { "author": "Constantin De La Roche", "author_email": "constantin@botcrypto.io", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools" ], "description": "aio-kraken-ws [![pipeline status](https://gitlab.com/botcrypto/aio-kraken-ws/badges/master/pipeline.svg)](https://gitlab.com/botcrypto/aio-kraken-ws/commits/master)\n[![coverage report](https://gitlab.com/botcrypto/aio-kraken-ws/badges/master/coverage.svg)](https://gitlab.com/botcrypto/aio-kraken-ws/commits/master)\n[![PEP8](https://img.shields.io/badge/code%20style-pep8-green.svg)](https://www.python.org/dev/peps/pep-0008/)\n===\n\nA module to collect ohlc candles from Kraken using WebSockets that is asyncio friendly! Looking for automated trading tools? [Botcrypto](https://botcrypto.io) may interest you.\n\n## Key features\n\n- Subscribe to kraken data using a single WebSocket.\n- Trigger a callback that is coroutine on each new closed candles from kraken.\n- Easy subscription/unsubscription to datasets, i.e. [(PAIR, Unit Time)].\n- Callback is regulary triggered at each end of the UT intervals, whatever is the number of data received by kraken.\n\n## Getting started\n\n#### Install\n\n`pip install aio-kraken-ws`\n\n#### Usage\n\n```python\n# check tests/learning/log_to_file.py for a complete example\nasync def callback(pair, interval, timestamp, o, h, l, c, v):\n \"\"\" A coroutine handling new candles.\n\n :param str pair:\n :param int interval: time in minutes\n :param int timestamp: candle open timestamp.\n :param float o: open price\n :param float h: high price\n :param float l: low price\n :param float c: close price\n :param float v: volume\n \"\"\"\n with open(\"candles.txt\", \"a+\") as file:\n file.write(f\"[{pair}:{interval}]({timestamp},{o},{h},{l},{c},{v})\\n\")\n\nkraken_ws = await KrakenWs.create(callback)\n# subscribe to some datasets\nawait kraken_ws.subscribe([(\"XBT/EUR\", 1), (\"ETH/EUR\", 5)])\n```\n\nThe `callback` function is called for each dataset at the end of each dataset's unit time interval.\n\nE.g. if subscription start at 4h42.05 to the dataset `(\"XBT/EUR\", 1)`, then callback is triggered at 4h43.00, at 4h44.00, at 4h45.00, etc... For `(\"XBT/EUR\", 60)`, it would be at 5h00.00, at 6h00.00, etc... It's possible to get at most 10ms delay between the exact UT interval ending and the actual datetime of the call.\n\nIf **no** new data were received from Kraken during an interval, the callback is triggered with the latest known close price and v=0, as it's described in the following example.\n\nE.g.\n```python\nawait kraken_ws.subscribe([(\"XBT/EUR\", 1)])\n# time.time() = 120\nawait callback(\"XBT/EUR\", 1, 60, 42.0, 57.0, 19.0, 24.0, 150.0)\n# time.time() = 180\nawait callback(\"XBT/EUR\", 1, 120, 19.0, 24.0, 8.0, 10.0, 13.0)\n# time.time() = 240 : no data received in 60s, i.e. no activity\nawait callback(\"XBT/EUR\", 1, 180, 10.0, 10.0, 10.0, 10.0, 0.0)\n```\n\nAn exception raised by the `callback` will be logged and it wont stop the streams.\n\n\n## Start tests\n\nClone the repo and install requirements\n`pip install -e .[test]`\n\nRun the suite tests\n```\n# unit tests - no call to kraken - fast\npytest --cov=aio_kraken_ws --cov-report= -v tests/unit\n\n# integration tests - actual kraken subscription - slow\npytest --cov=aio_kraken_ws --cov-append -v -n 8 tests/integration\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/botcrypto/aio-kraken-ws", "keywords": "sample kraken websockets", "license": "", "maintainer": "", "maintainer_email": "", "name": "aio-kraken-ws", "package_url": "https://pypi.org/project/aio-kraken-ws/", "platform": "", "project_url": "https://pypi.org/project/aio-kraken-ws/", "project_urls": { "Bug Reports": "https://gitlab.com/botcrypto/aio-kraken-ws/issues", "Funding": "https://botcrypto.io", "Homepage": "https://gitlab.com/botcrypto/aio-kraken-ws", "Source": "https://gitlab.com/botcrypto/aio-kraken-ws" }, "release_url": "https://pypi.org/project/aio-kraken-ws/0.0.1/", "requires_dist": [ "websockets (==8.0.2)", "asynctest (==0.13.0) ; extra == 'test'", "pycodestyle (==2.5.0) ; extra == 'test'", "pylint (==2.3.1) ; extra == 'test'", "pytest (==5.1.2) ; extra == 'test'", "pytest-cov (==2.7.1) ; extra == 'test'", "pytest-xdist (==1.29.0) ; extra == 'test'" ], "requires_python": ">=3", "summary": "Get ohlc from kraken web sockets.", "version": "0.0.1" }, "last_serial": 5986337, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "362ad797fb5f2d13cf5c9634e3494031", "sha256": "724f783277737380b07ee707aad53ad94dde651c9b9486ab7e81714d8d4147a2" }, "downloads": -1, "filename": "aio_kraken_ws-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "362ad797fb5f2d13cf5c9634e3494031", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 12761, "upload_time": "2019-10-16T20:53:22", "url": "https://files.pythonhosted.org/packages/fa/62/3bae7826ba4e5a3fa04ee56630ec75761f1aaf764326cc082e31d910614c/aio_kraken_ws-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6233bf51538de4e7f33b2cd532d993d7", "sha256": "511424fe36cd606385479402f9e634756bd3a4bc77a70eca739999ad84c05bd9" }, "downloads": -1, "filename": "aio-kraken-ws-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6233bf51538de4e7f33b2cd532d993d7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 13877, "upload_time": "2019-10-16T20:53:25", "url": "https://files.pythonhosted.org/packages/23/31/f42a1ea7f7974463b736a734b376827925e59f2a9a5bdd3d48cf0b965ccb/aio-kraken-ws-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "362ad797fb5f2d13cf5c9634e3494031", "sha256": "724f783277737380b07ee707aad53ad94dde651c9b9486ab7e81714d8d4147a2" }, "downloads": -1, "filename": "aio_kraken_ws-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "362ad797fb5f2d13cf5c9634e3494031", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 12761, "upload_time": "2019-10-16T20:53:22", "url": "https://files.pythonhosted.org/packages/fa/62/3bae7826ba4e5a3fa04ee56630ec75761f1aaf764326cc082e31d910614c/aio_kraken_ws-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6233bf51538de4e7f33b2cd532d993d7", "sha256": "511424fe36cd606385479402f9e634756bd3a4bc77a70eca739999ad84c05bd9" }, "downloads": -1, "filename": "aio-kraken-ws-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6233bf51538de4e7f33b2cd532d993d7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 13877, "upload_time": "2019-10-16T20:53:25", "url": "https://files.pythonhosted.org/packages/23/31/f42a1ea7f7974463b736a734b376827925e59f2a9a5bdd3d48cf0b965ccb/aio-kraken-ws-0.0.1.tar.gz" } ] }