1use crate::client::BybitClient;
29use crate::error::Result;
30use crate::types::{CreateOrderRequest, CreateOrderResponse, OrderList};
31
32impl BybitClient {
33 pub async fn create_order(&self, request: &CreateOrderRequest) -> Result<CreateOrderResponse> {
34 let body = serde_json::to_value(request)?;
35 self.post("/v5/order/create", Some(body)).await
36 }
37
38 pub async fn cancel_order(
39 &self,
40 category: &str,
41 order_id: &str,
42 symbol: &str,
43 ) -> Result<serde_json::Value> {
44 let body = serde_json::json!({
45 "category": category,
46 "orderId": order_id,
47 "symbol": symbol,
48 });
49 self.post("/v5/order/cancel", Some(body)).await
50 }
51
52 pub async fn cancel_all_orders(
53 &self,
54 category: &str,
55 symbol: &str,
56 ) -> Result<serde_json::Value> {
57 let body = serde_json::json!({
58 "category": category,
59 "symbol": symbol,
60 });
61 self.post("/v5/order/cancel-all", Some(body)).await
62 }
63
64 pub async fn get_order(&self, category: &str, order_id: &str) -> Result<OrderList> {
65 let query = vec![("category", category), ("orderId", order_id)];
66 self.get("/v5/order/realtime", Some(query)).await
67 }
68
69 pub async fn get_open_orders(&self, category: &str) -> Result<OrderList> {
70 let query = vec![("category", category)];
71 self.get("/v5/order/realtime", Some(query)).await
72 }
73}
74
75#[cfg(test)]
76mod tests {
77 #[test]
78 fn test_trade_module_exists() {}
79}