Browse Source

簡易時間隔離。

skyfffire 1 year ago
parent
commit
877b3ce400
1 changed files with 12 additions and 12 deletions
  1. 12 12
      strategy/src/avellaneda_stoikov.rs

+ 12 - 12
strategy/src/avellaneda_stoikov.rs

@@ -246,7 +246,7 @@ impl AvellanedaStoikov {
             self.ask_delta += pos_edge;
         }
 
-        if self.flow_ratio_long.is_zero() || self.cross_time_diff < 30 {
+        if self.flow_ratio_long.is_zero() || self.cross_time_diff < 20 {
             self.ask_delta += self.base_delta;
             self.bid_delta += self.base_delta;
 
@@ -384,24 +384,24 @@ impl AvellanedaStoikov {
         let prev_flow_ratio_long = self.flow_ratio_long;
         self.flow_ratio_long = Self::calc_flow_ratio(&self.flow_ratio_long, &dec!(0), &mut self.trade_long_vec);
         let time = Utc::now().timestamp_millis();
-        let mut is_cross = false;
+        // let mut is_cross = false;
         if (self.flow_ratio_long > Decimal::ZERO && prev_flow_ratio_long <= Decimal::ZERO)
             || (self.flow_ratio_long < Decimal::ZERO && prev_flow_ratio_long >= Decimal::ZERO) {
             self.cross_time = time;
-            is_cross = true;
+            // is_cross = true;
         }
 
         if self.cross_time != 0 {
-            let prev_cross_time_diff = self.cross_time_diff;
+            // let prev_cross_time_diff = self.cross_time_diff;
             self.cross_time_diff = (time - self.cross_time) / 1000;
 
-            if is_cross {
-                self.cross_time_diff_avg = if self.cross_time_diff_avg == 0 {
-                    prev_cross_time_diff
-                } else {
-                    (self.cross_time_diff_avg * 5 + prev_cross_time_diff * 5) / 10
-                };
-            }
+            // if is_cross {
+            //     self.cross_time_diff_avg = if self.cross_time_diff_avg == 0 {
+            //         prev_cross_time_diff
+            //     } else {
+            //         (self.cross_time_diff_avg * 5 + prev_cross_time_diff * 5) / 10
+            //     };
+            // }
         }
 
         self.flow_ratio_short = Self::calc_flow_ratio(&self.flow_ratio_short, &dec!(0), &mut self.trade_short_vec);
@@ -485,7 +485,7 @@ impl AvellanedaStoikov {
             inventory: self.inventory,
             sigma_square: self.flow_ratio_long,
             gamma: self.flow_ratio_short,
-            kappa: Decimal::from(self.cross_time_diff_avg),
+            kappa: Decimal::from(self.cross_time_diff),
 
             flow_ratio: self.flow_ratio_long,
             ref_price: self.ref_price,