瀏覽代碼

接口新增,行情,合约信息

hl 1 年之前
父節點
當前提交
703abba327
共有 2 個文件被更改,包括 34 次插入4 次删除
  1. 14 2
      exchanges/src/htx_swap_rest.rs
  2. 20 2
      exchanges/tests/htx_swap_test.rs

+ 14 - 2
exchanges/src/htx_swap_rest.rs

@@ -81,8 +81,9 @@ impl HtxSwapRest {
         ).await;
         data
     }
-    // (【通用】获取聚合行情)
-    pub async fn get_market(&mut self, params: Value) -> ResponseData {
+
+    //行情 (【通用】获取聚合行情)
+    pub async fn get_ticker(&mut self, params: Value) -> ResponseData {
         let data = self.request("GET".to_string(),
                                 "/linear-swap-ex/market".to_string(),
                                 format!("/detail/merged"),
@@ -92,6 +93,17 @@ impl HtxSwapRest {
         data
     }
 
+    //合约信息 (【通用】获取合约信息)
+    pub async fn get_market(&mut self, params: Value) -> ResponseData {
+        let data = self.request("GET".to_string(),
+                                "/linear-swap-api/v1".to_string(),
+                                format!("/swap_contract_info"),
+                                false,
+                                params,
+        ).await;
+        data
+    }
+
     //查询合约账户 (【全仓】获取用户账户信息)
     pub async fn get_account(&mut self,params: Value) -> ResponseData {
 

+ 20 - 2
exchanges/tests/htx_swap_test.rs

@@ -120,8 +120,26 @@ async fn rest_get_server_time_test() {
     trace!("htx--服务器时间戳--{}", req_data.data);
 }
 
+
 /*获取聚合行情*/
 #[tokio::test]
+async fn rest_get_ticker_test() {
+    global::log_utils::init_log_with_trace();
+    proxy_handle();
+
+    let mut ret = get_rest();
+    let req_data = ret.get_ticker(json!({
+            "contract_type":"swap"
+         })
+    ).await;
+    trace!("htx--获取聚合行情--{:?}", req_data);
+    trace!("htx--获取聚合行情--{}", req_data.data);
+}
+
+
+
+/*合约信息*/
+#[tokio::test]
 async fn rest_get_market_test() {
     global::log_utils::init_log_with_trace();
     proxy_handle();
@@ -131,8 +149,8 @@ async fn rest_get_market_test() {
             "contract_code":"BTC-USDT"
          })
     ).await;
-    trace!("htx--获取聚合行情--{:?}", req_data);
-    trace!("htx--获取聚合行情--{}", req_data.data);
+    trace!("htx--合约信息--{:?}", req_data);
+    trace!("htx--合约信息--{}", req_data.data);
 }