Browse Source

成交量计算修改

JiahengHe 1 year ago
parent
commit
07aee4be90
1 changed files with 4 additions and 4 deletions
  1. 4 4
      standard/src/coinex_swap_handle.rs

+ 4 - 4
standard/src/coinex_swap_handle.rs

@@ -90,17 +90,17 @@ pub fn format_order_item(order: &Value, ct_val: Decimal, status: &str) -> Order
     let text = order["client_id"].as_str().unwrap_or("");
     let size = Decimal::from_str(order["amount"].as_str().unwrap()).unwrap();
     let left = Decimal::from_str(order["unfilled_amount"].as_str().unwrap()).unwrap();
-    // 成交量
-    let filled_amount = Decimal::from_str(order["filled_amount"].as_str().unwrap_or("0")).unwrap();
+    // 成交量
+    let filled_amount = size - left;
     // 成交额
     let filled_value = Decimal::from_str(order["filled_value"].as_str().unwrap()).unwrap();
     // 成交均价
     let mut avg_price = Decimal::ZERO;
-    if filled_amount != Decimal::ZERO{
+    if filled_amount > Decimal::ZERO{
         avg_price = filled_value/filled_amount;
     }
     let amount = size * ct_val;
-    let deal_amount = (size - left) * ct_val;
+    let deal_amount = filled_amount * ct_val;
     let custom_status = if status == "finish" { "REMOVE".to_string() } else if status == "put" || status == "update" { "NEW".to_string() } else {
         "NULL".to_string()
     };