Skip to main content

Python SDK with async support for the OKX v5 API

Project description

About

python-okx-async is an unofficial Python wrapper for the OKX exchange v5 API that comes with async support. The wrapper is an extension of the python-okx package, which supports synchronous REST requests and websocket streams.

Installation

To install the package, run

pip install python-okx-async

Quick start

Create an OKX account

Create API credentials

  • Log into your OK account and select API keys in the user menu
  • Click the + Create V5 API key button
  • Follow the instructions to create API credentials (key, passhprase, secret)

Save API credentials

  • If there isn't a .env file in your home directory, create one and make sure it can only be read and written to by you.
touch ~/.env
chmod 600 ~/.env
  • Add the following lines to the .env file, replacing the text to the right of the equal signs with the credentials created above. Note that the credentials should NOT be enclosed in quotation marks.
OKX_API_KEY=<key>
OKX_API_PASSPHRASE=<passphrase>
OKX_API_SECRET=<secret>

API credentials are stored in a .env file for security reasons. It is not advisable to include API credentials directly in source code or to provide them as command line arguments.

Run examples

Import and instantiate the API wrapper class AsyncTradeAPI, which is used for order placement, as follows

import os
from dotenv import load_dotenv
from okx_async.AsyncTrade import AsyncTradeAPI

load_dotenv()

tradeAPI = AsyncTradeAPI(os.getenv("OKX_API_KEY"), os.getenv("OKX_API_SECRET"), os.getenv("OKX_API_PASSPHRASE"), flag="0", debug=False)

The other API classes can be instantiated similarly. Note that by default flag="1", which is the OKX demo environment, and debug=True.

The example_order_book.py script included in the Github repository prints the order book for the XCH-USDT spot market to a depth of 20 levels.

Also make sure to check out the documentation of python-okx, and the additional examples included in that repository.

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

python-okx-async-0.1.0.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

python_okx_async-0.1.0-py3-none-any.whl (53.4 kB view details)

Uploaded Python 3

File details

Details for the file python-okx-async-0.1.0.tar.gz.

File metadata

  • Download URL: python-okx-async-0.1.0.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for python-okx-async-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5eff85f04b54cd45524d3dfe6fdc20f10f35c382d86ea30dd7a526c4d4afd62
MD5 af96452f62ad49f1c94b3db2244f6437
BLAKE2b-256 fb4661876c0000bdf21bb56378f6d18fb58c3822463cbaf6299bcd93bec3baad

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for python_okx_async-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d421b7783f2cc6fe020b352eedace84b153a7a8b33ee9200338e6bacb13fbd10
MD5 aab2622467a4b7e5dca21b7847cd5702
BLAKE2b-256 dc493e14f33aec8f05bdb2a69d16ad04251dbb938f7425d115fb2346396ea826

See more details on using hashes here.

Provenance

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