1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
use crate::models::{AssetKind, Currency, Request}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Deserialize, Serialize, Clone, Debug)] pub struct GetBookSummaryByCurrencyRequest { pub currency: Currency, #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option<AssetKind>, } impl GetBookSummaryByCurrencyRequest { pub fn all(currency: Currency) -> Self { Self { currency, kind: None, } } pub fn futures(currency: Currency) -> Self { Self { currency, kind: Some(AssetKind::Future), } } pub fn options(currency: Currency) -> Self { Self { currency, kind: Some(AssetKind::Option), } } } #[derive(Deserialize, Serialize, Clone, Debug)] pub struct GetBookSummaryByCurrencyResponse { pub ask_price: Option<f64>, pub base_currency: Currency, pub bid_price: Option<f64>, pub creation_timestamp: u64, pub current_funding: Option<f64>, pub estimated_delivery_price: Option<f64>, pub funding_8h: Option<f64>, pub high: Option<f64>, pub instrument_name: String, pub interest_rate: Option<f64>, pub last: Option<f64>, pub low: Option<f64>, pub mark_price: f64, pub mid_price: Option<f64>, pub open_interest: f64, pub quote_currency: Currency, pub underlying_index: Option<String>, pub underlying_price: Option<f64>, pub volume: f64, pub volume_usd: Option<f64>, } impl Request for GetBookSummaryByCurrencyRequest { const METHOD: &'static str = "public/get_book_summary_by_currency"; type Response = Vec<GetBookSummaryByCurrencyResponse>; } #[derive(Deserialize, Serialize, Clone, Debug)] pub struct GetIndexRequest { pub currency: Currency, } impl GetIndexRequest { pub fn new(currency: Currency) -> Self { Self { currency } } } #[derive(Deserialize, Serialize, Clone, Debug)] pub struct GetIndexResponse { pub edp: f64, #[serde(flatten)] pub indices: HashMap<Currency, f64>, } impl Request for GetIndexRequest { const METHOD: &'static str = "public/get_index"; type Response = GetIndexResponse; } #[derive(Deserialize, Serialize, Clone, Debug, Default)] pub struct GetInstrumentsRequest { pub currency: Currency, #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option<AssetKind>, #[serde(skip_serializing_if = "Option::is_none")] pub expired: Option<bool>, } impl GetInstrumentsRequest { pub fn new(currency: Currency) -> Self { Self { currency, ..Default::default() } } pub fn expired(currency: Currency) -> Self { Self { currency, expired: Some(true), ..Default::default() } } pub fn futures(currency: Currency) -> Self { Self::with_kind(currency, AssetKind::Future) } pub fn options(currency: Currency) -> Self { Self::with_kind(currency, AssetKind::Option) } pub fn with_kind(currency: Currency, kind: AssetKind) -> Self { Self { currency, kind: Some(kind), ..Default::default() } } } #[derive(Deserialize, Serialize, Clone, Debug)] pub struct GetInstrumentsResponse { pub base_currency: String, pub contract_size: f64, pub creation_timestamp: u64, pub expiration_timestamp: u64, pub instrument_name: String, pub is_active: bool, pub kind: AssetKind, pub min_trade_amount: f64, pub option_type: Option<String>, pub quote_currency: Option<Currency>, pub settlement_period: String, pub strike: Option<f64>, pub tick_size: f64, } impl Request for GetInstrumentsRequest { const METHOD: &'static str = "public/get_instruments"; type Response = Vec<GetInstrumentsResponse>; }