Skip to main content

deribit-wrapper

Overview

This Python script provides a comprehensive client for interacting with the Deribit API. It encapsulates functionality for both public and private endpoints, covering market data, account information, trading operations, and more. It supports both the production and test environments, making it suitable for developers at all stages of application development.

Features

  • Environment Switching: Easily switch between the production and test environments.
  • Market Data Retrieval: Access to market data including contract sizes, currencies, ticker information, book summaries, and historical data.
  • Account Management: Functionality to authenticate, retrieve account summaries, positions, and transaction logs.
  • Trading Operations: Support for placing buy and sell orders, including market and limit orders, as well as bulk ordering.
  • Utility Functions: Helper functions to convert timestamps, retrieve specific instruments or markets, and calculate margins.

Installation

Install deribit-wrapper using pip:

pip install deribit-wrapper

Configuration

Instantiate the DeribitClient class with the appropriate parameters:

  • client_id: Your Deribit client ID.
  • client_secret: Your Deribit client secret.
  • env: Which Deribit environment to talk to, 'test' or 'prod'. Defaults to 'prod'.
  • simulated: Defaults to True. Every state-changing trading call — order, market_order, bulk_order, close_position and cancel_orders — returns a simulated result instead of submitting anything. It does not change the environment.

⚠️ simulated is not an environment switch. env alone decides whether you are on production or test, and it defaults to 'prod'. A client left at the defaults reads real production data (balances, positions, transaction logs); only the trading calls above are simulated. To keep everything off production, pass env="test".

Example — production reads, simulated order placement (the defaults):

from deribit_wrapper import DeribitClient

client = DeribitClient(client_id="your_client_id", client_secret="your_client_secret")

Example — fully isolated on the test environment:

client = DeribitClient(
    env="test",
    client_id="your_test_client_id",
    client_secret="your_test_client_secret",
)

Example — placing real orders (production, nothing simulated):

client = DeribitClient(
    client_id="your_client_id",
    client_secret="your_client_secret",
    simulated=False,
)

Usage

Market Data

  • Get Contract Size: get_contract_size(asset)
  • Get Currencies: get_currencies()
  • Get Ticker Information: get_ticker(asset)
  • Get Book Summary by Currency: get_complete_market_book()
  • and more...

Account Information

  • Authenticate: Automatically handled during requests to private endpoints.
  • Get Account Summary: get_account_summary(currency)
  • Get Positions: get_positions(currency, kind)
  • and more...

Trading

  • Place an Order: order(asset, amount, limit=None, label=None, reduce_only=False) — simulated when simulated=True
  • Place a Market Order: market_order(asset, amount, label=None, reduce_only=False) — simulated when simulated=True
  • Bulk Orders: bulk_order(orders, label=None) — simulated when simulated=True
  • Close a Position: close_position(asset, limit=None) — simulated when simulated=True
  • Cancel Orders: cancel_orders(currency=None, kind=None, order_type=None, label=None) — simulated when simulated=True
  • and more...

Examples

  1. Retrieving Market Data:
ticker_info = client.get_ticker("BTC-25JUN21")
print(ticker_info)
  1. Placing a Market Order:
order_response = client.market_order("BTC-25JUN21", 1)
print(order_response)
  1. Getting Account Summary:
account_summary = client.get_account_summary("BTC")
print(account_summary)

Getting Help

If you encounter any issues or have questions about using deribit-wrapper, please create an issue in the GitHub repository.

Contributing

Contributions to deribit-wrapper are welcome! Whether it's bug reports, feature requests, or code contributions, please feel free to make a contribution. For code contributions, please:

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Submit a pull request.

Please ensure your code adheres to the project's coding standards and includes appropriate tests.

License

deribit-wrapper is released under the MIT License. See the LICENSE file for more details.

Metadata

Release files for deribit-wrapper 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deribit-wrapper 0.6.2
File Size Uploaded
deribit_wrapper-0.6.2.tar.gz 33.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deribit-wrapper 0.6.2
File Interpreter ABI Platform
deribit_wrapper-0.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 56.8 kB

Release files / deribit_wrapper-0.6.2.tar.gz

Download URL deribit_wrapper-0.6.2.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
300241d63aa42307576c99a59487b05ec8fb3f06f4930cd0e78b379bb0d60489
BLAKE2b-256 checksum
How to use checksums
03d3d4eb3f321017a5b0d1914bc7307bbe634ad97959effc709498e1ea15929a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / deribit_wrapper-0.6.2-py3-none-any.whl

Download URL deribit_wrapper-0.6.2-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9b0774f1c8a447f8fbe30aaf3a76fe5e6991a916e86ecf9a6f71723f8e25d33
BLAKE2b-256 checksum
How to use checksums
d132bb834eb866d828b8bd7f344e1867cd657cb6da76fc1fbf5a49967510ee72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.6.4

2 release files

0.6.3

2 release files

This release

0.6.2 This release

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page