deribit_http/model/request/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::order::OrderType;
7use crate::model::response::order::LinkedOrderType;
8use crate::model::trigger::{Trigger, TriggerFillCondition};
9use crate::model::types::TimeInForce;
10use pretty_simple_display::{DebugPretty, DisplaySimple};
11use serde::{Deserialize, Serialize};
12use serde_with::skip_serializing_none;
13
14/// Order request structure for placing orders on Deribit
15#[skip_serializing_none]
16#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
17pub struct OrderRequest {
18 /// Unique order identifier
19 pub order_id: Option<String>,
20 /// Name of the instrument to trade
21 pub instrument_name: String,
22 /// Order amount (for futures and perpetuals)
23 pub amount: Option<f64>,
24 /// Number of contracts (for options)
25 pub contracts: Option<f64>,
26 /// Order type (market, limit, etc.)
27 #[serde(rename = "type")]
28 pub type_: Option<OrderType>,
29 /// User-defined label for the order
30 pub label: Option<String>,
31 /// Limit price for the order
32 pub price: Option<f64>,
33 /// Time in force specification
34 pub time_in_force: Option<TimeInForce>,
35 /// Amount to display in the order book
36 pub display_amount: Option<f64>,
37 /// Whether the order should only be posted (not taken)
38 pub post_only: Option<bool>,
39 /// Whether to reject if the order would be posted only
40 pub reject_post_only: Option<bool>,
41 /// Whether this order only reduces position
42 pub reduce_only: Option<bool>,
43 /// Trigger price for conditional orders
44 pub trigger_price: Option<f64>,
45 /// Trigger offset for conditional orders
46 pub trigger_offset: Option<f64>,
47 /// Trigger type for conditional orders
48 pub trigger: Option<Trigger>,
49 /// Advanced order type (USD or implied volatility)
50 pub advanced: Option<AdvancedOrderType>,
51 /// Market maker protection flag
52 pub mmp: Option<bool>,
53 /// Order validity timestamp (Unix timestamp)
54 pub valid_until: Option<i64>,
55 /// Type of linked order (OTO, OCO, OTOCO)
56 pub linked_order_type: Option<LinkedOrderType>,
57 /// Trigger fill condition for linked orders
58 pub trigger_fill_condition: Option<TriggerFillCondition>,
59 /// Configuration for OTOCO (One-Triggers-One-Cancels-Other) orders
60 pub otoco_config: Option<Vec<String>>,
61}
62
63/// Advanced order type
64#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
65#[serde(rename_all = "lowercase")]
66pub enum AdvancedOrderType {
67 /// USD denomination
68 Usd,
69 /// Implied volatility
70 Implv,
71}