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
- If you don't already have an OKX account, register for one on https://www.okx.com/account/register
Create API credentials
- Log into your OK account and select
API keysin the user menu - Click the
+ Create V5 API keybutton - Follow the instructions to create API credentials (key, passhprase, secret)
Save API credentials
- If there isn't a
.envfile 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
.envfile, 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 supply them as command line arguments.
Run examples
Import and instantiate the API wrapper class AsyncTradeAPI, which is used for order placement, as shown below. You may first need to run pip install python-dotenv to install the dotenv package on your system.
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"))
The other REST API classes can be instantiated similarly. Note that async classes are initialized with default arguments flag='1' and debug=True, i.e. async classes are by default in the OKX production environment and not in debug mode.
For a complete example see the example_order_book.py file included in the Github repository. The script 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.
Metadata
Release files for python-okx-async 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-okx-async-0.1.1.tar.gz | 34.4 kB | Without provenance | Details for python-okx-async-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_okx_async-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for python_okx_async-0.1.1-py3-none-any.whl |
Total release size: 87.8 kB
Release files / python-okx-async-0.1.1.tar.gz
| Download URL | python-okx-async-0.1.1.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
377997c3c385e87f5e46978592c8a022d20feec06d7ad728f290dda41fded1dc
|
|
BLAKE2b-256 checksum How to use checksums |
dd3080d973126361edc718fef84dba5ba0b15c9554b2ecb72e1f57f5688a56bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / python_okx_async-0.1.1-py3-none-any.whl
| Download URL | python_okx_async-0.1.1-py3-none-any.whl |
|---|---|
| Size | 53.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eedc2b623bf6d64b823057f0e82397d5a30701cf225c6afde1b3cf5d98b22fde
|
|
BLAKE2b-256 checksum How to use checksums |
77753de4b29f4f699c3d4342b442475facb6b80c6a55c3b6273ae31b4af21b74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for python-okx-async 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.