|
@@ -220,6 +220,7 @@ impl Predictor {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ let prev_pos_amount = self.pos_amount;
|
|
|
self.pos_amount = pos_amount.clone();
|
|
self.pos_amount = pos_amount.clone();
|
|
|
self.pos_avg_price = pos_avg_price.clone();
|
|
self.pos_avg_price = pos_avg_price.clone();
|
|
|
self.inventory = (pos_amount / (min_amount_value / self.mid_price)).trunc();
|
|
self.inventory = (pos_amount / (min_amount_value / self.mid_price)).trunc();
|
|
@@ -232,7 +233,9 @@ impl Predictor {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- self.processor(update_time, true).await;
|
|
|
|
|
|
|
+ if prev_pos_amount != self.pos_amount {
|
|
|
|
|
+ self.processor(update_time, true).await;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
pub async fn on_balance(&mut self, balance: Decimal) {
|
|
pub async fn on_balance(&mut self, balance: Decimal) {
|
|
@@ -385,10 +388,6 @@ impl Predictor {
|
|
|
|
|
|
|
|
self.update_delta();
|
|
self.update_delta();
|
|
|
|
|
|
|
|
- if !self.inventory.is_zero() {
|
|
|
|
|
- info!(?data_time, is_hard_update)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// let cci_arc = self.cci_arc.clone();
|
|
// let cci_arc = self.cci_arc.clone();
|
|
|
let now = data_time;
|
|
let now = data_time;
|
|
|
let mid_price = self.mid_price;
|
|
let mid_price = self.mid_price;
|
|
@@ -424,25 +423,47 @@ impl Predictor {
|
|
|
}
|
|
}
|
|
|
let pos_avg_price = self.pos_avg_price;
|
|
let pos_avg_price = self.pos_avg_price;
|
|
|
|
|
|
|
|
- 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();
|
|
|
|
|
|
|
+ if is_hard_update {
|
|
|
|
|
+ self.debug_sender.unbounded_send(vec![
|
|
|
|
|
+ now,
|
|
|
|
|
+ if pos_avg_price.is_zero() { Self::DONT_VIEW } 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();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// #[instrument(skip(self, ref_ticker_map), level="TRACE")]
|
|
// #[instrument(skip(self, ref_ticker_map), level="TRACE")]
|