| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // use std::str::FromStr;
- // use rust_decimal::Decimal;
- // use rust_decimal_macros::dec;
- // use exchanges::response_base::ResponseData;
- // use crate::{MarketOrder, SpecialDepth, SpecialTicker};
- // use crate::exchange::ExchangeEnum;
- // use crate::handle_info::HandleSwapInfo;
- //
- //
- // // 处理特殊Ticker信息
- // pub fn handle_special_ticker(res_data: ResponseData) -> SpecialDepth {
- // let res_data_str = res_data.data;
- // let res_data_json: serde_json::Value = serde_json::from_str(&*res_data_str).unwrap();
- // format_special_ticker(res_data_json, res_data.label)
- // }
- //
- // pub fn format_special_ticker(data: serde_json::Value, label: String) -> SpecialDepth {
- // let bp = Decimal::from_str(data["b"].as_str().unwrap()).unwrap();
- // let bq = Decimal::from_str(data["B"].as_str().unwrap()).unwrap();
- // let ap = Decimal::from_str(data["a"].as_str().unwrap()).unwrap();
- // let aq = Decimal::from_str(data["A"].as_str().unwrap()).unwrap();
- // let mp = (bp + ap) * dec!(0.5);
- // let t = Decimal::from_str(&data["u"].to_string()).unwrap();
- //
- // let ticker_info = SpecialTicker { sell: ap, buy: bp, mid_price: mp, t, create_at: Default::default() };
- // let depth_info = vec![bp, bq, ap, aq];
- // SpecialDepth {
- // name: label,
- // depth: depth_info,
- // ticker: ticker_info,
- // t,
- // create_at: Default::default(),
- // }
- // }
- //
- // // 处理特殊深度数据
- // pub fn handle_special_depth(res_data: ResponseData) -> SpecialDepth {
- // HandleSwapInfo::handle_special_depth(ExchangeEnum::BinanceSpot, res_data)
- // }
- //
- // // 格式化深度信息
- // pub fn format_depth_items(value: serde_json::Value) -> Vec<MarketOrder> {
- // let mut depth_items: Vec<MarketOrder> = vec![];
- // for value in value.as_array().unwrap() {
- // depth_items.push(MarketOrder {
- // price: Decimal::from_str(value[0].as_str().unwrap()).unwrap(),
- // amount: Decimal::from_str(value[1].as_str().unwrap()).unwrap(),
- // })
- // }
- // return depth_items;
- // }
|