|
|
@@ -1,4 +1,4 @@
|
|
|
-use tracing::info;
|
|
|
+use tracing::{error, info};
|
|
|
use std::collections::BTreeMap;
|
|
|
use std::sync::Arc;
|
|
|
use std::sync::atomic::AtomicBool;
|
|
|
@@ -97,38 +97,34 @@ async fn on_data(core_arc_clone: Arc<Mutex<Core>>,
|
|
|
update_flag_u: &mut Decimal,
|
|
|
multiplier: &Decimal,
|
|
|
run_symbol: &String,
|
|
|
- data: ResponseData) {
|
|
|
- if data.code.as_str() != "200" {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- let mut trace_stack = TraceStack::new(data.time, data.ins);
|
|
|
+ response: ResponseData) {
|
|
|
+ let mut trace_stack = TraceStack::new(response.time, response.ins);
|
|
|
trace_stack.on_after_span_line();
|
|
|
|
|
|
- match data.channel.as_str() {
|
|
|
+ match response.channel.as_str() {
|
|
|
"futures.order_book" => {
|
|
|
trace_stack.set_source("gate_usdt_swap.order_book".to_string());
|
|
|
- let special_depth = standard::handle_info::HandleSwapInfo::handle_special_depth(GateSwap, &data);
|
|
|
+ let special_depth = standard::handle_info::HandleSwapInfo::handle_special_depth(GateSwap, &response);
|
|
|
trace_stack.on_after_format();
|
|
|
|
|
|
- on_special_depth(core_arc_clone, update_flag_u, &data.label, &mut trace_stack, &special_depth).await;
|
|
|
+ on_special_depth(core_arc_clone, update_flag_u, &response.label, &mut trace_stack, &special_depth).await;
|
|
|
}
|
|
|
"futures.book_ticker" => {
|
|
|
trace_stack.set_source("gate_usdt_swap.book_ticker".to_string());
|
|
|
// 将ticker数据转换为模拟深度
|
|
|
- let special_depth = standard::handle_info::HandleSwapInfo::handle_book_ticker(GateSwap, &data);
|
|
|
+ let special_depth = standard::handle_info::HandleSwapInfo::handle_book_ticker(GateSwap, &response);
|
|
|
trace_stack.on_after_format();
|
|
|
|
|
|
- on_special_depth(core_arc_clone, update_flag_u, &data.label, &mut trace_stack, &special_depth).await;
|
|
|
+ on_special_depth(core_arc_clone, update_flag_u, &response.label, &mut trace_stack, &special_depth).await;
|
|
|
}
|
|
|
"futures.balances" => {
|
|
|
- let account = standard::handle_info::HandleSwapInfo::handle_account_info(GateSwap, &data, run_symbol);
|
|
|
+ let account = standard::handle_info::HandleSwapInfo::handle_account_info(GateSwap, &response, run_symbol);
|
|
|
let mut core = core_arc_clone.lock().await;
|
|
|
core.update_equity(account).await;
|
|
|
}
|
|
|
"futures.orders" => {
|
|
|
trace_stack.set_source("gate_swap.orders".to_string());
|
|
|
- let orders = standard::handle_info::HandleSwapInfo::handle_order(GateSwap, data.clone(), multiplier.clone());
|
|
|
+ let orders = standard::handle_info::HandleSwapInfo::handle_order(GateSwap, response.clone(), multiplier.clone());
|
|
|
|
|
|
let mut order_infos:Vec<OrderInfo> = Vec::new();
|
|
|
for order in orders.order {
|
|
|
@@ -156,7 +152,7 @@ async fn on_data(core_arc_clone: Arc<Mutex<Core>>,
|
|
|
}
|
|
|
}
|
|
|
"futures.positions" => {
|
|
|
- let positions = standard::handle_info::HandleSwapInfo::handle_position(GateSwap, &data, multiplier);
|
|
|
+ let positions = standard::handle_info::HandleSwapInfo::handle_position(GateSwap, &response, multiplier);
|
|
|
let mut core = core_arc_clone.lock().await;
|
|
|
core.update_position(positions).await;
|
|
|
}
|
|
|
@@ -179,7 +175,10 @@ async fn on_data(core_arc_clone: Arc<Mutex<Core>>,
|
|
|
// }
|
|
|
// core.max_buy_min_sell_cache.insert(data.label, vec![*max_buy, *min_sell]);
|
|
|
}
|
|
|
- _ => {}
|
|
|
+ _ => {
|
|
|
+ error!("未知推送类型");
|
|
|
+ error!(?response);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|