SDK for Hyperliquid API trading with Python.
Project description
hyperliquid-python-sdk
Installation
pip install hyperliquid-python-sdk
Configuration
- Set the public key as the
account_address
in examples/config.json. - Set your private key as the
secret_key
in examples/config.json. - See the example of loading the config in examples/example_utils.py
[Optional] Generate a new API key for an API Wallet
Generate and authorize a new API private key on https://app.hyperliquid.xyz/API, and set the API wallet's private key as the secret_key
in examples/config.json. Note that you must still set the public key of the main wallet not the API wallet as the account_address
in examples/config.json
Usage Examples
from hyperliquid.info import Info
from hyperliquid.utils import constants
info = Info(constants.TESTNET_API_URL, skip_ws=True)
user_state = info.user_state("0xcd5051944f780a621ee62e39e493c489668acf4d")
print(user_state)
See examples for more complete examples. You can also checkout the repo and run any of the examples after configuring your private key e.g.
cp examples/config.json.example examples/config.json
vim examples/config.json
python examples/basic_order.py
Getting started with contributing to this repo
-
Download
Poetry
: https://python-poetry.org/. Note that in the install script you might have to setsymlinks=True
invenv.EnvBuilder
. -
Point poetry to correct version of python. For development we require python 3.10 exactly. Some dependencies have issues on 3.11, while older versions don't have correct typing support.
brew install python@3.10 && poetry env use /opt/homebrew/Cellar/python@3.10/3.10.10_1/bin/python3.10
-
Install dependencies:
make install
Makefile usage
CLI commands for faster development.
Install all dependencies
Install requirements:
make install
Codestyle
Install pre-commit hooks which will run isort, black and codestyle on your code:
make pre-commit-install
Automatic formatting uses pyupgrade
, isort
and black
.
make codestyle
# or use synonym
make formatting
Codestyle checks only, without rewriting files:
make check-codestyle
Note:
check-codestyle
usesisort
,black
anddarglint
library
Update all dev libraries to the latest version using one comand
make update-dev-deps
Tests with coverage badges
Run pytest
make test
All linters
make lint
the same as:
make test && make check-codestyle && make mypy && make check-safety
Cleanup
Delete pycache files
make pycache-remove
Remove package build
make build-remove
Delete .DS_STORE files
make dsstore-remove
Remove .mypycache
make mypycache-remove
Or to remove all above run:
make cleanup
Releases
You can see the list of available releases on the GitHub Releases page.
We follow the Semantic Versions specification and use Release Drafter
. As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.
List of labels and corresponding titles
Label | Title in Releases |
---|---|
enhancement , feature |
Features |
bug , refactoring , bugfix , fix |
Fixes & Refactoring |
build , ci , testing |
Build System & CI/CD |
breaking |
Breaking Changes |
documentation |
Documentation |
dependencies |
Dependencies updates |
Building and releasing
Building a new version of the application contains steps:
- Bump the version of your package with
poetry version <version>
. You can pass the new version explicitly, or a rule such asmajor
,minor
, orpatch
. For more details, refer to the Semantic Versions standard. - Make a commit to
GitHub
- Create a
GitHub release
poetry publish --build
License
This project is licensed under the terms of the MIT
license. See LICENSE for more details.
@misc{hyperliquid-python-sdk,
author = {Hyperliquid},
title = {SDK for Hyperliquid API trading with Python.},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/hyperliquid-dex/hyperliquid-python-sdk}}
}
Terms
By using this package you agree to the Terms of Use. See TERMS for more details.
Credits
This project was generated with python-package-template
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hyperliquid_python_sdk-0.8.0.tar.gz
.
File metadata
- Download URL: hyperliquid_python_sdk-0.8.0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.8.9 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 109d76c2ef9d737ab1a37a346d81198c31a14878b80861ec5c79328a7ee037f4 |
|
MD5 | d65483bcf7c4177012248f83e589c6b0 |
|
BLAKE2b-256 | 026f0b9574580018f2b8d139a26de59aef848a4c58d7e63b4b0b2e85f96d957f |
File details
Details for the file hyperliquid_python_sdk-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: hyperliquid_python_sdk-0.8.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.8.9 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 788bc5d3cc464f26ded53675e805bb26c27d172ba31070850bb9e363e728bf0c |
|
MD5 | 62a656791e106260b40fe93f50986f6d |
|
BLAKE2b-256 | e0e996f395744890b559e3c0d8277240895cf7c9424b3c03761e07eb7d7c5b53 |