Selaa lähdekoodia

bybit rest新增 接口

hl 1 vuosi sitten
vanhempi
commit
d58a7f182f
2 muutettua tiedostoa jossa 27 lisäystä ja 11 poistoa
  1. 17 0
      exchanges/src/bybit_swap_rest.rs
  2. 10 11
      exchanges/tests/bybit_swap_test.rs

+ 17 - 0
exchanges/src/bybit_swap_rest.rs

@@ -247,6 +247,23 @@ impl BybitSwapRest {
         ).await;
         data
     }
+
+    //撤銷所有訂單
+    pub async fn cancel_orders(&mut self, symbol: String) -> ResponseData {
+        let  params = serde_json::json!({
+             "category": "linear",
+             "symbol": symbol,
+         });
+        let data = self.request("POST".to_string(),
+                                "/v5".to_string(),
+                                "/order/cancel-all".to_string(),
+                                true,
+                                params.to_string(),
+        ).await;
+        data
+    }
+
+
     /*******************************************************************************************************/
     /*****************************************工具函数********************************************************/
     /*******************************************************************************************************/

+ 10 - 11
exchanges/tests/bybit_swap_test.rs

@@ -177,7 +177,7 @@ async fn rest_get_tickers_test() {
     let req_data = ret.get_tickers("DOGEUSDT".to_string()).await;
     println!("Bybit--查詢最新行情信息--{:?}", req_data);
 }
-//rest-查詢最新行情信息
+//rest-查詢市場價格K線數據
 #[tokio::test]
 async fn rest_get_kline_test() {
     global::log_utils::init_log_with_trace();
@@ -293,17 +293,16 @@ async fn rest_cancel_order_test() {
     println!("Bybit--撤单--{:?}", req_data);
 }
 
+//rest-撤銷所有訂單
+#[tokio::test]
+async fn rest_cancel_orders_test() {
+    global::log_utils::init_log_with_trace();
+
+    let mut ret = get_rest();
+    let req_data = ret.cancel_orders("DOGEUSDT".to_string()).await;
+    println!("Bybit--撤銷所有訂單--{:?}", req_data);
+}
 
-// //rest-查詢實時委託單
-// #[tokio::test]
-// async fn rest_get_order_test() {
-//     global::log_utils::init_log_with_trace();
-//
-//     let mut ret = get_rest();
-//     let req_data = ret.get_order("BTCUSDT".to_string(),
-//                                  "".to_string(), "".to_string()).await;
-//     println!("Bybit--查詢可交易產品的規格信息--{:?}", req_data);
-// }
 
 
 async fn get_ws(btree_map: Option<BybitSwapLogin>, type_v: BybitSwapWsType) -> BybitSwapWs {