|
|
@@ -363,7 +363,14 @@ impl AvellanedaStoikov {
|
|
|
}
|
|
|
|
|
|
let mut cci = self.cci_arc.lock().await;
|
|
|
-
|
|
|
+ let mut sma = Decimal::ZERO;
|
|
|
+ let mut smb = Decimal::ZERO;
|
|
|
+ let mut smm = Decimal::ZERO;
|
|
|
+ if !self.depth_vec[1].time.is_zero() {
|
|
|
+ sma = self.depth_vec[1].asks[0].price;
|
|
|
+ smb = self.depth_vec[1].bids[0].price;
|
|
|
+ smm = (sma + smb) / Decimal::TWO;
|
|
|
+ }
|
|
|
cci.predictor_state_vec.push_back(PredictorState {
|
|
|
update_time: Decimal::from_i64(Utc::now().timestamp_millis()).unwrap(),
|
|
|
|
|
|
@@ -371,15 +378,15 @@ impl AvellanedaStoikov {
|
|
|
ask_price: self.ask_price,
|
|
|
bid_price: self.bid_price,
|
|
|
last_price: self.last_price,
|
|
|
- spread: self.spread,
|
|
|
- spread_max: self.spread_max,
|
|
|
- spread_min: Decimal::ZERO,
|
|
|
+ spread: smm,
|
|
|
+ spread_max: sma,
|
|
|
+ spread_min: smb,
|
|
|
optimal_ask_price: self.optimal_ask_price,
|
|
|
optimal_bid_price: self.optimal_bid_price,
|
|
|
|
|
|
inventory: self.inventory,
|
|
|
- sigma_square: self.sigma_square,
|
|
|
- gamma: self.gamma,
|
|
|
+ sigma_square: self.spread_max,
|
|
|
+ gamma: self.spread,
|
|
|
kappa: self.kappa,
|
|
|
|
|
|
flow_ratio: Decimal::ZERO,
|