bybit/ws/response.rs
1use super::callback::Arg;
2use serde::Deserialize;
3
4/// The pong/subscription response.
5#[derive(Deserialize, Debug)]
6pub struct OpResponse<'a> {
7 pub success: bool,
8 pub ret_msg: &'a str,
9 pub conn_id: &'a str,
10 pub req_id: Option<&'a str>,
11 pub op: &'a str,
12}
13
14/// The option pong response of public channels.
15#[derive(Deserialize, Debug)]
16pub struct OptionPongResponse<'a> {
17 pub args: [&'a str; 1],
18 pub op: &'a str,
19}
20
21/// The data in option subscription response.
22#[derive(Deserialize, Debug)]
23#[serde(rename_all = "camelCase")]
24pub struct OptionSubscriptionData<'a> {
25 #[serde(borrow)]
26 pub fail_topics: Vec<&'a str>,
27 pub success_topics: Vec<&'a str>,
28}
29
30/// The option subscription response.
31#[derive(Deserialize, Debug)]
32pub struct OptionSubscriptionResponse<'a> {
33 pub success: bool,
34 pub conn_id: &'a str,
35 pub data: OptionSubscriptionData<'a>,
36 #[serde(alias = "type")]
37 pub type_: &'a str,
38}
39
40/// The pong response of private channels.
41#[derive(Deserialize, Debug)]
42pub struct PrivatePongResponse<'a> {
43 pub req_id: Option<&'a str>,
44 pub op: &'a str,
45 pub args: [&'a str; 1],
46 pub conn_id: &'a str,
47}
48
49/// The base response which contains common fields of public channels.
50#[derive(Deserialize, Debug)]
51pub struct BasePublicResponse<'a, Data> {
52 /// Topic name.
53 pub topic: &'a str,
54 /// Data type. `snapshot`, `delta`.
55 #[serde(alias = "type")]
56 pub type_: &'a str,
57 /// The timestamp (ms) that the system generates the data.
58 pub ts: u64,
59 /// The data vary on the topic.
60 pub data: Data,
61}
62
63/// The base ticker response which contains common fields.
64#[derive(Deserialize, Debug)]
65pub struct BaseTickerPublicResponse<'a, Data> {
66 /// Topic name.
67 pub topic: &'a str,
68 /// Data type. `snapshot`, `delta`.
69 #[serde(alias = "type")]
70 pub type_: &'a str,
71 /// Cross sequence.
72 pub cs: u64,
73 /// The timestamp (ms) that the system generates the data.
74 pub ts: u64,
75 /// The spot/future ticker data.
76 pub data: Data,
77}
78
79#[derive(Deserialize, Debug)]
80pub struct BaseOptionPublicResponse<'a, Data> {
81 /// message ID
82 pub id: &'a str,
83 /// Topic name.
84 pub topic: &'a str,
85 #[serde(alias = "type")]
86 /// Data type. `snapshot`.
87 pub type_: &'a str,
88 /// The timestamp (ms) that the system generates the data.
89 pub ts: u64,
90 /// The data vary on the topic.
91 pub data: Data,
92}
93
94/// The base response which contains common fields of private channels.
95#[derive(Deserialize, Debug)]
96#[serde(rename_all = "camelCase")]
97pub struct BasePrivateResponse<'a, Data> {
98 /// Message ID.
99 pub id: &'a str,
100 /// Topic name.
101 pub topic: &'a str,
102 /// Data created timestamp (ms).
103 pub creation_time: u64,
104 /// The data vary on the topic.
105 pub data: Data,
106}
107
108/// The (price, size) pair of orderbook.
109#[derive(Deserialize, Debug)]
110pub struct OrderbookItem<'a>(pub &'a str, pub &'a str);
111
112/// The orderbook data.
113#[derive(Deserialize, Debug)]
114pub struct Orderbook<'a> {
115 /// Symbol name.
116 pub s: &'a str,
117 /// Bids. For `snapshot` stream, the element is sorted by price in descending order.
118 pub b: Vec<OrderbookItem<'a>>,
119 /// Asks. For `snapshot` stream, the element is sorted by price in ascending order.
120 pub a: Vec<OrderbookItem<'a>>,
121 /// Update ID. Is a sequence.
122 /// Occasionally, you'll receive "u"=1, which is a snapshot data due to the restart of the service.
123 /// So please overwrite your local orderbook.
124 pub u: u64,
125 /// Cross sequence. Option does not have this field.
126 pub seq: Option<u64>,
127}
128
129/// The trade data.
130#[allow(non_snake_case)]
131#[derive(Deserialize, Debug)]
132pub struct Trade<'a> {
133 /// The timestamp (ms) that the order is filled.
134 pub T: u64,
135 /// Symbol name.
136 pub s: &'a str,
137 /// Side. `Buy`, `Sell`.
138 pub S: &'a str,
139 /// Trade size.
140 pub v: &'a str,
141 /// Trade price.
142 pub p: &'a str,
143 /// Direction of price change. Unique field for future.
144 pub L: Option<&'a str>,
145 /// Trade ID.
146 pub i: &'a str,
147 /// Whether it is a block trade order or not.
148 pub BT: bool,
149}
150
151/// The spot ticker data. (`snapshot` only)
152#[derive(Deserialize, Debug)]
153#[serde(rename_all = "camelCase")]
154pub struct SpotTicker<'a> {
155 /// Symbol name.
156 pub symbol: &'a str,
157 /// Last price.
158 pub last_price: &'a str,
159 /// The highest price in the last 24 hours.
160 pub high_price_24h: &'a str,
161 /// The lowest price in the last 24 hours.
162 pub low_price_24h: &'a str,
163 /// Percentage change of market price relative to 24h.
164 pub prev_price_24h: &'a str,
165 /// Volume for 24h.
166 pub volume_24h: &'a str,
167 /// Turnover for 24h.
168 pub turnover_24h: &'a str,
169 /// Percentage change of market price relative to 24h.
170 pub price_24h_pcnt: &'a str,
171 /// USD index price. It can be empty.
172 pub usd_index_price: &'a str,
173}
174
175/// The option ticker data. (`snapshot` only)
176#[derive(Deserialize, Debug)]
177#[serde(rename_all = "camelCase")]
178pub struct OptionTicker<'a> {
179 /// Symbol name.
180 pub symbol: &'a str,
181 /// Best bid price.
182 pub bid_price: &'a str,
183 /// Best bid size.
184 pub bid_size: &'a str,
185 /// Best bid iv.
186 pub bid_iv: &'a str,
187 /// Best ask price.
188 pub ask_price: &'a str,
189 /// Best ask size.
190 pub ask_size: &'a str,
191 /// Best ask iv.
192 pub ask_iv: &'a str,
193 /// Last price.
194 pub last_price: &'a str,
195 /// The highest price in the last 24 hours.
196 pub high_price_24h: &'a str,
197 /// The lowest price in the last 24 hours.
198 pub low_price_24h: &'a str,
199 /// Market price.
200 pub mark_price: &'a str,
201 /// Index price.
202 pub index_price: &'a str,
203 /// Mark price iv.
204 pub mark_price_iv: &'a str,
205 /// Underlying price.
206 pub underlying_price: &'a str,
207 /// Open interest size.
208 pub open_interest: &'a str,
209 /// Turnover for 24h.
210 pub turnover_24h: &'a str,
211 /// Volume for 24h.
212 pub volume_24h: &'a str,
213 /// Total volume.
214 pub total_volume: &'a str,
215 /// Total turnover.
216 pub total_turnover: &'a str,
217 /// Delta.
218 pub delta: &'a str,
219 /// Gamma.
220 pub gamma: &'a str,
221 /// Vega.
222 pub vega: &'a str,
223 /// Theta.
224 pub theta: &'a str,
225 /// Predicated delivery price. It has value when 30 min before delivery.
226 pub predicted_delivery_price: &'a str,
227 /// The change in the last 24 hous.
228 pub change_24h: &'a str,
229}
230
231/// The future ticker data.
232///
233/// This data utilises the snapshot field and delta field. `None` means field value has not changed.
234#[derive(Deserialize, Debug)]
235#[serde(rename_all = "camelCase")]
236pub struct FutureTicker<'a> {
237 /// Symbol name.
238 pub symbol: &'a str,
239 /// Tick direction.
240 pub tick_direction: Option<&'a str>,
241 /// Percentage change of market price in the last 24 hours.
242 pub price_24h_pcnt: Option<&'a str>,
243 /// Last price.
244 pub last_price: Option<&'a str>,
245 /// Market price 24 hours ago.
246 pub prev_price_24h: Option<&'a str>,
247 /// The highest price in the last 24 hours.
248 pub high_price_24h: Option<&'a str>,
249 /// The lowest price in the last 24 hours.
250 pub low_price_24h: Option<&'a str>,
251 /// Market price an hour ago.
252 pub prev_price_1h: Option<&'a str>,
253 /// Mark price.
254 pub mark_price: Option<&'a str>,
255 /// Index price.
256 pub index_price: Option<&'a str>,
257 /// Open interest size.
258 pub open_interest: Option<&'a str>,
259 /// Open interest value.
260 pub open_interest_value: Option<&'a str>,
261 /// Turnover for 24h.
262 pub turnover_24h: Option<&'a str>,
263 /// Volume for 24h.
264 pub volume_24h: Option<&'a str>,
265 /// Next funding timestamp (ms).
266 pub next_funding_time: Option<&'a str>,
267 /// Funding rate.
268 pub funding_rate: Option<&'a str>,
269 /// Best bid price.
270 pub bid1_price: Option<&'a str>,
271 /// Best bid size.
272 pub bid1_size: Option<&'a str>,
273 /// Best ask price.
274 pub ask1_price: Option<&'a str>,
275 /// Best ask size.
276 pub ask1_size: Option<&'a str>,
277 /// Delivery date time (UTC+0). Unique field for inverse futures.
278 pub delivery_time: Option<&'a str>,
279 /// Delivery fee rate. Unique field for inverse futures.
280 pub basis_rate: Option<&'a str>,
281 /// Delivery fee rate. Unique field for inverse futures.
282 pub delivery_fee_rate: Option<&'a str>,
283 /// Predicated delivery price. Unique field for inverse futures.
284 pub predicted_delivery_price: Option<&'a str>,
285}
286
287/// The (leveraged token) kline data.
288#[derive(Deserialize, Debug)]
289pub struct Kline<'a> {
290 /// The start timestamp (ms)
291 pub start: u64,
292 /// The end timestamp (ms). It is current timestamp if it does not reach to the end time of candle.
293 pub end: u64,
294 /// Kline interval.
295 pub interval: &'a str,
296 /// Open price.
297 pub open: &'a str,
298 /// Close price.
299 pub close: &'a str,
300 /// Highest price.
301 pub high: &'a str,
302 /// Lowest price.
303 pub low: &'a str,
304 /// Trade volume. Leveraged token does not have this field.
305 pub volume: Option<&'a str>,
306 /// Turnover. Leveraged token does not have this field.
307 pub turnover: Option<&'a str>,
308 /// Weather the tick is ended or not.
309 pub confirm: bool,
310 /// The timestamp (ms) of the last matched order in the candle.
311 pub timestamp: u64,
312}
313
314/// The liquidation data.
315#[derive(Deserialize, Debug)]
316#[serde(rename_all = "camelCase")]
317pub struct Liquidation<'a> {
318 /// The updated timestamp (ms).
319 pub updated_time: u64,
320 /// Symbol name.
321 pub symbol: &'a str,
322 /// Order side. `Buy`, `Sell`.
323 pub side: &'a str,
324 /// Executed size.
325 pub size: &'a str,
326 /// Executed price.
327 pub price: &'a str,
328}
329
330// The leveraged token ticker data.
331#[derive(Deserialize, Debug)]
332#[serde(rename_all = "camelCase")]
333pub struct LtTicker<'a> {
334 /// Symbol name.
335 pub symbol: &'a str,
336 /// Market price change percentage in the past 24 hours.
337 pub price_24h_pcnt: &'a str,
338 /// The last price.
339 pub last_price: &'a str,
340 /// Market price 24 hours ago.
341 pub prev_price_24h: &'a str,
342 /// Highest price in the past 24 hours.
343 pub high_price_24h: &'a str,
344 /// Lowest price in the past 24 hours.
345 pub low_price24h: &'a str,
346}
347
348/// The leveraged token nav data.
349#[derive(Deserialize, Debug)]
350#[serde(rename_all = "camelCase")]
351pub struct LtNav<'a> {
352 /// The generated timestamp of nav.
353 pub time: u64,
354 /// Symbol name.
355 pub symbol: &'a str,
356 /// Net asset value.
357 pub nav: &'a str,
358 /// Total position value = basket value * total circulation.
359 pub basket_position: &'a str,
360 /// Leverage.
361 pub leverage: &'a str,
362 /// Basket loan.
363 pub basket_loan: &'a str,
364 /// Circulation.
365 pub circulation: &'a str,
366 /// Basket.
367 pub basket: &'a str,
368}
369
370/// The position data.
371#[derive(Deserialize, Debug)]
372#[serde(rename_all = "camelCase")]
373pub struct Position<'a> {
374 /// Product type.
375 /// - Unified account: does not have this field.
376 /// - Normal account: `linear`, `inverse`.
377 pub category: Option<&'a str>,
378 /// Symbol name.
379 pub symbol: &'a str,
380 /// Position side: `Buy`, `Sell`.
381 pub side: &'a str,
382 /// Position size.
383 pub size: &'a str,
384 /// Used to identify positions in different position modes.
385 /// - 0 one-way mode position.
386 /// - 1 Buy side of hedge-mode position.
387 /// - 2 Sell side of hedge-mode position.
388 pub position_idx: u8,
389 /// Trade mode. 0: cross margin, 1: isolated margin. Always 0 under unified margin account.
390 pub trade_mode: u8,
391 /// Position value.
392 pub position_value: &'a str,
393 /// Risk limit ID.
394 /// _Note_: for portfolio margin mode, it returns 0, which the risk limit value is invalid.
395 pub risk_id: u16,
396 /// Risk limit value corresponding to riskId.
397 /// _Note_: for portfolio margin mode, it returns "", which the risk limit value is invalid.
398 pub risk_limit_value: &'a str,
399 /// Entry price.
400 pub entry_price: &'a str,
401 /// Mark price
402 pub mark_price: &'a str,
403 /// Leverage.
404 /// _Note_: for portfolio margin mode, it returns "", which the leverage value is invalid.
405 pub leverage: &'a str,
406 /// Position margin. Unified account does not have this field.
407 pub position_balance: Option<&'a str>,
408 /// Whether to add margin automatically. 0: false, 1: true. Unified account does not have this field.
409 pub auto_add_margin: Option<u8>,
410 /// Position maintenance margin.
411 /// _Note_: for portfolio margin mode, it returns "".
412 #[serde(alias = "positionMM")]
413 pub position_mm: &'a str,
414 /// Position initial margin.
415 /// _Note_: for portfolio margin mode, it returns "".
416 #[serde(alias = "positionIM")]
417 pub position_im: &'a str,
418 /// Est.liquidation price. "" for Unified trade(spot/linear/options).
419 pub liq_price: &'a str,
420 /// Est.bankruptcy price. "" for Unified trade(spot/linear/options).
421 pub bust_price: &'a str,
422 /// Tp/Sl mode: `Full`, `Partial`.
423 pub tpsl_mode: &'a str,
424 /// Take profit price.
425 pub take_profit: &'a str,
426 /// Stop loss price.
427 pub stop_loss: &'a str,
428 /// Trailing stop.
429 pub trailing_stop: &'a str,
430 /// Unrealised profit and loss.
431 pub unrealised_pnl: &'a str,
432 /// Cumulative realised PnL.
433 pub cum_realised_pnl: &'a str,
434 /// Position status.
435 /// -`Normal`.
436 /// - `Liq`: in the liquidation progress.
437 /// - `Adl`: in the auto-deleverage progress.
438 pub position_status: &'a str,
439 /// Position created timestamp (ms).
440 pub created_time: &'a str,
441 /// Position data updated timestamp (ms).
442 pub updated_time: &'a str,
443}
444
445/// The execution data.
446///
447/// You may have multiple executions for one order in a single message.
448#[derive(Deserialize, Debug)]
449#[serde(rename_all = "camelCase")]
450pub struct Execution<'a> {
451 /// Product type.
452 /// - Unified account: `spot`, `linear`, `option`.
453 /// - Normal account: `linear`, `inverse`.
454 pub category: &'a str,
455 /// Symbol name.
456 pub symbol: &'a str,
457 /// Whether to borrow. Valid for `spot` only.
458 /// - 0 (default): false.
459 /// - 1: true.
460 pub is_leverage: &'a str,
461 /// Order ID.
462 pub order_id: &'a str,
463 /// User customized order ID.
464 pub order_link_id: &'a str,
465 /// Side. `Buy`, `Sell`.
466 pub side: &'a str,
467 /// Order price.
468 pub order_price: &'a str,
469 /// Order qty.
470 pub order_qty: &'a str,
471 /// The remaining qty not executed.
472 pub leaves_qty: &'a str,
473 /// Order type. `Market`, `Limit`.
474 pub order_type: &'a str,
475 /// Stop order type. If the order is not stop order, any type is not returned.
476 pub stop_order_type: &'a str,
477 /// Executed trading fee.
478 pub exec_fee: &'a str,
479 /// Execution ID.
480 pub exec_id: &'a str,
481 /// Execution price.
482 pub exec_price: &'a str,
483 /// Execution qty.
484 pub exec_qty: &'a str,
485 /// Executed type.
486 pub exec_type: &'a str,
487 /// Executed order value.
488 pub exec_value: &'a str,
489 /// Executed timestamp (ms).
490 pub exec_time: &'a str,
491 /// Is maker order. true: maker, false: taker.
492 pub is_maker: bool,
493 /// Trading fee rate.
494 pub fee_rate: &'a str,
495 /// Implied volatility. Valid for option.
496 pub trade_iv: &'a str,
497 /// Implied volatility of mark price. Valid for option.
498 pub mark_iv: &'a str,
499 /// The mark price of the symbol when executing.
500 pub mark_price: &'a str,
501 /// The index price of the symbol when executing.
502 pub index_price: &'a str,
503 /// The underlying price of the symbol when executing. Valid for option.
504 pub underlying_price: &'a str,
505 /// Paradigm block trade ID.
506 pub block_trade_id: &'a str,
507}
508
509/// The order data.
510#[derive(Deserialize, Debug)]
511#[serde(rename_all = "camelCase")]
512pub struct Order<'a> {
513 /// Product type.
514 /// - Unified account: `spot`, `linear`, `option`.
515 /// - Normal account: `linear`, `inverse`.
516 pub category: &'a str,
517 /// Order ID.
518 pub order_id: &'a str,
519 /// User customised order ID.
520 pub order_link_id: &'a str,
521 /// Whether to borrow. `spot` returns this field only. 0 (default): false, 1: true.
522 pub is_leverage: &'a str,
523 /// Block trade ID.
524 pub block_trade_id: &'a str,
525 /// Symbol name.
526 pub symbol: &'a str,
527 /// Order price.
528 pub price: &'a str,
529 /// Order qty.
530 pub qty: &'a str,
531 /// Side. `Buy`, `Sell`.
532 pub side: &'a str,
533 /// Position index. Used to identify positions in different position modes.
534 pub position_idx: u8,
535 /// Order status.
536 pub order_status: &'a str,
537 /// Cancel type.
538 pub cancel_type: &'a str,
539 /// Reject reason.
540 pub reject_reason: &'a str,
541 /// Average filled price. If unfilled, it is "".
542 pub avg_price: &'a str,
543 /// The remaining qty not executed.
544 pub leaves_qty: &'a str,
545 /// The remaining value not executed.
546 pub leaves_value: &'a str,
547 /// Cumulative executed order qty.
548 pub cum_exec_qty: &'a str,
549 /// Cumulative executed order value.
550 pub cum_exec_value: &'a str,
551 /// Cumulative executed trading fee.
552 pub cum_exec_fee: &'a str,
553 /// Time in force.
554 pub time_in_force: &'a str,
555 /// Order type. `Market`, `Limit`.
556 pub order_type: &'a str,
557 /// Stop order type.
558 pub stop_order_type: &'a str,
559 /// Implied volatility.
560 pub order_iv: &'a str,
561 /// Trigger price. If stopOrderType=TrailingStop, it is activate price. Otherwise, it is trigger price.
562 pub trigger_price: &'a str,
563 /// Take profit price.
564 pub take_profit: &'a str,
565 /// Stop loss price.
566 pub stop_loss: &'a str,
567 /// The price type to trigger take profit.
568 pub tp_trigger_by: &'a str,
569 /// The price type to trigger stop loss.
570 pub sl_trigger_by: &'a str,
571 /// Trigger direction. 1: rise, 2: fall.
572 pub trigger_direction: u8,
573 /// The price type of trigger price.
574 pub trigger_by: &'a str,
575 /// Last price when place the order. For linear only.
576 pub last_price_on_created: &'a str,
577 /// Reduce only. `true` means reduce position size.
578 pub reduce_only: bool,
579 /// Close on trigger.
580 pub close_on_trigger: bool,
581 /// Order created timestamp (ms).
582 pub created_time: &'a str,
583 /// Order updated timestamp (ms).
584 pub updated_time: &'a str,
585}
586
587/// The wallet coin data.
588#[derive(Deserialize, Debug)]
589#[serde(rename_all = "camelCase")]
590pub struct WalletCoin<'a> {
591 /// Coin name, such as BTC, ETH, USDT, USDC.
592 pub coin: &'a str,
593 /// Equity of current coin.
594 pub equity: &'a str,
595 /// USD value of current coin. If this coin cannot be collateral, then it is 0.
596 pub usd_value: &'a str,
597 /// Wallet balance of current coin.
598 pub wallet_balance: &'a str,
599 /// Borrow amount of current coin.
600 pub borrow_amount: &'a str,
601 /// Available amount to borrow of current coin.
602 pub available_to_borrow: &'a str,
603 /// Available amount to withdraw of current coin.
604 pub available_to_withdraw: &'a str,
605 /// Accrued interest.
606 pub accrued_interest: &'a str,
607 /// Pre-occupied margin for order. For portfolio margin mode, it returns "".
608 #[serde(alias = "totalOrderIM")]
609 pub total_order_im: &'a str,
610 /// Sum of initial margin of all positions + Pre-occupied liquidation fee. For portfolio margin mode, it returns "".
611 #[serde(alias = "totalPositionIM")]
612 pub total_position_im: &'a str,
613 /// Sum of maintenance margin for all positions. For portfolio margin mode, it returns "".
614 #[serde(alias = "totalPositionMM")]
615 pub total_position_mm: &'a str,
616 /// Unrealised P&L.
617 pub unrealised_pnl: &'a str,
618 /// Cumulative Realised P&L.
619 pub cum_realised_pnl: &'a str,
620}
621
622/// The wallet data.
623#[derive(Deserialize, Debug)]
624#[serde(rename_all = "camelCase")]
625pub struct Wallet<'a> {
626 /// Account type.
627 /// - Unified account: UNIFIED.
628 /// - Normal account: CONTRACT.
629 pub account_type: &'a str,
630 /// Initial Margin Rate: Account Total Initial Margin Base Coin / Account Margin Balance Base Coin.
631 /// In non-unified mode, the field will be returned as an empty string.
632 #[serde(alias = "accountIMRate")]
633 pub account_im_rate: &'a str,
634 /// Maintenance Margin Rate: Account Total Maintenance Margin Base Coin / Account Margin Balance Base Coin.
635 /// In non-unified mode, the field will be returned as an empty string.
636 #[serde(alias = "accountMMRate")]
637 pub account_mm_rate: &'a str,
638 /// Equity of account converted to usd:Account Margin Balance Base Coin + Account Option Value Base Coin.
639 /// In non-unified mode, the field will be returned as an empty string.
640 pub total_equity: &'a str,
641 /// Wallet Balance of account converted to usd:∑ Asset Wallet Balance By USD value of each asset.
642 /// In non-unified mode, the field will be returned as an empty string.
643 pub total_wallet_balance: &'a str,
644 /// Margin Balance of account converted to usd:totalWalletBalance + totalPerpUPL.
645 /// In non-unified mode, the field will be returned as an empty string.
646 pub total_margin_balance: &'a str,
647 /// Available Balance of account converted to usd:Regular mode:totalMarginBalance - totalInitialMargin.
648 /// In non-unified mode, the field will be returned as an empty string.
649 pub total_available_balance: &'a str,
650 /// Unrealised P&L of perpetuals of account converted to usd:∑ Each perp upl by base coin.
651 /// In non-unified mode, the field will be returned as an empty string.
652 #[serde(alias = "totalPerpUPL")]
653 pub total_perp_upl: &'a str,
654 /// Initial Margin of account converted to usd:∑ Asset Total Initial Margin Base Coin.
655 /// In non-unified mode, the field will be returned as an empty string.
656 pub total_initial_margin: &'a str,
657 /// Maintenance Margin of account converted to usd: ∑ Asset Total Maintenance Margin Base Coin.
658 /// In non-unified mode, the field will be returned as an empty string.
659 pub total_maintenance_margin: &'a str,
660 /// Coin.
661 pub coin: Vec<WalletCoin<'a>>,
662}
663
664/// The greeks data.
665#[derive(Deserialize, Debug)]
666#[serde(rename_all = "camelCase")]
667pub struct Greek<'a> {
668 /// Base coin.
669 pub base_coin: &'a str,
670 /// Delta value.
671 pub total_delta: &'a str,
672 /// Gamma value.
673 pub total_gamma: &'a str,
674 /// Vega value.
675 pub total_vega: &'a str,
676 /// Theta value.
677 pub total_theta: &'a str,
678}
679
680#[derive(Deserialize, Debug)]
681#[serde(untagged)]
682pub enum SpotPublicResponse<'a> {
683 #[serde(borrow)]
684 Orderbook(BasePublicResponse<'a, Orderbook<'a>>),
685 Trade(BasePublicResponse<'a, Vec<Trade<'a>>>),
686 Ticker(BaseTickerPublicResponse<'a, SpotTicker<'a>>),
687 Kline(BasePublicResponse<'a, Vec<Kline<'a>>>),
688 LtTicker(BasePublicResponse<'a, LtTicker<'a>>),
689 LtNav(BasePublicResponse<'a, LtNav<'a>>),
690 Op(OpResponse<'a>),
691}
692
693pub struct SpotPublicResponseArg;
694impl Arg for SpotPublicResponseArg {
695 type ValueType<'a> = SpotPublicResponse<'a>;
696}
697
698#[derive(Deserialize, Debug)]
699#[serde(untagged)]
700pub enum FuturePublicResponse<'a> {
701 #[serde(borrow)]
702 Orderbook(BasePublicResponse<'a, Orderbook<'a>>),
703 Trade(BasePublicResponse<'a, Vec<Trade<'a>>>),
704 Ticker(BaseTickerPublicResponse<'a, FutureTicker<'a>>),
705 Kline(BasePublicResponse<'a, Vec<Kline<'a>>>),
706 Liquidation(BasePublicResponse<'a, Liquidation<'a>>),
707 Op(OpResponse<'a>),
708}
709
710pub struct FuturePublicResponseArg;
711impl Arg for FuturePublicResponseArg {
712 type ValueType<'a> = FuturePublicResponse<'a>;
713}
714
715#[derive(Deserialize, Debug)]
716#[serde(untagged)]
717pub enum OptionPublicResponse<'a> {
718 #[serde(borrow)]
719 Orderbook(BaseOptionPublicResponse<'a, Orderbook<'a>>),
720 Trade(BaseOptionPublicResponse<'a, Vec<Trade<'a>>>),
721 Ticker(BaseOptionPublicResponse<'a, OptionTicker<'a>>),
722 Pong(OptionPongResponse<'a>),
723 Subscription(OptionSubscriptionResponse<'a>),
724}
725
726pub struct OptionPublicResponseArg;
727impl Arg for OptionPublicResponseArg {
728 type ValueType<'a> = OptionPublicResponse<'a>;
729}
730
731#[derive(Deserialize, Debug)]
732#[serde(untagged)]
733pub enum PrivateResponse<'a> {
734 #[serde(borrow)]
735 Position(BasePrivateResponse<'a, Vec<Position<'a>>>),
736 Execution(BasePrivateResponse<'a, Vec<Execution<'a>>>),
737 Order(BasePrivateResponse<'a, Vec<Order<'a>>>),
738 Wallet(BasePrivateResponse<'a, Vec<Wallet<'a>>>),
739 Greek(BasePrivateResponse<'a, Vec<Greek<'a>>>),
740 Pong(PrivatePongResponse<'a>),
741 Op(OpResponse<'a>),
742}
743
744pub struct PrivateResponseArg;
745impl Arg for PrivateResponseArg {
746 type ValueType<'a> = PrivateResponse<'a>;
747}