use rust_decimal::Decimal;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct TickerMessage {
pub channel: String,
#[serde(rename = "type")]
pub msg_type: String,
pub data: Vec<TickerData>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TickerData {
pub symbol: String,
pub bid: Decimal,
pub bid_qty: Decimal,
pub ask: Decimal,
pub ask_qty: Decimal,
pub last: Decimal,
pub volume: Decimal,
pub vwap: Decimal,
pub low: Decimal,
pub high: Decimal,
pub change: Decimal,
pub change_pct: Decimal,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BookMessage {
pub channel: String,
#[serde(rename = "type")]
pub msg_type: String,
pub data: Vec<BookData>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BookData {
pub symbol: String,
#[serde(default)]
pub bids: Vec<BookLevel>,
#[serde(default)]
pub asks: Vec<BookLevel>,
#[serde(default)]
pub checksum: Option<u32>,
#[serde(default)]
pub timestamp: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BookLevel {
pub price: Decimal,
pub qty: Decimal,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TradeMessage {
pub channel: String,
#[serde(rename = "type")]
pub msg_type: String,
pub data: Vec<TradeData>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TradeData {
pub symbol: String,
pub side: String,
pub price: Decimal,
pub qty: Decimal,
pub ord_type: String,
pub trade_id: i64,
pub timestamp: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OhlcMessage {
pub channel: String,
#[serde(rename = "type")]
pub msg_type: String,
pub data: Vec<OhlcData>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OhlcData {
pub symbol: String,
pub open: Decimal,
pub high: Decimal,
pub low: Decimal,
pub close: Decimal,
pub volume: Decimal,
pub vwap: Decimal,
pub trades: u64,
pub interval_begin: String,
pub interval: u32,
pub timestamp: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct InstrumentMessage {
pub channel: String,
#[serde(rename = "type")]
pub msg_type: String,
pub data: InstrumentData,
}
#[derive(Debug, Clone, Deserialize)]
pub struct InstrumentData {
#[serde(default)]
pub assets: Vec<AssetData>,
#[serde(default)]
pub pairs: Vec<PairData>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct AssetData {
pub id: String,
pub status: String,
#[serde(default)]
pub precision: Option<u8>,
#[serde(default)]
pub precision_display: Option<u8>,
#[serde(default)]
pub borrowable: Option<bool>,
#[serde(default)]
pub collateral_value: Option<Decimal>,
#[serde(default)]
pub margin_rate: Option<Decimal>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct PairData {
pub symbol: String,
pub base: String,
pub quote: String,
pub status: String,
#[serde(default)]
pub marginable: Option<bool>,
#[serde(default)]
pub has_index: Option<bool>,
#[serde(default)]
pub price_precision: Option<u8>,
#[serde(default)]
pub qty_precision: Option<u8>,
#[serde(default)]
pub qty_min: Option<Decimal>,
#[serde(default)]
pub cost_min: Option<Decimal>,
}