|
|
@@ -21,7 +21,9 @@ pub(crate) async fn reference_bybit_swap_run(is_shutdown_arc: Arc<AtomicBool>,
|
|
|
core_arc: Arc<Mutex<Core>>,
|
|
|
name: String,
|
|
|
symbols: Vec<String>,
|
|
|
- is_colo: bool) {
|
|
|
+ is_colo: bool,
|
|
|
+ ref_index: usize
|
|
|
+) {
|
|
|
spawn(async move {
|
|
|
//创建读写通道
|
|
|
let (write_tx, write_rx) = futures_channel::mpsc::unbounded::<Message>();
|
|
|
@@ -29,7 +31,7 @@ pub(crate) async fn reference_bybit_swap_run(is_shutdown_arc: Arc<AtomicBool>,
|
|
|
ws.set_subscribe(vec![
|
|
|
BybitSwapSubscribeType::PuTrade,
|
|
|
BybitSwapSubscribeType::PuOrderBook1,
|
|
|
- BybitSwapSubscribeType::PuKline("1".to_string()),
|
|
|
+ // BybitSwapSubscribeType::PuKline("1".to_string()),
|
|
|
// BybitSwapSubscribeType::PuTickers
|
|
|
]);
|
|
|
|
|
|
@@ -59,7 +61,7 @@ pub(crate) async fn reference_bybit_swap_run(is_shutdown_arc: Arc<AtomicBool>,
|
|
|
let mut depth_asks = depth_asks.lock().await;
|
|
|
let mut depth_bids = depth_bids.lock().await;
|
|
|
// 使用克隆后的 Arc,避免 move 语义
|
|
|
- on_public_data(core_arc_cc, &mul, &data, &mut depth_asks, &mut depth_bids).await
|
|
|
+ on_public_data(core_arc_cc, &mul, &data, &mut depth_asks, &mut depth_bids, ref_index).await
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -78,11 +80,7 @@ pub(crate) async fn bybit_swap_run(is_shutdown_arc: Arc<AtomicBool>,
|
|
|
is_colo: bool,
|
|
|
exchange_params: BTreeMap<String, String>) {
|
|
|
// 参考
|
|
|
- let name_c = name.clone();
|
|
|
- let symbols_c = symbols.clone();
|
|
|
- let is_shutdown_arc_c = is_shutdown_arc.clone();
|
|
|
- let core_arc_c = core_arc.clone();
|
|
|
- reference_bybit_swap_run(is_shutdown_arc_c, core_arc_c, name_c, symbols_c, is_colo).await;
|
|
|
+ reference_bybit_swap_run(is_shutdown_arc.clone(), core_arc.clone(), name.clone(), symbols.clone(), is_colo, 233).await;
|
|
|
|
|
|
// 交易
|
|
|
spawn(async move {
|
|
|
@@ -120,7 +118,7 @@ pub(crate) async fn bybit_swap_run(is_shutdown_arc: Arc<AtomicBool>,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-async fn on_public_data(core_arc: Arc<Mutex<Core>>, mul: &Decimal, response: &ResponseData, depth_asks: &mut Vec<OrderBook>, depth_bids: &mut Vec<OrderBook>) {
|
|
|
+async fn on_public_data(core_arc: Arc<Mutex<Core>>, mul: &Decimal, response: &ResponseData, depth_asks: &mut Vec<OrderBook>, depth_bids: &mut Vec<OrderBook>, ref_index: usize) {
|
|
|
let mut trace_stack = TraceStack::new(response.time, response.ins);
|
|
|
trace_stack.on_after_span_line();
|
|
|
|
|
|
@@ -153,13 +151,13 @@ async fn on_public_data(core_arc: Arc<Mutex<Core>>, mul: &Decimal, response: &Re
|
|
|
};
|
|
|
|
|
|
trace_stack.on_after_format();
|
|
|
- on_depth(core_arc.clone(), &response.label, &mut trace_stack, &result_depth, 0).await;
|
|
|
+ on_depth(core_arc.clone(), &response.label, &mut trace_stack, &result_depth, ref_index).await;
|
|
|
// on_depth(core_arc, &response.label, &mut trace_stack, &result_depth, 1).await;
|
|
|
}
|
|
|
// 全量
|
|
|
else {
|
|
|
trace_stack.on_after_format();
|
|
|
- on_depth(core_arc.clone(), &response.label, &mut trace_stack, &depth, 0).await;
|
|
|
+ on_depth(core_arc.clone(), &response.label, &mut trace_stack, &depth, ref_index).await;
|
|
|
// on_depth(core_arc, &response.label, &mut trace_stack, &depth, 1).await;
|
|
|
|
|
|
depth_asks.clear();
|
|
|
@@ -175,7 +173,7 @@ async fn on_public_data(core_arc: Arc<Mutex<Core>>, mul: &Decimal, response: &Re
|
|
|
trace_stack.on_after_format();
|
|
|
|
|
|
for trade in trades.iter_mut() {
|
|
|
- on_trade(core_arc.clone(), &response.label, &mut trace_stack, &trade, 0).await;
|
|
|
+ on_trade(core_arc.clone(), &response.label, &mut trace_stack, &trade, ref_index).await;
|
|
|
// on_trade(core_arc.clone(), &response.label, &mut trace_stack, &trade, 1).await;
|
|
|
}
|
|
|
}
|