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
# -----------------------------------------------------------
# Enable Limit Orders
# must be called once, ever (only necessary during beta testing)
tx_hash = client.enable_limit_orders()
# 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.3.tar.gz
(14.9 kB
view hashes)
Built Distribution
Close
Hashes for dydx_python-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9627a91dc57331166867f56b4b4cb3d73fdd1a6c57797c18e025cac6cef2b092 |
|
MD5 | 01028cbd8611619c04ce901a098ca29a |
|
BLAKE2b-256 | 55dbe06dff82e693431f04d50e5ff13a9f8931ce2b06186b1fe80e381bf50e5d |