Skip to main content

Python asyncio client for Kraken API REST and Kraken Websockets API using httpx and websockets

Project description

Kraky

Python asyncio client for Kraken API REST and Kraken Websockets API using httpx and websockets

Installation

pip install kraky

Usage

REST

async def get_token():
    kraken_api_key = ""
    kraken_secret = ""
    kraky_api_client = KrakyApiClient(
        api_key=kraken_api_key, secret=kraken_secret
    )

    ws_token = await self.kraky_api_client.get_ws_token()
    return ws_token

Websocket

async def public_handler(self, response):
    print(response)

async def private_handler(self, response):
    print(response)

async def main():

    interval = 30

    ws_pairs = ["XBT/USD", "ETH/USD]

    ws_token = get_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.7 and above

Licence

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kraky-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

kraky-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file kraky-0.1.0.tar.gz.

File metadata

  • Download URL: kraky-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for kraky-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4999a1e0a630f6824d67788422d6ca8bdd4915dc4a62f648816c04daaaade2a4
MD5 408804faa251db1df63f3db6da0653f7
BLAKE2b-256 4027a979ce1845ed46547c105f5664f21f18cff23b499d6b3dd0741c7730038d

See more details on using hashes here.

File details

Details for the file kraky-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kraky-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for kraky-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c2986c0d862bf35aa3535b3601f35c89f79445aa4ec4e7bd89e4ed9304c1308
MD5 48df4fccf6d93c29a8a2087ad1b84839
BLAKE2b-256 5f2f8da145c3c10d03279b4e5cf359ca6517fa0de8b64f57d46f5d5eac513cdb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page