Skip to content

The Derive Protocol Python Client is a powerful and intuitive library designed to interact seamlessly with the Derive Protocol — a decentralized and self-custodial derivatives platform.

Notifications You must be signed in to change notification settings

8ball030/derive_client

 
 

Repository files navigation

Derive.xyz Python Client.

This repo provides a unified interface for the Derive Exchange.

Please checkout the examples directory for usage.

Here is a quick demonstration of the cli functionality.

alt text

Preparing Keys for the Client

To use the client, you will need to generate an API key from the Derive Exchange.

The process involves linking your local signer to the account you want to use programmatically.

Here are the steps:

  1. Generate a local signer using your preferred method. For example, you can use the Open Aea Ledger Ethereum Cli.

    aea generate-key ethereum

    This will generate a new private key in the ethereum_private_key.txt file.

  2. Go to the Derive Exchange and create an account.

  3. Go to the API section and create a new API key.

  4. Register a new Session key with the Public Address of the account your signer generated in step 0.

Once you have the API key, you can use it to interact with the Derive Exchange.

You need;

DERIVE_WALLET - The programtic wallet generated upon account creation. It can be found in the Developer section of the Derive Exchange. SIGNER_PRIVATE_KEY - The private key generated in step 0. SUBACCOOUNT_ID - The subaccount id you want to use for the API key.

derive_client = DeriveClient(
    private_key=TEST_PRIVATE_KEY, 
    env=Environment.TEST, # or Environment.PROD
    wallet=TEST_WALLET,
    subaccount_id = 123456
    )

Orders Operations

You can filter by status, instrument name, and more.

orders = derive_client.orders.list(
    status=OrderStatus.open,
)

Install

pip install derive-client

Dev

Formatting

make fmt

Linting

make lint

Typecheck

make typecheck

Tests

make tests

Codegen

make codegen-all

For convience, all commands can be run with:

make all

Releasing

We can use tbump to automatically bump our versions in preparation of a release.

export new_version=0.1.5
tbump $new_version

The release workflow will then detect that a branch with a v prefix exists and create a release from it.

Additionally, the package will be published to PyPI.

About

The Derive Protocol Python Client is a powerful and intuitive library designed to interact seamlessly with the Derive Protocol — a decentralized and self-custodial derivatives platform.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages