|
|
@@ -78,42 +78,12 @@ impl Predictor {
|
|
|
let mut debugs: Vec<VecDeque<Option<Decimal>>> = vec![VecDeque::new(); len];
|
|
|
|
|
|
while let Some(value) = rx.next().await {
|
|
|
- // 获取插入下标
|
|
|
- // 反向遍历 VecDeque
|
|
|
- let mut insert_index = 0usize;
|
|
|
- if debugs[0].len() > 0 {
|
|
|
- let mut j = debugs[0].len() - 1;
|
|
|
- loop {
|
|
|
- if debugs[0][j].unwrap() <= value[0] {
|
|
|
- insert_index = j + 1;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- j = j - 1;
|
|
|
- if j == 0 {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 数据填充到对应位置
|
|
|
for i in 0..len {
|
|
|
if value[i] == Self::DONT_VIEW {
|
|
|
- // 可能会遇见按时序插入的
|
|
|
- if debugs[i].len() > 0 && insert_index < debugs[i].len() {
|
|
|
- // 在合适的位置插入新元素
|
|
|
- debugs[i].insert(insert_index, None);
|
|
|
- } else {
|
|
|
- debugs[i].push_back(None);
|
|
|
- }
|
|
|
+ debugs[i].push_back(None);
|
|
|
} else {
|
|
|
- // 可能会遇见按时序插入的
|
|
|
- if debugs[i].len() > 0 && insert_index < debugs[i].len() {
|
|
|
- // 在合适的位置插入新元素
|
|
|
- debugs[i].insert(insert_index, Some(value[i]));
|
|
|
- } else {
|
|
|
- debugs[i].push_back(Some(value[i]));
|
|
|
- }
|
|
|
+ debugs[i].push_back(Some(value[i]));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -423,47 +393,25 @@ impl Predictor {
|
|
|
}
|
|
|
let pos_avg_price = self.pos_avg_price;
|
|
|
|
|
|
- if is_hard_update {
|
|
|
- self.debug_sender.unbounded_send(vec![
|
|
|
- now,
|
|
|
- if pos_avg_price.is_zero() { mid_price } else { pos_avg_price },
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- inventory,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- Self::DONT_VIEW,
|
|
|
- pos_avg_price
|
|
|
- ]).unwrap();
|
|
|
- } else {
|
|
|
- self.debug_sender.unbounded_send(vec![
|
|
|
- now,
|
|
|
- mid_price,
|
|
|
- ask_price,
|
|
|
- bid_price,
|
|
|
- last_price,
|
|
|
- spread,
|
|
|
- spread_max,
|
|
|
- spread_min,
|
|
|
- optimal_ask_price,
|
|
|
- optimal_bid_price,
|
|
|
- inventory,
|
|
|
- sigma_square,
|
|
|
- gamma,
|
|
|
- kappa,
|
|
|
- flow_ratio,
|
|
|
- fair_price,
|
|
|
- pos_avg_price
|
|
|
- ]).unwrap();
|
|
|
- }
|
|
|
+ self.debug_sender.unbounded_send(vec![
|
|
|
+ now,
|
|
|
+ mid_price,
|
|
|
+ ask_price,
|
|
|
+ bid_price,
|
|
|
+ last_price,
|
|
|
+ spread,
|
|
|
+ spread_max,
|
|
|
+ spread_min,
|
|
|
+ optimal_ask_price,
|
|
|
+ optimal_bid_price,
|
|
|
+ inventory,
|
|
|
+ sigma_square,
|
|
|
+ gamma,
|
|
|
+ kappa,
|
|
|
+ flow_ratio,
|
|
|
+ fair_price,
|
|
|
+ pos_avg_price
|
|
|
+ ]).unwrap();
|
|
|
}
|
|
|
|
|
|
// #[instrument(skip(self, ref_ticker_map), level="TRACE")]
|