|
|
@@ -110,6 +110,14 @@ impl Platform for BinanceSwap {
|
|
|
todo!()
|
|
|
}
|
|
|
|
|
|
+ async fn cancel_order(&self, _symbol: &str, _order_id: &str) -> Result<Order, Error> {
|
|
|
+ todo!()
|
|
|
+ }
|
|
|
+
|
|
|
+ async fn cancel_orders(&self, _symbol: &str) -> Result<Vec<Order>, Error> {
|
|
|
+ todo!()
|
|
|
+ }
|
|
|
+
|
|
|
// 订阅深度信息
|
|
|
// fn subscribe_depth(&self, symbol: &str) {
|
|
|
// let symbol_format = &utils::format_symbol(symbol, "");
|
|
|
@@ -134,80 +142,6 @@ impl Platform for BinanceSwap {
|
|
|
// self.wss.custom_subscribe(vec![symbol_format], 0, 0, get_res_data)
|
|
|
// }
|
|
|
|
|
|
- // 订阅深度信息
|
|
|
- // fn subscribe_special_depth(&self, symbol: &str) {
|
|
|
- // let symbol_format = &utils::format_symbol(symbol, "");
|
|
|
- // let get_res_data = move |res_data: ResponseData| {
|
|
|
- // async move {
|
|
|
- // if res_data.code == "200" && res_data.channel == "depth" {
|
|
|
- // let res_data_str = res_data.data;
|
|
|
- // let res_data_json: serde_json::Value = serde_json::from_str(&*res_data_str).unwrap();
|
|
|
- // let mut depth_asks: Vec<MarketOrder> = parse_depth_items(&res_data_json["asks"]);
|
|
|
- // let mut depth_bids: Vec<MarketOrder> = parse_depth_items(&res_data_json["bids"]);
|
|
|
- // depth_asks.sort_by(|a, b| a.price.partial_cmp(&b.price).unwrap_or(Ordering::Equal));
|
|
|
- // depth_bids.sort_by(|a, b| b.price.partial_cmp(&a.price).unwrap_or(Ordering::Equal));
|
|
|
- // let mp = (depth_asks[0].price + depth_bids[0].price) * dec!(0.5);
|
|
|
- // let step = (public_params::EFF_RANGE * mp / Decimal::from_usize(public_params::LEVEL).unwrap()).round();
|
|
|
- // let mut ap = Vec::new();
|
|
|
- // let mut bp = Vec::new();
|
|
|
- // let mut av: Vec<Decimal> = Vec::new();
|
|
|
- // let mut bv: Vec<Decimal> = Vec::new();
|
|
|
- // for i in 0..public_params::LEVEL {
|
|
|
- // let price = (depth_asks[0].price + step * Decimal::from_f64(i as f64).unwrap()).round();
|
|
|
- // ap.push(price);
|
|
|
- // }
|
|
|
- // for i in 0..public_params::LEVEL {
|
|
|
- // let price = (depth_asks[0].price - step * Decimal::from_f64(i as f64).unwrap()).round();
|
|
|
- // bp.push(price);
|
|
|
- // }
|
|
|
- // let mut ap_price_tag = depth_asks[0].price + step;
|
|
|
- // let mut ap_index = 0;
|
|
|
- // for item in depth_asks.iter() {
|
|
|
- // let price = item.price;
|
|
|
- // let amount = item.amount;
|
|
|
- // println!("{} {}", price, amount);
|
|
|
- // if price > ap_price_tag {
|
|
|
- // av[ap_index] += amount;
|
|
|
- // } else {
|
|
|
- // ap_price_tag += step;
|
|
|
- // ap_index += 1;
|
|
|
- // if ap_index == public_params::LEVEL {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // av[ap_index] += amount
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // let mut bp_price_tag = depth_bids[0].price - step;
|
|
|
- // let mut bp_index = 0;
|
|
|
- // for item in depth_bids.iter() {
|
|
|
- // let price = item.price;
|
|
|
- // let amount = item.amount;
|
|
|
- // if price > bp_price_tag {
|
|
|
- // bv[bp_index] += amount;
|
|
|
- // } else {
|
|
|
- // bp_price_tag -= step;
|
|
|
- // bp_index += 1;
|
|
|
- // if bp_index == public_params::LEVEL {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // bv[bp_index] += amount
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // let aa: Vec<&Decimal> = bp.iter().clone().chain(bv.iter().clone()).chain(ap.iter().clone()).chain(av.iter().clone()).collect::<Vec<_>>();
|
|
|
- // println!("{:?}", aa);
|
|
|
- // let result = Depth {
|
|
|
- // time: 123456,
|
|
|
- // asks: depth_asks,
|
|
|
- // bids: depth_bids,
|
|
|
- // };
|
|
|
- // println!("subscribe_special_depth: {:?}", result)
|
|
|
- // }
|
|
|
- // }
|
|
|
- // };
|
|
|
- // self.wss.custom_subscribe(vec![symbol_format], 0, 0, get_res_data)
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
// fn parse_depth_items(value: &serde_json::Value) -> Vec<MarketOrder> {
|