Преглед на файлове

修改订单平均价格

gepangpang преди 2 години
родител
ревизия
4e2f8e8565
променени са 4 файла, в които са добавени 4 реда и са изтрити 8 реда
  1. 1 2
      standard/src/gate_handle.rs
  2. 1 2
      standard/src/gate_swap.rs
  3. 1 2
      standard/src/kucoin_handle.rs
  4. 1 2
      standard/src/kucoin_swap.rs

+ 1 - 2
standard/src/gate_handle.rs

@@ -72,7 +72,6 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
         let custom_id = text.replace("t-my-custom-id_", "");
         let amount = size * amount_size;
         let deal_amount = (amount - left) * amount_size;
-        let avg_price = if deal_amount.is_zero() { fill_price } else { fill_price / deal_amount };
         let custom_status = if status == "finished" { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { "OTHER".to_string() };
         let order = Order {
             id,
@@ -80,7 +79,7 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
             price,
             amount,
             deal_amount,
-            avg_price,
+            avg_price: fill_price,
             status: custom_status,
             order_type,
         };

+ 1 - 2
standard/src/gate_swap.rs

@@ -419,7 +419,6 @@ fn parse_order_item(order: &serde_json::Value, amount_size: Decimal) -> Order {
     let custom_id = text.replace("t-my-custom-id_", "");
     let amount = size * amount_size;
     let deal_amount = (amount - left) * amount_size;
-    let avg_price = fill_price / deal_amount;
     let custom_status = if "finished" == status { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { "OTHER".to_string() };
     Order {
         id: order["id"].to_string(),
@@ -427,7 +426,7 @@ fn parse_order_item(order: &serde_json::Value, amount_size: Decimal) -> Order {
         price: order["price"].as_str().unwrap_or("0").parse().unwrap_or(dec!(0)),
         amount: order["size"].to_string().parse().unwrap_or(dec!(0)),
         deal_amount,
-        avg_price,
+        avg_price: fill_price,
         status: custom_status,
         order_type: "limit".to_string(),
     }

+ 1 - 2
standard/src/kucoin_handle.rs

@@ -75,8 +75,7 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
 
         let amount = size * amount_size;
         let deal_amount = filled_size * amount_size;
-        let deal_price = if status == "match" { match_price } else { price };
-        let avg_price = if filled_size.is_zero() { deal_price } else { deal_price / filled_size };
+        let avg_price = if status == "match" { match_price } else { price };
         let custom_status = if ["done", "match"].contains(&status) { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { "OTHER".to_string() };
         let order = Order {
             id,

+ 1 - 2
standard/src/kucoin_swap.rs

@@ -369,8 +369,7 @@ fn parse_order_item(order: &serde_json::Value, amount_size: Decimal) -> Order {
 
     let amount = size * amount_size;
     let deal_amount = filled_size * amount_size;
-    let deal_price = if status == "match" { match_price } else { price };
-    let avg_price = if filled_size.is_zero() { deal_price } else { deal_price / filled_size };
+    let avg_price = if status == "match" { match_price } else { price };
     let custom_status = if ["done", "match"].contains(&status) { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { "OTHER".to_string() };
     Order {
         id: order["id"].as_str().unwrap_or("").parse().unwrap(),