DCE API Rust Client
A high-performance, asynchronous Rust client library for the Dalian Commodity Exchange (DCE) API.
Ported from the dceapi-go library, this SDK provides a type-safe and efficient way to interact with DCE market data, news, delivery, and trading services.
Features
- Asynchronous: Built on
tokioandreqwestfor modern async/await workflows. - Auto-Token Management: Handles API token acquisition and automatic refresh before expiry.
- Retry Mechanism: Automatically retries requests on token expiration (HTTP 402).
- Compression Support: Supports Gzip, Brotli, and Deflate for faster data transfer.
- Type Safety: Comprehensive Rust models for all request and response structures.
- Error Handling: Detailed error types using
thiserror.
Services
- News: Get articles, announcements, and notices.
- Common: Retrieve current trade dates and variety (commodity) lists.
- Market: Fetch day, night, week, and month quotes, plus contract statistics.
- Trade: Get trading parameters and contract information.
- Settle: Retrieve settlement parameters.
- Member: Access member trading and volume rankings.
- Delivery: Get delivery data, warehouse receipts, costs, and premiums.
Installation
Add this to your Cargo.toml:
[]
= { = "./path/to/dceapi-rs" } # Adjust the path accordingly
= { = "1", = ["full"] }
Quick Start
Set Environment Variables
Basic Usage
use ;
async
Examples
The project includes two examples:
-
Basic: Simple demonstration of trade date and variety list retrieval.
-
Complete: Comprehensive usage of all available services.
Configuration
You can also configure the client manually:
use ;
use Duration;
let config = new
.with_api_key
.with_secret
.with_timeout
.with_lang;
let client = new?;
License
MIT / Apache-2.0