|
|
@@ -1,6 +1,7 @@
|
|
|
use std::collections::BTreeMap;
|
|
|
use std::sync::Arc;
|
|
|
use std::sync::atomic::AtomicBool;
|
|
|
+use std::time::Duration;
|
|
|
use rust_decimal::Decimal;
|
|
|
use tokio::sync::Mutex;
|
|
|
use exchanges::response_base::ResponseData;
|
|
|
@@ -9,7 +10,6 @@ use standard::exchange::ExchangeEnum::BinanceSwap;
|
|
|
use crate::model::{OriginalTradeBa};
|
|
|
use crate::quant::Quant;
|
|
|
use exchanges::binance_swap_ws::{BinanceSwapSubscribeType, BinanceSwapWs, BinanceSwapWsType};
|
|
|
-use futures_util::StreamExt;
|
|
|
use crate::exchange_disguise::{on_special_depth};
|
|
|
|
|
|
// 参考 币安 合约 启动
|
|
|
@@ -41,7 +41,7 @@ pub(crate) async fn reference_binance_swap_run(bool_v1 :Arc<AtomicBool>,
|
|
|
let mut min_sell = Decimal::ZERO;
|
|
|
|
|
|
loop {
|
|
|
- if let Some(data) = read_rx.next().await {
|
|
|
+ while let Ok(Some(data)) = read_rx.try_next() {
|
|
|
on_data(bot_arc_clone.clone(), &mut update_flag_u, &mut max_buy, &mut min_sell, data).await;
|
|
|
|
|
|
// 从通道中接收并丢弃所有的消息,直到通道为空
|
|
|
@@ -49,6 +49,8 @@ pub(crate) async fn reference_binance_swap_run(bool_v1 :Arc<AtomicBool>,
|
|
|
// 消息被忽略
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ tokio::time::sleep(Duration::from_nanos(1)).await;
|
|
|
}
|
|
|
});
|
|
|
|