Explorar el Código

bitmart bug ,服务器时间接口

hl hace 1 año
padre
commit
68d415e597
Se han modificado 2 ficheros con 47 adiciones y 24 borrados
  1. 13 0
      exchanges/src/bitmart_swap_rest.rs
  2. 34 24
      exchanges/tests/bitmart_swap_test.rs

+ 13 - 0
exchanges/src/bitmart_swap_rest.rs

@@ -57,6 +57,19 @@ impl BitMartSwapRest {
     /*****************************************rest请求函数********************************************************/
     /*******************************************************************************************************/
 
+    //获取服务器时间
+    pub async fn get_server_time(&mut self ) -> ResponseData {
+        let params = json!({
+        });
+        let data = self.request("GET".to_string(),
+                                "".to_string(),
+                                format!("/system/time"),
+                                false,
+                                params,
+        ).await;
+        data
+    }
+
     //深度
     pub async fn get_depth(&mut self, symbol: String) -> ResponseData {
         let params = json!({

+ 34 - 24
exchanges/tests/bitmart_swap_test.rs

@@ -12,8 +12,6 @@ use exchanges::proxy;
 use exchanges::response_base::ResponseData;
 
 
-
-
 const ACCESS_KEY: &str = "80618e45710812162b04892c7ee5ead4a3cc3e56";
 const SECRET_KEY: &str = "6c6c98544461bbe71db2bca4c6d7fd0021e0ba9efc215f9c6ad41852df9d9df9";
 const API_MEMO: &str = "test001";
@@ -110,6 +108,18 @@ fn get_ws(btree_map: Option<BitMartSwapLogin>, ws_type: BitMartSwapWsType) -> Bi
 }
 
 
+/*获取服务器时间*/
+#[tokio::test]
+async fn rest_get_server_time_test() {
+    global::log_utils::init_log_with_trace();
+    proxy_handle();
+
+    let mut ret = get_rest();
+    let req_data = ret.get_server_time().await;
+    trace!("bitmart--获取服务器时间--{:?}", req_data);
+    trace!("bitmart--获取服务器时间--{}", req_data.data);
+}
+
 /*深度*/
 #[tokio::test]
 async fn rest_get_depth_test() {
@@ -118,8 +128,8 @@ async fn rest_get_depth_test() {
 
     let mut ret = get_rest();
     let req_data = ret.get_depth("BTCUSDT".to_string()).await;
-    trace!("htx--深度--{:?}", req_data);
-    trace!("htx--深度--{}", req_data.data);
+    trace!("bitmart--深度--{:?}", req_data);
+    trace!("bitmart--深度--{}", req_data.data);
 }
 
 
@@ -131,8 +141,8 @@ async fn rest_get_market_test() {
 
     let mut ret = get_rest();
     let req_data = ret.get_market("BTCUSDT".to_string()).await;
-    trace!("htx--合约信息--{:?}", req_data);
-    trace!("htx--合约信息--{}", req_data.data);
+    trace!("bitmart--合约信息--{:?}", req_data);
+    trace!("bitmart--合约信息--{}", req_data.data);
 }
 
 
@@ -146,8 +156,8 @@ async fn rest_get_account_test() {
     let req_data = ret.get_account(json!({
          })
     ).await;
-    trace!("htx--查询合约账户--{:?}", req_data);
-    trace!("htx--查询合约账户--{}", req_data.data);
+    trace!("bitmart--查询合约账户--{:?}", req_data);
+    trace!("bitmart--查询合约账户--{}", req_data.data);
 }
 
 /*用户仓位列表*/
@@ -158,8 +168,8 @@ async fn rest_get_user_position_test() {
 
     let mut ret = get_rest();
     let req_data = ret.get_user_position("BTCUSDT".to_string()).await;
-    trace!("htx--用户仓位列表--{:?}", req_data);
-    trace!("htx--用户仓位列表--{}", req_data.data);
+    trace!("bitmart--用户仓位列表--{:?}", req_data);
+    trace!("bitmart--用户仓位列表--{}", req_data.data);
 }
 
 /*查询合约订单列表*/
@@ -172,8 +182,8 @@ async fn rest_get_orders_test() {
     let req_data = ret.get_orders(json!({
         "symbol":"BTCUSDT"
     })).await;
-    trace!("htx--查询合约订单列表--{:?}", req_data);
-    trace!("htx--查询合约订单列表--{}", req_data.data);
+    trace!("bitmart--查询合约订单列表--{:?}", req_data);
+    trace!("bitmart--查询合约订单列表--{}", req_data.data);
 }
 
 /*查询单个订单详情*/
@@ -187,8 +197,8 @@ async fn rest_get_order_details_test() {
         "symbol":"BTCUSDT",
         "order_id":"123"
     })).await;
-    trace!("htx--查询单个订单详情--{:?}", req_data);
-    trace!("htx--查询单个订单详情--{}", req_data.data);
+    trace!("bitmart--查询单个订单详情--{:?}", req_data);
+    trace!("bitmart--查询单个订单详情--{}", req_data.data);
 }
 /*合约交易下单*/
 #[tokio::test]
@@ -209,8 +219,8 @@ async fn rest_swap_order_test() {
         "lever_rate":1,
 
     })).await;
-    trace!("htx--合约交易下单--{:?}", req_data);
-    trace!("htx--合约交易下单--{}", req_data.data);
+    trace!("bitmart--合约交易下单--{:?}", req_data);
+    trace!("bitmart--合约交易下单--{}", req_data.data);
 }
 
 /*全部撤单*/
@@ -222,8 +232,8 @@ async fn rest_cancel_price_order_test() {
     let mut ret = get_rest();
 
     let req_data = ret.cancel_price_order(json!({  })).await;
-    trace!("htx--全部撤单--{:?}", req_data);
-    trace!("htx--全部撤单--{}", req_data.data);
+    trace!("bitmart--全部撤单--{:?}", req_data);
+    trace!("bitmart--全部撤单--{}", req_data.data);
 }
 
 /*撤单*/
@@ -237,8 +247,8 @@ async fn rest_cancel_order_test() {
     let req_data = ret.cancel_order(json!({
         "order_id":"123"
     })).await;
-    trace!("htx--撤单--{:?}", req_data);
-    trace!("htx--撤单--{}", req_data.data);
+    trace!("bitmart--撤单--{:?}", req_data);
+    trace!("bitmart--撤单--{}", req_data.data);
 }
 
 
@@ -254,8 +264,8 @@ async fn rest_cancel_order_test() {
 //         "margin_account":"USDT",
 //         "position_mode":"dual_side",
 //     })).await;
-//     trace!("htx--设置持仓模式--{:?}", req_data);
-//     trace!("htx--设置持仓模式--{}", req_data.data);
+//     trace!("bitmart--设置持仓模式--{:?}", req_data);
+//     trace!("bitmart--设置持仓模式--{}", req_data.data);
 // }
 
 
@@ -271,8 +281,8 @@ async fn rest_setting_dual_leverage_test() {
         "symbol":"BTCUSDT",
         "open_type":"cross",
     })).await;
-    trace!("htx--设置持仓模式--{:?}", req_data);
-    trace!("htx--设置持仓模式--{}", req_data.data);
+    trace!("bitmart--设置持仓模式--{:?}", req_data);
+    trace!("bitmart--设置持仓模式--{}", req_data.data);
 }