|
|
@@ -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()
|
|
|
};
|