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
/******************************************************************************
Author: Joaquín Béjar García
Email: jb@taunais.com
Date: 15/9/25
******************************************************************************/
use crate::model::trade::TradeExecution;
use pretty_simple_display::{DebugPretty, DisplaySimple};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
/// Order response
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct OrderResponse {
/// Order information
pub order: OrderInfoResponse,
/// List of trade executions for the order
pub trades: Vec<TradeExecution>,
}
/// Types of linked orders supported by Deribit
#[derive(DebugPretty, DisplaySimple, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum LinkedOrderType {
/// One order triggers another (OTO)
OneTriggersOther,
/// One order cancels another (OCO)
OneCancelsOther,
/// One order triggers another and cancels a third (OTOCO)
OneTriggersOneCancelsOther,
}
/// Order information
#[skip_serializing_none]
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct OrderInfoResponse {
/// Order amount
pub amount: f64,
/// Whether order was placed via API
pub api: bool,
/// Average execution price
pub average_price: Option<f64>,
/// Order creation timestamp
pub creation_timestamp: u64,
/// Order direction (buy/sell)
pub direction: String,
/// Amount that has been filled
pub filled_amount: Option<f64>,
/// Instrument name
pub instrument_name: String,
/// Whether this is a liquidation order
pub is_liquidation: bool,
/// Order label
pub label: String,
/// Last update timestamp
pub last_update_timestamp: u64,
/// Maximum amount to show in order book (optional)
pub max_show: Option<f64>,
/// Unique order identifier
pub order_id: String,
/// Current order state
pub order_state: String,
/// Type of order
pub order_type: String,
/// Original order type before any modifications
pub original_order_type: Option<String>,
/// Whether this is a post-only order
pub post_only: bool,
/// Order price
pub price: f64,
/// Current profit/loss on the order
pub profit_loss: Option<f64>,
/// Whether this order only reduces position
pub reduce_only: bool,
/// Whether this order has been replaced
pub replaced: bool,
/// Whether this order reduces risk
pub risk_reducing: bool,
/// Time in force specification
pub time_in_force: String,
/// Whether the order has been triggered
pub triggered: Option<bool>,
/// Trigger condition for the order
pub trigger: Option<String>,
/// USD value of the order
pub usd: Option<f64>,
/// Whether order was placed via web interface
pub web: bool,
}