|
|
@@ -134,41 +134,50 @@ impl HandleSwapInfo {
|
|
|
let mut depth_asks: Vec<MarketOrder>;
|
|
|
let mut depth_bids: Vec<MarketOrder>;
|
|
|
let t: Decimal;
|
|
|
+ let create_at: i64;
|
|
|
match exchange {
|
|
|
ExchangeEnum::BinanceSpot => {
|
|
|
depth_asks = binance_handle::format_depth_items(res_data_json["asks"].clone());
|
|
|
depth_bids = binance_handle::format_depth_items(res_data_json["bids"].clone());
|
|
|
t = Decimal::from_str(&res_data_json["lastUpdateId"].to_string()).unwrap();
|
|
|
+ create_at = 0;
|
|
|
}
|
|
|
ExchangeEnum::BinanceSwap => {
|
|
|
depth_asks = binance_handle::format_depth_items(res_data_json["a"].clone());
|
|
|
depth_bids = binance_handle::format_depth_items(res_data_json["b"].clone());
|
|
|
t = Decimal::from_str(&res_data_json["u"].to_string()).unwrap();
|
|
|
+ create_at = res_data_json["E"].as_i64().unwrap() * 1000;
|
|
|
}
|
|
|
ExchangeEnum::GateSwap => {
|
|
|
depth_asks = gate_handle::format_depth_items(res_data_json["asks"].clone());
|
|
|
depth_bids = gate_handle::format_depth_items(res_data_json["bids"].clone());
|
|
|
+ // todo! 有id可以取 保证与py一致
|
|
|
t = Decimal::from_str(&res_data_json["t"].to_string()).unwrap();
|
|
|
+ create_at = res_data_json["t"].as_i64().unwrap() * 1000;
|
|
|
}
|
|
|
ExchangeEnum::KucoinSwap => {
|
|
|
depth_asks = kucoin_handle::format_depth_items(res_data_json["asks"].clone());
|
|
|
depth_bids = kucoin_handle::format_depth_items(res_data_json["bids"].clone());
|
|
|
t = Decimal::from_str(&res_data_json["sequence"].to_string()).unwrap();
|
|
|
+ create_at = res_data_json["ts"].as_i64().unwrap() * 1000;
|
|
|
}
|
|
|
ExchangeEnum::KucoinSpot => {
|
|
|
depth_asks = kucoin_spot_handle::format_depth_items(res_data_json["asks"].clone());
|
|
|
depth_bids = kucoin_spot_handle::format_depth_items(res_data_json["bids"].clone());
|
|
|
t = Decimal::from_str(&res_data_json["timestamp"].to_string()).unwrap();
|
|
|
+ create_at = 0;
|
|
|
}
|
|
|
ExchangeEnum::OkxSwap => {
|
|
|
depth_asks = okx_handle::format_depth_items(res_data_json[0]["asks"].clone());
|
|
|
depth_bids = okx_handle::format_depth_items(res_data_json[0]["bids"].clone());
|
|
|
t = Decimal::from_str(&res_data_json[0]["seqId"].to_string()).unwrap();
|
|
|
+ create_at = 0;
|
|
|
}
|
|
|
ExchangeEnum::BitgetSpot => {
|
|
|
depth_asks = bitget_spot_handle::format_depth_items(res_data_json[0]["asks"].clone());
|
|
|
depth_bids = bitget_spot_handle::format_depth_items(res_data_json[0]["bids"].clone());
|
|
|
t = Decimal::from_str(res_data_json[0]["ts"].as_str().unwrap()).unwrap();
|
|
|
+ create_at = 0;
|
|
|
}
|
|
|
_ => {
|
|
|
error!("未找到该交易所!handle_special_depth: {:?}",exchange);
|
|
|
@@ -227,13 +236,14 @@ impl HandleSwapInfo {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let ticker_info = SpecialTicker { sell: depth_asks[0].price, buy: depth_bids[0].price, mid_price: mp, t };
|
|
|
+ let ticker_info = SpecialTicker { sell: depth_asks[0].price, buy: depth_bids[0].price, mid_price: mp, t, create_at };
|
|
|
let depth_info = bp.iter().cloned().chain(bv.iter().cloned()).chain(ap.iter().cloned()).chain(av.iter().cloned()).collect();
|
|
|
SpecialDepth {
|
|
|
name: res_data.label,
|
|
|
depth: depth_info,
|
|
|
ticker: ticker_info,
|
|
|
t,
|
|
|
+ create_at,
|
|
|
}
|
|
|
}
|
|
|
}
|