|
|
@@ -609,7 +609,12 @@ pub fn format_order_item(order: Value, ct_val: Decimal) -> Order {
|
|
|
let price = Decimal::from_str(order["priceRp"].as_str().unwrap()).unwrap();
|
|
|
let amount = Decimal::from_str(order["orderQtyRq"].as_str().unwrap()).unwrap() * ct_val;
|
|
|
let deal_amount = Decimal::from_str(order["cumQtyRq"].as_str().unwrap()).unwrap() * ct_val;
|
|
|
- let avg_price = Decimal::from_str(order["cumValueRv"].as_str().unwrap()).unwrap()/deal_amount;
|
|
|
+ let avg_price;
|
|
|
+ if deal_amount > Decimal::ZERO {
|
|
|
+ avg_price = Decimal::from_str(order["cumValueRv"].as_str().unwrap()).unwrap()/deal_amount
|
|
|
+ } else {
|
|
|
+ avg_price = Decimal::ZERO;
|
|
|
+ }
|
|
|
|
|
|
let status = order["ordStatus"].as_str().unwrap();
|
|
|
let custom_status;
|