|
|
@@ -118,10 +118,10 @@ impl Platform for HtxSwap {
|
|
|
let res_data_json = response.data;
|
|
|
let mut account = Account::new();
|
|
|
for data in res_data_json.as_array().unwrap() {
|
|
|
- let margin_position = Decimal::from_str(&data["margin_position"].to_string()).unwrap();
|
|
|
+ let margin_position = Decimal::from_f64(data["margin_position"].as_f64().unwrap()).unwrap();
|
|
|
|
|
|
- let balance = Decimal::from_str(&data["margin_balance"].to_string()).unwrap();
|
|
|
- let frozen_balance = Decimal::from_str(&data["margin_frozen"].to_string()).unwrap();
|
|
|
+ let balance = Decimal::from_f64(data["margin_balance"].as_f64().unwrap()).unwrap();
|
|
|
+ let frozen_balance = Decimal::from_f64(data["margin_frozen"].as_f64().unwrap()).unwrap();
|
|
|
let available_balance = balance - margin_position - frozen_balance;
|
|
|
// 格式化account信息
|
|
|
account = Account {
|
|
|
@@ -199,8 +199,8 @@ impl Platform for HtxSwap {
|
|
|
low: Decimal::from_str(ticker_info["low"].as_str().unwrap()).unwrap(),
|
|
|
sell: Decimal::from_f64(ticker_info["bid"][0].as_f64().unwrap()).unwrap(),
|
|
|
buy: Decimal::from_f64(ticker_info["ask"][0].as_f64().unwrap()).unwrap(),
|
|
|
- last: Decimal::from_str(ticker_info["close"].as_str().unwrap()).unwrap(),
|
|
|
- volume: Decimal::from_str(ticker_info["amount"].as_str().unwrap()).unwrap(),
|
|
|
+ last: Decimal::from_f64(ticker_info["close"].as_f64().unwrap()).unwrap(),
|
|
|
+ volume: Decimal::from_f64(ticker_info["amount"].as_f64().unwrap()).unwrap(),
|
|
|
};
|
|
|
Ok(result)
|
|
|
}
|
|
|
@@ -565,9 +565,9 @@ impl Platform for HtxSwap {
|
|
|
pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
|
|
|
let id = order["order_id"].to_string();
|
|
|
let custom_id = order["client_order_id"].to_string();
|
|
|
- let price = Decimal::from_str(&order["price"].to_string()).unwrap();
|
|
|
- let amount = Decimal::from_str(&order["volume"].to_string()).unwrap() * ct_val;
|
|
|
- let deal_amount = Decimal::from_str(&order["trade_volume"].to_string()).unwrap() * ct_val;
|
|
|
+ let price = Decimal::from_f64(order["price"].as_f64().unwrap()).unwrap();
|
|
|
+ let amount = Decimal::from_f64(order["volume"].as_f64().unwrap()).unwrap() * ct_val;
|
|
|
+ let deal_amount = Decimal::from_f64(order["trade_volume"].as_f64().unwrap()).unwrap() * ct_val;
|
|
|
let avg_price = Decimal::from_f64(order["trade_avg_price"].as_f64().unwrap_or(0.0)).unwrap() * ct_val;
|
|
|
|
|
|
let status = order["status"].to_string();
|