|
|
@@ -41,7 +41,7 @@ pub async fn run_listener(is_shutdown_arc: Arc<AtomicBool>) {
|
|
|
for symbol_info in symbol_infos {
|
|
|
let ct_val_ccy = symbol_info["ctValCcy"].as_str().unwrap();
|
|
|
let settle_ccy = symbol_info["settleCcy"].as_str().unwrap();
|
|
|
-
|
|
|
+ if settle_ccy != "USDT" { continue; };
|
|
|
let symbol = format!("{}_{}", ct_val_ccy, settle_ccy);
|
|
|
let mul = Decimal::from_str(symbol_info["ctMult"].as_str().unwrap()).unwrap();
|
|
|
mul_map.insert(symbol.clone(), mul);
|
|
|
@@ -49,25 +49,37 @@ pub async fn run_listener(is_shutdown_arc: Arc<AtomicBool>) {
|
|
|
symbols.push(symbol)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
for chunk in symbols.chunks(20) {
|
|
|
- let ws_name = name.to_string();
|
|
|
- let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
|
|
|
- let write_tx_am = Arc::new(Mutex::new(write_tx));
|
|
|
- let symbols_chunk = chunk.iter().cloned().collect::<Vec<String>>();
|
|
|
- let is_shutdown_clone = Arc::clone(&is_shutdown_arc);
|
|
|
+ let bu_ws_name = name.to_string();
|
|
|
+ let (bu_write_tx, bu_write_rx) = futures_channel::mpsc::unbounded();
|
|
|
+ let bu_write_tx_am = Arc::new(Mutex::new(bu_write_tx));
|
|
|
+ let bu_symbols_chunk = chunk.iter().cloned().collect::<Vec<String>>();
|
|
|
+ let bu_is_shutdown_clone = Arc::clone(&is_shutdown_arc);
|
|
|
+ tokio::spawn(async move {
|
|
|
+ let mut ws = OkxSwapWs::new_with_tag(bu_ws_name.clone(), false, None, OkxSwapWsType::Business);
|
|
|
+ ws.set_subscribe(vec![
|
|
|
+ OkxSwapSubscribeType::BuFuturesRecords,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // 建立链接
|
|
|
+ ws.set_symbols(bu_symbols_chunk);
|
|
|
+ ws.ws_connect_async(bu_is_shutdown_clone, data_listener, &bu_write_tx_am, bu_write_rx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
|
|
|
+ });
|
|
|
|
|
|
+ let pub_ws_name = name.to_string();
|
|
|
+ let (pub_write_tx, pub_write_rx) = futures_channel::mpsc::unbounded();
|
|
|
+ let pub_write_tx_am = Arc::new(Mutex::new(pub_write_tx));
|
|
|
+ let pub_symbols_chunk = chunk.iter().cloned().collect::<Vec<String>>();
|
|
|
+ let pub_is_shutdown_clone = Arc::clone(&is_shutdown_arc);
|
|
|
tokio::spawn(async move {
|
|
|
- let mut ws = OkxSwapWs::new_with_tag(ws_name, false, None, OkxSwapWsType::Public);
|
|
|
+ let mut ws = OkxSwapWs::new_with_tag(pub_ws_name.clone(), false, None, OkxSwapWsType::Public);
|
|
|
ws.set_subscribe(vec![
|
|
|
OkxSwapSubscribeType::PuFuturesTrades,
|
|
|
- OkxSwapSubscribeType::PuFuturesRecords,
|
|
|
- // OkxSwapSubscribeType::PuFuturesOrderBook
|
|
|
]);
|
|
|
|
|
|
// 建立链接
|
|
|
- ws.set_symbols(symbols_chunk);
|
|
|
- ws.ws_connect_async(is_shutdown_clone, data_listener, &write_tx_am, write_rx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
|
|
|
+ ws.set_symbols(pub_symbols_chunk);
|
|
|
+ ws.ws_connect_async(pub_is_shutdown_clone, data_listener, &pub_write_tx_am, pub_write_rx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -87,7 +99,6 @@ pub async fn data_listener(response: ResponseData) {
|
|
|
}
|
|
|
// 订单流数据
|
|
|
"futures.trades" => {
|
|
|
- println!("------------------------------- {:?}", response);
|
|
|
let mut trades = ExchangeStructHandler::trades_handle(ExchangeEnum::OkxSwap, &response);
|
|
|
let mul_map = MUL_MAP.lock().await;
|
|
|
|