Skip to content

Quick start with Python

This guide will walk you through the steps to set up and start using the dydx client library.

Below you will use existing example provided with dydx Python client.

Clone the dydx client repo

git clone https://github.com/dydxprotocol/v4-clients.git

Set up virtual environment

It's a good practice to use virtual environment to isolate dependencies for a project. Run the following command to create virtual environment.

python -m venv myenv

Activate the virtual environment:

  • On Windows
myenv\Scripts\ctivate
  • On macOS/Linux
source myenv/bin/activate

After activation, you should see the environment name in the terminal prompt, indicating you are in a virtual environment.

Adding the dydx Dependency

Use the pip install command to add the dependencies. It will install the latest version of the client in the current virtual environment.

pip install dydx-v4-client

For more details on the dydx-v4-client library installation, please check the readme of the python client.

Install poetry

The dydx uses poetry library for dependency management. Install the poetry using pip.

pip install poetry

Install all dependencies

Go to the Python client library.

cd v4-clients/v4-client-py-v2

Install the project dependencies using the following command:

poetry install

Run an example

Now, we can run an example file. Let's run example/accounts_endpoint.py file.

python examples/account_endpoints.py
Now, you can play around with all the available examples. Happy trading!