|
|
@@ -1,5 +1,5 @@
|
|
|
use std::str::FromStr;
|
|
|
-use rust_decimal::Decimal;
|
|
|
+use rust_decimal::{Decimal, Error};
|
|
|
use rust_decimal::prelude::FromPrimitive;
|
|
|
use rust_decimal_macros::dec;
|
|
|
use serde_json::Value;
|
|
|
@@ -121,9 +121,9 @@ pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
|
|
|
}
|
|
|
// 处理特殊Ticket信息
|
|
|
pub fn handle_book_ticker(res_data: &ResponseData) -> SpecialDepth {
|
|
|
- let bp = Decimal::from_str((*res_data).data["b"].as_str().unwrap_or("0")).unwrap();
|
|
|
+ let bp = Decimal::from_str((*res_data).data["b"].as_str().unwrap_or("0")).unwrap_or(Decimal::ZERO);
|
|
|
let bq = Decimal::from_f64((*res_data).data["B"].as_f64().unwrap()).unwrap();
|
|
|
- let ap = Decimal::from_str((*res_data).data["a"].as_str().unwrap_or("0")).unwrap();
|
|
|
+ let ap = Decimal::from_str((*res_data).data["a"].as_str().unwrap_or("0")).unwrap_or(Decimal::ZERO);
|
|
|
let aq = Decimal::from_f64((*res_data).data["A"].as_f64().unwrap()).unwrap();
|
|
|
let mp = (bp + ap) * dec!(0.5);
|
|
|
let t = Decimal::from_u64((*res_data).data["u"].as_u64().unwrap()).unwrap();
|