lighter_rust/models/
order.rs1use super::{OrderStatus, OrderType, Side};
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Order {
7 pub id: String,
8 pub client_order_id: Option<String>,
9 pub symbol: String,
10 pub side: Side,
11 pub order_type: OrderType,
12 pub status: OrderStatus,
13 pub quantity: String,
14 pub price: Option<String>,
15 pub stop_price: Option<String>,
16 pub filled_quantity: String,
17 pub remaining_quantity: String,
18 pub average_fill_price: Option<String>,
19 pub fee: Option<String>,
20 pub time_in_force: TimeInForce,
21 pub created_at: DateTime<Utc>,
22 pub updated_at: DateTime<Utc>,
23 pub expires_at: Option<DateTime<Utc>>,
24}
25
26#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
27#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
28pub enum TimeInForce {
29 Gtc, Ioc, Fok, Day, }
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct CreateOrderRequest {
37 pub symbol: String,
38 pub side: Side,
39 pub order_type: OrderType,
40 pub quantity: String,
41 pub price: Option<String>,
42 pub stop_price: Option<String>,
43 pub client_order_id: Option<String>,
44 pub time_in_force: TimeInForce,
45 pub post_only: Option<bool>,
46 pub reduce_only: Option<bool>,
47 pub signature: String,
48 pub nonce: u64,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct CancelOrderRequest {
53 pub order_id: Option<String>,
54 pub client_order_id: Option<String>,
55 pub symbol: Option<String>,
56 pub signature: String,
57 pub nonce: u64,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct Trade {
62 pub id: String,
63 pub order_id: String,
64 pub symbol: String,
65 pub side: Side,
66 pub quantity: String,
67 pub price: String,
68 pub fee: String,
69 pub fee_asset: String,
70 pub is_maker: bool,
71 pub timestamp: DateTime<Utc>,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct OrderFilter {
76 pub symbol: Option<String>,
77 pub status: Option<OrderStatus>,
78 pub side: Option<Side>,
79 pub order_type: Option<OrderType>,
80 pub start_time: Option<DateTime<Utc>>,
81 pub end_time: Option<DateTime<Utc>>,
82 pub page: Option<u32>,
83 pub limit: Option<u32>,
84}