Sfoglia il codice sorgente

挂单价格显示问题

skyffire 6 mesi fa
parent
commit
094552c897
2 ha cambiato i file con 15 aggiunte e 9 eliminazioni
  1. 11 5
      strategy/src/predictor.rs
  2. 4 4
      strategy/src/utils.rs

+ 11 - 5
strategy/src/predictor.rs

@@ -390,11 +390,17 @@ impl Predictor {
 
         if is_close_long {
             self.ask_delta = self.mid_price * self.params.close;
-        } else if is_close_short {
+        }
+
+        if is_close_short {
             self.bid_delta = self.mid_price * self.params.close;
-        } else if is_open_long {
+        }
+
+        if is_open_long {
             self.bid_delta = self.params.open * self.mid_price;
-        } else if is_open_short {
+        }
+
+        if is_open_short {
             self.ask_delta = self.params.open * self.mid_price;
         }
     }
@@ -405,7 +411,7 @@ impl Predictor {
         } else if self.ask_delta == dec!(-2) {
             Self::DONT_VIEW
         } else {
-            max(self.ask_price + self.ask_delta, self.bid_price)
+            max(self.fair_price + self.ask_delta, self.bid_price)
         };
 
         self.optimal_bid_price = if self.bid_delta == dec!(-1) {
@@ -413,7 +419,7 @@ impl Predictor {
         } else if self.bid_delta == dec!(-2) {
             Self::DONT_VIEW
         } else {
-            min(self.bid_price - self.bid_delta, self.ask_price)
+            min(self.fair_price - self.bid_delta, self.ask_price)
         };
 
         self.optimal_ask_price.rescale(self.mid_price.scale());

+ 4 - 4
strategy/src/utils.rs

@@ -394,8 +394,8 @@ pub fn build_html_file(data_c: &Vec<VecDeque<Option<Decimal>>>) -> String {
             name: "optimal_ask_price",
             type: "line",
             showSymbol: false,
-            // data: data[8],
-            data: [],
+            data: data[8],
+            // data: [],
             lineStyle: {
               type: "dashed",
             },
@@ -404,8 +404,8 @@ pub fn build_html_file(data_c: &Vec<VecDeque<Option<Decimal>>>) -> String {
             name: "optimal_bid_price",
             type: "line",
             showSymbol: false,
-            // data: data[9],
-            data: [],
+            data: data[9],
+            // data: [],
             lineStyle: {
               type: "dashed",
             },