|
|
@@ -256,12 +256,12 @@ impl AvellanedaStoikov {
|
|
|
|
|
|
pub fn update_optimal_ask_and_bid(&mut self) {
|
|
|
self.optimal_ask_price = if self.ask_delta == Decimal::NEGATIVE_ONE {
|
|
|
- self.fair_price_vec[0]
|
|
|
+ self.ref_price
|
|
|
} else {
|
|
|
max(self.ref_price + self.ask_delta, self.ask_price)
|
|
|
};
|
|
|
self.optimal_bid_price = if self.bid_delta == Decimal::NEGATIVE_ONE {
|
|
|
- self.fair_price_vec[0]
|
|
|
+ self.ref_price
|
|
|
} else {
|
|
|
min(self.ref_price - self.bid_delta, self.bid_price)
|
|
|
};
|
|
|
@@ -349,12 +349,10 @@ 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;
|
|
|
+ let sma = self.depth_vec[1].asks[0].price;
|
|
|
+ let smb = self.depth_vec[1].bids[0].price;
|
|
|
smm = (sma + smb) / Decimal::TWO;
|
|
|
}
|
|
|
cci.predictor_state_vec.push_back(PredictorState {
|
|
|
@@ -365,8 +363,8 @@ impl AvellanedaStoikov {
|
|
|
bid_price: self.bid_price,
|
|
|
last_price: self.last_price,
|
|
|
spread: smm,
|
|
|
- spread_max: sma,
|
|
|
- spread_min: smb,
|
|
|
+ spread_max: self.mid_price,
|
|
|
+ spread_min: self.ref_price,
|
|
|
optimal_ask_price: self.optimal_ask_price,
|
|
|
optimal_bid_price: self.optimal_bid_price,
|
|
|
|