deribit_http/model/response/order.rs
1/******************************************************************************
2 Author: Joaquín Béjar García
3 Email: jb@taunais.com
4 Date: 15/9/25
5******************************************************************************/
6use crate::model::trade::TradeExecution;
7use pretty_simple_display::{DebugPretty, DisplaySimple};
8use serde::{Deserialize, Serialize};
9use serde_with::skip_serializing_none;
10
11/// Order response
12#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
13pub struct OrderResponse {
14 /// Order information
15 pub order: OrderInfoResponse,
16 /// List of trade executions for the order
17 pub trades: Vec<TradeExecution>,
18}
19
20/// Types of linked orders supported by Deribit
21#[derive(DebugPretty, DisplaySimple, Clone, PartialEq, Eq, Serialize, Deserialize)]
22#[serde(rename_all = "snake_case")]
23pub enum LinkedOrderType {
24 /// One order triggers another (OTO)
25 OneTriggersOther,
26 /// One order cancels another (OCO)
27 OneCancelsOther,
28 /// One order triggers another and cancels a third (OTOCO)
29 OneTriggersOneCancelsOther,
30}
31
32/// Order information
33#[skip_serializing_none]
34#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
35pub struct OrderInfoResponse {
36 /// Order amount
37 pub amount: f64,
38 /// Whether order was placed via API
39 pub api: bool,
40 /// Average execution price
41 pub average_price: Option<f64>,
42 /// Order creation timestamp
43 pub creation_timestamp: u64,
44 /// Order direction (buy/sell)
45 pub direction: String,
46 /// Amount that has been filled
47 pub filled_amount: Option<f64>,
48 /// Instrument name
49 pub instrument_name: String,
50 /// Whether this is a liquidation order
51 pub is_liquidation: bool,
52 /// Order label
53 pub label: String,
54 /// Last update timestamp
55 pub last_update_timestamp: u64,
56 /// Maximum amount to show in order book (optional)
57 pub max_show: Option<f64>,
58 /// Unique order identifier
59 pub order_id: String,
60 /// Current order state
61 pub order_state: String,
62 /// Type of order
63 pub order_type: String,
64 /// Original order type before any modifications
65 pub original_order_type: Option<String>,
66 /// Whether this is a post-only order
67 pub post_only: bool,
68 /// Order price
69 pub price: f64,
70 /// Current profit/loss on the order
71 pub profit_loss: Option<f64>,
72 /// Whether this order only reduces position
73 pub reduce_only: bool,
74 /// Whether this order has been replaced
75 pub replaced: bool,
76 /// Whether this order reduces risk
77 pub risk_reducing: bool,
78 /// Time in force specification
79 pub time_in_force: String,
80 /// Whether the order has been triggered
81 pub triggered: Option<bool>,
82 /// Trigger condition for the order
83 pub trigger: Option<String>,
84 /// USD value of the order
85 pub usd: Option<f64>,
86 /// Whether order was placed via web interface
87 pub web: bool,
88}