|
|
@@ -194,39 +194,38 @@ impl AvellanedaStoikov {
|
|
|
}
|
|
|
|
|
|
pub fn update_gamma(&mut self) {
|
|
|
- self.gamma = if self.spread_min == Decimal::ZERO {
|
|
|
+ self.gamma = if self.sigma_square == Decimal::ZERO || self.inventory == Decimal::ZERO {
|
|
|
Decimal::ONE
|
|
|
} else {
|
|
|
- Decimal::ONE + Self::IRA * (self.spread_max / self.spread_min).sqrt().unwrap() / Decimal::TEN
|
|
|
+ Self::IRA * (self.spread_max - self.spread_min) / (Decimal::TWO * self.inventory.abs() * self.sigma_square)
|
|
|
};
|
|
|
-
|
|
|
self.gamma.rescale(8);
|
|
|
}
|
|
|
|
|
|
pub fn update_kappa(&mut self) {
|
|
|
- // if self.spread_max == Decimal::ZERO {
|
|
|
- // self.kappa = Decimal::ONE;
|
|
|
- // } else {
|
|
|
- // let delta_plus_max = (Decimal::TWO - Self::IRA) * self.spread_max + Self::IRA * self.spread_min;
|
|
|
- // let mut temp = (delta_plus_max) * self.gamma - self.sigma_square * self.gamma.powd(Decimal::TWO);
|
|
|
- //
|
|
|
- // temp.rescale(6);
|
|
|
- //
|
|
|
- // self.kappa = if temp <= Decimal::ZERO {
|
|
|
- // Decimal::TEN
|
|
|
- // } else if temp >= Decimal::TEN {
|
|
|
- // Decimal::TEN
|
|
|
- // } else {
|
|
|
- // self.gamma / (temp.exp() - Decimal::ONE)
|
|
|
- // };
|
|
|
- // self.kappa.rescale(8);
|
|
|
- // }
|
|
|
-
|
|
|
- if self.mid_price > Decimal::ZERO {
|
|
|
- self.kappa = dec!(888) / self.mid_price;
|
|
|
+ if self.spread_max == Decimal::ZERO {
|
|
|
+ self.kappa = Decimal::ONE;
|
|
|
} else {
|
|
|
- self.kappa = dec!(1);
|
|
|
+ let delta_plus_max = (Decimal::TWO - Self::IRA) * self.spread_max + Self::IRA * self.spread_min;
|
|
|
+ let mut temp = (delta_plus_max) * self.gamma - self.sigma_square * self.gamma.powd(Decimal::TWO);
|
|
|
+
|
|
|
+ temp.rescale(6);
|
|
|
+
|
|
|
+ self.kappa = if temp <= Decimal::ZERO {
|
|
|
+ Decimal::TEN
|
|
|
+ } else if temp >= Decimal::TEN {
|
|
|
+ Decimal::TEN
|
|
|
+ } else {
|
|
|
+ self.gamma / (temp.exp() - Decimal::ONE)
|
|
|
+ };
|
|
|
+ self.kappa.rescale(8);
|
|
|
}
|
|
|
+
|
|
|
+ // if self.mid_price > Decimal::ZERO {
|
|
|
+ // self.kappa = dec!(888) / self.mid_price;
|
|
|
+ // } else {
|
|
|
+ // self.kappa = dec!(1);
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
pub fn update_ref_price(&mut self) {
|
|
|
@@ -301,13 +300,13 @@ impl AvellanedaStoikov {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if self.optimal_ask_price <= self.ask_price {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if self.optimal_bid_price >= self.bid_price {
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if self.optimal_ask_price < self.ask_price {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if self.optimal_bid_price > self.bid_price {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
|
|
|
if self.depth_vec.len() < 200 {
|
|
|
return;
|