dYdX Python REST API for Limit Orders
Project description
dYdX Python API for Limit Orders
The library is currently tested against Python versions 2.7, 3.4, 3.5, and 3.6
Installation
dydx-python
is available on PyPI. Install with pip
:
pip install dydx-python
Documentation
Check the dYdX developer docs for the API endpoint.
Example Usage
from dydx.client import Client
# create a new client with a private key (string or bytearray)
client = Client(
private_key='0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d',
node='https://parity.expotrading.com'
)
# -----------------------------------------------------------
# API Calls
# -----------------------------------------------------------
# get all trading pairs for dydx
trading_pairs = client.get_pairs()
# ...
# -----------------------------------------------------------
# Ethereum Transactions
# -----------------------------------------------------------
# deposit 10 ETH
# does not require set_allowance
tx_hash = client.deposit(market=0, wei=(10 * 1e18)) # ETH has 18 decimal places
# deposit 100 DAI
tx_hash = client.set_allowance(market=1) # must only be called once, ever
tx_hash = client.deposit(market=1, wei=(100 * 1e18)) # DAI has 18 decimal places
# deposit 100 USDC
tx_hash = client.set_allowance(market=2) # must only be called once, ever
tx_hash = client.deposit(market=2, wei=(100 * 1e6)) # USDC has 6 decimal places
# withdraw 50 USDC
tx_hash = client.withdraw(market=2, wei=(100 * 1e6)) # USDC has 6 decimal places
# withdraw all DAI (including interest)
tx_hash = client.withdraw_to_zero(market=1)
Testing
# Install the requirements
pip install -r requirements.txt
# Run the tests
docker-compose up
tox
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
dydx-python-0.2.1.tar.gz
(12.4 kB
view hashes)
Built Distribution
Close
Hashes for dydx_python-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 997649e249c778532b720e4bccc5d337e19a438358634b84a749d7de4aefda18 |
|
MD5 | 96366f6e62eb7987188addb4698cb067 |
|
BLAKE2b-256 | 02d6873820519fe900d379012e1dffd20cfadc455db99a63d64694ed536cb150 |