skyfffire 1 rok pred
rodič
commit
e6f54bec98

+ 3 - 1
strategy/src/avellaneda_stoikov.rs

@@ -28,6 +28,7 @@ pub struct AvellanedaStoikov {
     pub optimal_bid_price: Decimal,                                             // 买入挂单价
 
     pub inventory: Decimal,                                                     // 库存,也就是q
+    pub level: Decimal,                                                         // martin
     pub sigma_square: Decimal,                                                  // σ^2,波动性的平方
     pub gamma: Decimal,                                                         // γ,库存风险厌恶参数
     pub kappa: Decimal,                                                         // κ 订单簿 流动性 参数
@@ -89,6 +90,7 @@ impl AvellanedaStoikov {
             flow_ratio: Decimal::ONE,
             flow_ratio_diff_log: Default::default(),
             flow_out_value: Default::default(),
+            level: Default::default(),
         };
 
         avellaneda_stoikov
@@ -230,7 +232,7 @@ impl AvellanedaStoikov {
         if self.gamma != Decimal::ZERO {
             let a = (self.gamma * self.sigma_square * self.t_diff) / Decimal::TWO;
             let base_pos_edge = self.gamma * self.sigma_square;
-            let pos_edge = self.inventory.abs() * base_pos_edge * (Decimal::ONE + (self.inventory.abs() / dec!(5)));
+            let pos_edge = self.inventory.abs() * base_pos_edge * (Decimal::ONE + (self.inventory.abs() / dec!(45)));
             // let ratio_edge = (self.flow_ratio_diff_log.abs() / dec!(0.0003)) * self.gamma * self.sigma_square * self.t_diff;
 
             self.delta_bid = {

+ 1 - 1
strategy/src/strategy.rs

@@ -970,7 +970,7 @@ impl Strategy {
                 command.limits_open.insert(client_id, order);
             }
         }
-        // 挂空单
+        // 挂空单, TODO 如果下单之后没有收到仓位,岂不是会连续下几单?
         if self.post_side <= 0 && sell_value == Decimal::ZERO && predictor.optimal_ask_price > predictor.mid_price {
             let mut target_sell_price = predictor.optimal_ask_price;
             // target_sell_price = utils::clip(target_sell_price, self.bp * dec!(0.9995), self.ap * dec!(1.03));