Name | kraky JSON |
Version |
2023.8.17
JSON |
| download |
home_page | |
Summary | Python client for Kraken API REST and Kraken Websockets API using httpx and websockets. Supports both sync and async for API REST. |
upload_time | 2023-08-17 12:00:54 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | MIT License Copyright (c) 2021 Kevin Messer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
asyncio
httpx
kraken
websockets
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Kraky
Python client for Kraken API REST and Kraken Websockets API using httpx and websockets.
Supports both sync and async for API REST.
## Disclaimer
This software is for educational purposes only. Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
Always start by running a trading bot in Dry-run and do not engage money before you understand how it works and what profit/loss you should expect.
We strongly recommend you to have coding and Python knowledge. Do not hesitate to read the source code and understand the mechanism of this library.
## Installation
pip install kraky
## Docs
https://kraky.readthedocs.io/en/latest/
## Usage
### CLI
Kraky provides a CLI that matches the API function names and args.
You can use it like the following:
```bash
kraky get_ohlc_data pair=XBTUSD interval=240
```
You can replace get_ohlc_data by any kraky API function and pair=XBTUSD or interval=240 by any function argument.
Please respect the format key=value.
It also supports .env files so you can also create a .env file with your api_key and secret and kraky will pick them up.
Example:
```bash
KRAKEN_API_KEY=""
KRAKEN_SECRET=""
```
### Sync REST API
```python
from kraky import KrakyApiClient
def get_web_sockets_token():
kraken_api_key = ""
kraken_secret = ""
kraky_api_client = KrakyApiClient(
api_key=kraken_api_key, secret=kraken_secret
)
ws_token = kraky_api_client.get_web_sockets_token()
return ws_token
get_web_sockets_token()
```
### Async REST API
```python
from kraky import KrakyApiAsyncClient
async def get_web_sockets_token():
kraken_api_key = ""
kraken_secret = ""
kraky_api_client = KrakyApiAsyncClient(
api_key=kraken_api_key, secret=kraken_secret
)
ws_token = await kraky_api_client.get_web_sockets_token()
return ws_token
asyncio.run(get_web_sockets_token)
```
### Websocket
```python
import asyncio
from kraky import KrakyApiAsyncClient, KrakyWsClient
async def get_web_sockets_token():
kraken_api_key = ""
kraken_secret = ""
kraky_api_client = KrakyApiAsyncClient(
api_key=kraken_api_key, secret=kraken_secret
)
ws_token = await kraky_api_client.get_web_sockets_token()
return ws_token
async def public_handler(response):
print(response)
async def private_handler(response):
print(response)
async def main():
interval = 30
ws_pairs = ["XBT/USD", "ETH/USD"]
ws_token = await get_web_sockets_token()
kraky_public_ws_client = KrakyWsClient("production")
kraky_private_ws_client = KrakyWsClient("production-auth")
asyncio.create_task(
kraky_public_ws_client.connect(public_handler, connection_name="public")
)
asyncio.create_task(
kraky_private_ws_client.connect(private_handler, connection_name="private")
)
await kraky_public_ws_client.subscribe(
{"name": "ohlc", "interval": interval},
ws_pairs,
connection_name="public",
)
await kraky_private_ws_client.subscribe(
{
"interval": interval,
"token": ws_token,
"name": "openOrders",
},
connection_name="private",
)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
```
## Compatibility
- Python 3.8 and above
## Licence
MIT License
Raw data
{
"_id": null,
"home_page": "",
"name": "kraky",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "asyncio,httpx,kraken,websockets",
"author": "",
"author_email": "Atem18 <contact@atemlire.io>",
"download_url": "https://files.pythonhosted.org/packages/10/c3/a4c4cc458c539de36b027f495be5b03ed00f2acc28b909c5c676796df33a/kraky-2023.8.17.tar.gz",
"platform": null,
"description": "# Kraky\nPython client for Kraken API REST and Kraken Websockets API using httpx and websockets.\nSupports both sync and async for API REST.\n\n## Disclaimer\nThis software is for educational purposes only. Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.\n\nAlways start by running a trading bot in Dry-run and do not engage money before you understand how it works and what profit/loss you should expect.\n\nWe strongly recommend you to have coding and Python knowledge. Do not hesitate to read the source code and understand the mechanism of this library.\n\n## Installation \n pip install kraky\n\n## Docs\n\n https://kraky.readthedocs.io/en/latest/\n\n## Usage\n\n### CLI\n\nKraky provides a CLI that matches the API function names and args.\n\nYou can use it like the following:\n\n```bash\nkraky get_ohlc_data pair=XBTUSD interval=240\n```\n\nYou can replace get_ohlc_data by any kraky API function and pair=XBTUSD or interval=240 by any function argument.\nPlease respect the format key=value.\n\nIt also supports .env files so you can also create a .env file with your api_key and secret and kraky will pick them up.\n\nExample:\n```bash\nKRAKEN_API_KEY=\"\"\nKRAKEN_SECRET=\"\"\n```\n\n### Sync REST API\n```python\nfrom kraky import KrakyApiClient\n\n\ndef get_web_sockets_token():\n kraken_api_key = \"\"\n kraken_secret = \"\"\n kraky_api_client = KrakyApiClient(\n api_key=kraken_api_key, secret=kraken_secret\n )\n\n ws_token = kraky_api_client.get_web_sockets_token()\n return ws_token\n\nget_web_sockets_token()\n```\n\n### Async REST API\n```python\nfrom kraky import KrakyApiAsyncClient\n\n\nasync def get_web_sockets_token():\n kraken_api_key = \"\"\n kraken_secret = \"\"\n kraky_api_client = KrakyApiAsyncClient(\n api_key=kraken_api_key, secret=kraken_secret\n )\n\n ws_token = await kraky_api_client.get_web_sockets_token()\n return ws_token\n\nasyncio.run(get_web_sockets_token)\n```\n\n### Websocket\n\n```python\nimport asyncio\nfrom kraky import KrakyApiAsyncClient, KrakyWsClient\n\n\nasync def get_web_sockets_token():\n kraken_api_key = \"\"\n kraken_secret = \"\"\n kraky_api_client = KrakyApiAsyncClient(\n api_key=kraken_api_key, secret=kraken_secret\n )\n\n ws_token = await kraky_api_client.get_web_sockets_token()\n return ws_token\n\n\nasync def public_handler(response):\n print(response)\n\n\nasync def private_handler(response):\n print(response)\n\n\nasync def main():\n\n interval = 30\n\n ws_pairs = [\"XBT/USD\", \"ETH/USD\"]\n\n ws_token = await get_web_sockets_token()\n\n kraky_public_ws_client = KrakyWsClient(\"production\")\n kraky_private_ws_client = KrakyWsClient(\"production-auth\")\n\n asyncio.create_task(\n kraky_public_ws_client.connect(public_handler, connection_name=\"public\")\n )\n\n asyncio.create_task(\n kraky_private_ws_client.connect(private_handler, connection_name=\"private\")\n )\n\n await kraky_public_ws_client.subscribe(\n {\"name\": \"ohlc\", \"interval\": interval},\n ws_pairs,\n connection_name=\"public\",\n )\n\n await kraky_private_ws_client.subscribe(\n {\n \"interval\": interval,\n \"token\": ws_token,\n \"name\": \"openOrders\",\n },\n connection_name=\"private\",\n )\n\n\nif __name__ == \"__main__\":\n loop = asyncio.get_event_loop()\n loop.create_task(main())\n loop.run_forever()\n\n```\n\n## Compatibility\n\n- Python 3.8 and above\n\n## Licence\n\nMIT License\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2021 Kevin Messer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Python client for Kraken API REST and Kraken Websockets API using httpx and websockets. Supports both sync and async for API REST.",
"version": "2023.8.17",
"project_urls": null,
"split_keywords": [
"asyncio",
"httpx",
"kraken",
"websockets"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f9e2a77e3d5d2210b4b53d3c12419218b8a639d63666f947b546f3a17e9dbf12",
"md5": "71e856fa349ce354c10c3ee0479ec0f7",
"sha256": "e47c35034794c72635e3c4d5e48e653e0b53bd9231b5b689a3c90d6055273bc5"
},
"downloads": -1,
"filename": "kraky-2023.8.17-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "71e856fa349ce354c10c3ee0479ec0f7",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 13434,
"upload_time": "2023-08-17T12:00:53",
"upload_time_iso_8601": "2023-08-17T12:00:53.015378Z",
"url": "https://files.pythonhosted.org/packages/f9/e2/a77e3d5d2210b4b53d3c12419218b8a639d63666f947b546f3a17e9dbf12/kraky-2023.8.17-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "10c3a4c4cc458c539de36b027f495be5b03ed00f2acc28b909c5c676796df33a",
"md5": "78194c67cafdb9943b45f00f807cb56c",
"sha256": "f2ef894e2fc86a4011345b9156323077e0161d5e54f6900de70e92a345ab286d"
},
"downloads": -1,
"filename": "kraky-2023.8.17.tar.gz",
"has_sig": false,
"md5_digest": "78194c67cafdb9943b45f00f807cb56c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18955,
"upload_time": "2023-08-17T12:00:54",
"upload_time_iso_8601": "2023-08-17T12:00:54.621430Z",
"url": "https://files.pythonhosted.org/packages/10/c3/a4c4cc458c539de36b027f495be5b03ed00f2acc28b909c5c676796df33a/kraky-2023.8.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-17 12:00:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "kraky"
}