use crate::utils::de_float_from_str;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Debug)]
pub struct RestApi<T> {
pub code: String,
pub msg: String,
pub data: Vec<T>,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccountBalance {
adj_eq: String,
borrow_froz: String,
details: Vec<AccountBalanceDetail>,
imr: String,
iso_eq: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccountBalanceDetail {
avail_bal: String,
avail_eq: String,
borrow_froz: String,
cash_bal: String,
ccy: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccountPositions {
pub mgn_mode: String, pub pos_side: String, #[serde(deserialize_with = "de_float_from_str")]
pub pos: f32,
#[serde(deserialize_with = "de_float_from_str")]
pub avail_pos: f32,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccountPositionsHistory {
pub inst_type: String, pub inst_id: String, pub mgn_mode: String, #[serde(rename = "type")]
pub ptype: String, #[serde(deserialize_with = "de_float_from_str")]
pub pnl: f32, }
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccountSetLeverage {
pub lever: String,
pub mgn_mode: String,
pub inst_id: String,
pub pos_side: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MarketTickers {
pub inst_type: String,
pub inst_id: String,
pub last: String,
#[serde(deserialize_with = "de_float_from_str")]
pub ask_px: f32,
pub ask_sz: String,
#[serde(deserialize_with = "de_float_from_str")]
pub bid_px: f32,
pub bid_sz: String,
pub open24h: String,
pub high24h: String,
pub low24h: String,
pub vol_ccy24h: String,
pub vol24h: String,
pub sod_utc0: String,
pub sod_utc8: String,
pub ts: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MarketTicker {
pub inst_type: String,
pub inst_id: String,
pub last: String,
#[serde(deserialize_with = "de_float_from_str")]
pub ask_px: f32,
pub ask_sz: String,
#[serde(deserialize_with = "de_float_from_str")]
pub bid_px: f32,
pub bid_sz: String,
pub open24h: String,
pub high24h: String,
pub low24h: String,
pub vol_ccy24h: String,
pub vol24h: String,
pub sod_utc0: String,
pub sod_utc8: String,
pub ts: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MarketBooks {
pub asks: Vec<MarketBooksItemData>,
pub bids: Vec<MarketBooksItemData>,
pub ts: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MarketBooksItemData {
#[serde(deserialize_with = "de_float_from_str")]
pub price: f32,
#[serde(deserialize_with = "de_float_from_str")]
pub sz: f32,
#[serde(deserialize_with = "de_float_from_str")]
pub ignore: f32,
#[serde(deserialize_with = "de_float_from_str")]
pub count: f32,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeOrdersPending {
pub inst_type: String,
pub inst_id: String,
pub tgt_ccy: String,
pub ccy: String,
pub ord_id: String,
pub cl_ord_id: String,
pub tag: String,
pub px: String,
pub sz: String,
pub pnl: String,
pub ord_type: String,
pub side: String,
pub pos_side: String,
pub td_mode: String,
pub acc_fill_sz: String,
pub fill_px: String,
pub trade_id: String,
pub fill_sz: String,
pub fill_time: String,
pub avg_px: String,
pub state: String,
pub lever: String,
pub tp_trigger_px: String,
pub tp_trigger_px_type: String,
pub sl_trigger_px: String,
pub sl_trigger_px_type: String,
pub sl_ord_px: String,
pub tp_ord_px: String,
pub fee_ccy: String,
pub fee: String,
pub rebate_ccy: String,
pub source: String,
pub rebate: String,
pub category: String,
pub reduce_only: String,
pub quick_mgn_type: String,
pub u_time: String,
pub c_time: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeOrdersHistory {
pub inst_type: String,
pub inst_id: String,
pub ord_type: String,
pub state: String,
#[serde(deserialize_with = "de_float_from_str")]
pub pnl: f32,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeCancelBatchOrders {
pub ord_id: String, pub cl_ord_id: String, pub s_code: String, pub s_msg: String, }
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeOrder {
pub ord_id: String, pub cl_ord_id: String, pub s_code: String, pub tag: String, pub ts: String, pub s_msg: String, }
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeAmendOrder {
pub ord_id: String, pub cl_ord_id: String, pub req_id: String, pub s_code: String, pub s_msg: String, }
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeOrderGet {
pub state: String, }