A comprehensive Rust library providing common data structures, utilities, and constants for building Deribit cryptocurrency derivatives trading applications.
This crate serves as the foundation for all Deribit API client implementations, supporting FIX 4.4, HTTP REST, and WebSocket protocols with a unified, type-safe interface.
- 🔧 Complete API Constants: All Deribit API v2.1.1 configuration values
- 📊 Trading Data Models: Orders, positions, market data, and account structures
- 🛡️ Comprehensive Error Handling: 100+ official Deribit error codes with categorization
- 🔐 Cryptographic Utilities: Secure authentication, checksums, and FIX protocol support
- ⚡ Protocol Agnostic: Compatible with FIX, HTTP REST, and WebSocket implementations
- 🧪 Fully Tested: 74 comprehensive unit tests ensuring reliability
- 📚 Complete Documentation: Extensive API documentation with examples
| Protocol | Version | Status |
|---|---|---|
| FIX | 4.4 | ✅ Alpha Support |
| HTTP REST | v2.1.1 | ✅ Alpha Support |
| WebSocket | v2.1.1 | ✅ Alpha Support |
- Bitcoin (BTC) - Perpetuals, Futures, Options
- Ethereum (ETH) - Perpetuals, Futures, Options
- Solana (SOL) - Perpetuals, Futures, Options
- Stablecoins - USDC, USDT, EURR
Add this to your Cargo.toml:
[dependencies]
deribit-base = "0.2"The crate provides a comprehensive prelude module that exports all commonly used types:
- API constants for endpoints, rate limits, and configuration
- Error handling with categorized Deribit error codes
- Trading data structures for orders, positions, and market data
- Utility functions for FIX protocol, authentication, and data formatting
The utils module provides essential functions for FIX protocol integration:
- Secure nonce generation for authentication
- FIX timestamp formatting and parsing
- Message checksum calculation and validation
- Order data conversion to FIX field formats
Complete set of Deribit API configuration values including:
- API endpoints (production & test)
- Rate limits and timeouts
- Supported currencies and instruments
- Order limits and precision settings
- FIX protocol constants
Comprehensive error handling with:
- 100+ official Deribit error codes
- Error categorization and helper methods
- Serde support for JSON serialization
- Standard Error trait implementations
Protocol-agnostic data structures for:
- Trading: Orders, positions, trades, settlements
- Market Data: Tickers, order books, instruments, candles
- Account: Portfolios, balances, transfers, subaccounts
- Configuration: Request/response wrappers, authentication
Utility functions for:
- Cryptographic Operations: Nonce generation, checksums, hashing
- FIX Protocol: Message formatting, field conversions, validation
- Data Processing: Price/quantity formatting, decimal parsing
- Logging: Structured logging setup and configuration
- Authenticated: 20 requests/second
- Unauthenticated: 10 requests/second
- WebSocket Subscriptions: 200 per connection
| Currency | Min Order | Max Order | Price Precision | Amount Precision |
|---|---|---|---|---|
| BTC | 0.0001 | 1,000,000 | 8 decimals | 4 decimals |
| ETH | 0.001 | 10,000,000 | 4 decimals | 3 decimals |
| SOL | 0.1 | 100,000,000 | 4 decimals | 1 decimal |
- Access Token: 8 hours (28,800 seconds)
- Refresh Token: 30 days (2,592,000 seconds)
- Refresh Buffer: 5 minutes before expiration
The crate provides comprehensive error handling with categorized error codes:
- 100+ official Deribit error codes with descriptive names
- Error categorization methods for different error types
- Automatic conversion between numeric codes and enum variants
- Support for authorization, rate limiting, trading, and validation errors
The crate includes comprehensive test coverage with 74 unit tests covering:
- All API constants and their relationships
- Error code conversions and categorization
- Data model serialization and validation
- Utility function correctness and edge cases
- Rust Version: 1.70.0 or higher
- Deribit API: v2.1.1
- FIX Protocol: 4.4
- Platforms: Linux, macOS, Windows
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions to this project! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the project still builds and all tests pass.
- Commit your changes and push your branch to your forked repository.
- Submit a pull request to the main repository.
If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:
- Author: Joaquín Béjar García
- Email: jb@taunais.com
- Telegram: @joaquin_bejar
- Repository: https://github.com/joaquinbejar/deribit-base
- Documentation: https://docs.rs/deribit-base
We appreciate your interest and look forward to your contributions!
Licensed under MIT license
This software is not officially associated with Deribit. Trading financial instruments carries risk, and this library is provided as-is without any guarantees. Always test thoroughly with a demo account before using in a live trading environment.
