htx-rs 0.1.1

火币 HTX 现货交易 Rust SDK,支持下单、撤单、查单等主要接口,签名算法兼容官方。
Documentation
//! 现货交易相关数据结构,对应 Python SDK 的主要下单、撤单、查单等接口。
use serde::{Deserialize, Serialize};

/// 订单类型
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderType {
    BuyLimit,
    SellLimit,
    BuyMarket,
    SellMarket,
}

/// 订单状态
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderState {
    Submitted,
    PartialFilled,
    PartialCanceled,
    Filled,
    Canceled,
}

/// 下单请求
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateOrderRequest {
    pub account_id: String,
    pub symbol: String,
    pub order_type: OrderType,
    pub source: String,
    pub amount: f64,
    pub price: Option<f64>,
    pub client_order_id: Option<String>,
}

/// 下单响应
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateOrderResponse {
    pub order_id: String,
}

/// 订单详情
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OrderDetail {
    pub order_id: String,
    pub symbol: String,
    pub account_id: String,
    pub order_type: OrderType,
    pub state: OrderState,
    pub amount: f64,
    pub price: Option<f64>,
    pub filled_amount: Option<f64>,
    pub created_at: Option<u64>,
}

/// 撤单请求
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CancelOrderRequest {
    pub symbol: String,
    pub order_id: String,
}

/// 撤单响应
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CancelOrderResponse {
    pub order_id: String,
    pub status: String,
}

/// 查询订单请求
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetOrderRequest {
    pub order_id: String,
}

/// 查询订单响应
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetOrderResponse {
    pub detail: OrderDetail,
}