Metadata-Version: 2.1
Name: dydx-python
Version: 0.2.0
Summary: dYdX Python REST API for Limit Orders
Home-page: https://github.com/dydxprotocol/dydx-python
Author: dYdX Trading Inc.
Author-email: contact@dydx.exchange
License: Apache 2.0
Keywords: dydx exchange rest api defi ethereum eth
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Requires-Dist: requests (==2.22.0)
Requires-Dist: requests-mock (==1.6.0)
Requires-Dist: six (==1.12)
Requires-Dist: web3 (==5.0.0)
Requires-Dist: eth-account (==0.4.0)
Requires-Dist: pytest (<5.0.0,>=4.4.0)
Requires-Dist: tox (==3.13.2)
Requires-Dist: setuptools (==41.0.1)
Requires-Dist: eth-keys

# dydx-python
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](https://pypi.org/project/dydx-python). Install with `pip`:
```
pip install dydx-python
```

## Documentation

Check the [dYdX developer docs](https://docs.dydx.exchange/#/api?id=orderbook) for the API endpoint.

## Example Usage

```python
from dydx-python.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
```


