Browse Source

新增 bingx
ws优化

hl 1 year ago
parent
commit
0e82cd6c7a
1 changed files with 15 additions and 0 deletions
  1. 15 0
      exchanges/src/bingx_swap_ws.rs

+ 15 - 0
exchanges/src/bingx_swap_ws.rs

@@ -5,11 +5,13 @@ use std::time::Duration;
 
 use flate2::read::GzDecoder;
 use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
+use rust_xlsxwriter::IntoExcelData;
 use serde_json::json;
 use serde_json::Value;
 use tokio::sync::Mutex;
 use tokio_tungstenite::tungstenite::{Error, Message};
 use tracing::{error, info, trace};
+use tracing::instrument::WithSubscriber;
 
 use crate::response_base::ResponseData;
 use crate::socket_tool::AbstractWsMode;
@@ -290,6 +292,19 @@ impl BingxSwapWs {
         }else if json_value["code"].as_i64() == Option::from(0){
             res_data.code = 200;
             res_data.data = json_value.clone();
+
+            //订阅数据 甄别
+            let dataType  = json_value["dataType"].as_str().unwrap();
+            if dataType.contains("@depth"){
+                res_data.channel = "futures.order_book".to_string();
+            }else if  dataType.contains("@trade"){
+                res_data.channel = "futures.trades".to_string();
+            }else if dataType.contains("@kline_1m") {
+                res_data.channel = "futures.candlesticks".to_string();
+            }else{
+                res_data.channel = "未知推送数据".to_string();
+            }
+
         }else{
             res_data.code = -1;
             res_data.message = "未知解析".to_string();