Browse Source

coinex 增加spot账户查询

JiahengHe 1 năm trước cách đây
mục cha
commit
c73d648306
2 tập tin đã thay đổi với 22 bổ sung0 xóa
  1. 12 0
      exchanges/src/coinex_swap_rest.rs
  2. 10 0
      exchanges/tests/coinex_swap_test.rs

+ 12 - 0
exchanges/src/coinex_swap_rest.rs

@@ -87,6 +87,18 @@ impl CoinexSwapRest {
         data
     }
 
+    //查询现货账户
+    pub async fn get_spot_account(&mut self) -> ResponseData {
+        let data = self.request("GET".to_string(),
+                                "/v2".to_string(),
+                                "/assets/spot/balance".to_string(),
+                                true,
+                                None,
+                                None
+        ).await;
+        data
+    }
+
     //指定币对仓位列表
     pub async fn get_position(&mut self, market: String) -> ResponseData {
         let params = serde_json::json!({

+ 10 - 0
exchanges/tests/coinex_swap_test.rs

@@ -113,6 +113,16 @@ async fn rest_account_book_test() {
     println!("coinex--查询合约账户--{:?}", result["ccy"]);
 }
 
+#[tokio::test]
+async fn rest_spot_account_book_test() {
+    let mut ret = get_rest();
+    let req_data = ret.get_spot_account().await;
+    let res_data_json: Value = req_data.data;
+    println!("coinex--查询现货账户--{:?}", res_data_json);
+    let result = res_data_json.as_array().unwrap().get(0).unwrap();
+    println!("coinex--查询现货账户--{:?}", result["ccy"]);
+}
+
 #[tokio::test]
 async fn rest_position_test() {
     let mut ret = get_rest();