|
|
@@ -93,8 +93,8 @@ impl Platform for KucoinSwap {
|
|
|
let res_data_str = &res_data.data;
|
|
|
let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
|
|
|
|
|
|
- let balance = Decimal::from_str(&res_data_json["marginBalance"].as_f64().unwrap().to_string()).unwrap();
|
|
|
- let available_balance = Decimal::from_str(&res_data_json["availableBalance"].as_f64().unwrap().to_string()).unwrap();
|
|
|
+ let balance = Decimal::from_f64(res_data_json["marginBalance"].as_f64().unwrap()).unwrap();
|
|
|
+ let available_balance = Decimal::from_f64(res_data_json["availableBalance"].as_f64().unwrap()).unwrap();
|
|
|
let frozen_balance = balance - available_balance;
|
|
|
let result = Account {
|
|
|
coin: symbol_array[1].to_string(),
|
|
|
@@ -156,12 +156,12 @@ impl Platform for KucoinSwap {
|
|
|
let time = (Decimal::from_str(&*ticker_info["ts"].to_string()).unwrap() / dec!(1000000)).floor().to_i64().unwrap();
|
|
|
let result = Ticker {
|
|
|
time,
|
|
|
- high: Decimal::from_str(&ticker_info["bestAskPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- low: Decimal::from_str(&ticker_info["bestBidPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- sell: Decimal::from_str(&ticker_info["bestAskPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- buy: Decimal::from_str(&ticker_info["bestBidPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- last: Decimal::from_str(&ticker_info["price"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- volume: Decimal::from_str(&ticker_info["size"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
+ high: Decimal::from_f64(ticker_info["bestAskPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ low: Decimal::from_f64(ticker_info["bestBidPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ sell: Decimal::from_f64(ticker_info["bestAskPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ buy: Decimal::from_f64(ticker_info["bestBidPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ last: Decimal::from_f64(ticker_info["price"].as_f64().unwrap()).unwrap(),
|
|
|
+ volume: Decimal::from_f64(ticker_info["size"].as_f64().unwrap()).unwrap(),
|
|
|
};
|
|
|
Ok(result)
|
|
|
} else {
|
|
|
@@ -179,12 +179,12 @@ impl Platform for KucoinSwap {
|
|
|
let time = (Decimal::from_str(&*ticker_info["ts"].to_string()).unwrap() / dec!(1000000)).floor().to_i64().unwrap();
|
|
|
let result = Ticker {
|
|
|
time,
|
|
|
- high: Decimal::from_str(&ticker_info["bestAskPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- low: Decimal::from_str(&ticker_info["bestBidPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- sell: Decimal::from_str(&ticker_info["bestAskPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- buy: Decimal::from_str(&ticker_info["bestBidPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- last: Decimal::from_str(&ticker_info["price"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
- volume: Decimal::from_str(&ticker_info["size"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
+ high: Decimal::from_f64(ticker_info["bestAskPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ low: Decimal::from_f64(ticker_info["bestBidPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ sell: Decimal::from_f64(ticker_info["bestAskPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ buy: Decimal::from_f64(ticker_info["bestBidPrice"].as_f64().unwrap()).unwrap(),
|
|
|
+ last: Decimal::from_f64(ticker_info["price"].as_f64().unwrap()).unwrap(),
|
|
|
+ volume: Decimal::from_f64(ticker_info["size"].as_f64().unwrap()).unwrap(),
|
|
|
};
|
|
|
Ok(result)
|
|
|
} else {
|
|
|
@@ -207,9 +207,9 @@ impl Platform for KucoinSwap {
|
|
|
Some(value) => {
|
|
|
let base_asset = value["baseCurrency"].as_str().unwrap_or("").to_string();
|
|
|
let quote_asset = value["quoteCurrency"].as_str().unwrap_or("").to_string();
|
|
|
- let tick_size = Decimal::from_str(&value["tickSize"].as_f64().unwrap().to_string()).unwrap();
|
|
|
- let min_qty = Decimal::from_str(&value["lotSize"].as_f64().unwrap().to_string()).unwrap();
|
|
|
- let ct_val = Decimal::from_str(&value["multiplier"].as_f64().unwrap().to_string()).unwrap();
|
|
|
+ let tick_size = Decimal::from_f64(value["tickSize"].as_f64().unwrap()).unwrap();
|
|
|
+ let min_qty = Decimal::from_f64(value["lotSize"].as_f64().unwrap()).unwrap();
|
|
|
+ let ct_val = Decimal::from_f64(value["multiplier"].as_f64().unwrap()).unwrap();
|
|
|
|
|
|
let amount_size = min_qty * ct_val;
|
|
|
let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
|
|
|
@@ -225,9 +225,9 @@ impl Platform for KucoinSwap {
|
|
|
price_precision,
|
|
|
amount_precision,
|
|
|
min_qty,
|
|
|
- max_qty: Decimal::from_str(&value["maxOrderQty"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
+ max_qty: Decimal::from_f64(value["maxOrderQty"].as_f64().unwrap()).unwrap(),
|
|
|
min_notional,
|
|
|
- max_notional: Decimal::from_str(&value["maxPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
+ max_notional: Decimal::from_f64(value["maxPrice"].as_f64().unwrap()).unwrap(),
|
|
|
ct_val,
|
|
|
};
|
|
|
Ok(result)
|
|
|
@@ -253,9 +253,9 @@ impl Platform for KucoinSwap {
|
|
|
Some(value) => {
|
|
|
let base_asset = value["baseCurrency"].as_str().unwrap_or("").to_string();
|
|
|
let quote_asset = value["quoteCurrency"].as_str().unwrap_or("").to_string();
|
|
|
- let tick_size = Decimal::from_str(&value["tickSize"].as_f64().unwrap().to_string()).unwrap();
|
|
|
- let min_qty = Decimal::from_str(&value["lotSize"].as_f64().unwrap().to_string()).unwrap();
|
|
|
- let ct_val = Decimal::from_str(&value["multiplier"].as_f64().unwrap().to_string()).unwrap();
|
|
|
+ let tick_size = Decimal::from_f64(value["tickSize"].as_f64().unwrap()).unwrap();
|
|
|
+ let min_qty = Decimal::from_f64(value["lotSize"].as_f64().unwrap()).unwrap();
|
|
|
+ let ct_val = Decimal::from_f64(value["multiplier"].as_f64().unwrap()).unwrap();
|
|
|
|
|
|
let amount_size = min_qty * ct_val;
|
|
|
let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
|
|
|
@@ -271,9 +271,9 @@ impl Platform for KucoinSwap {
|
|
|
price_precision,
|
|
|
amount_precision,
|
|
|
min_qty,
|
|
|
- max_qty: Decimal::from_str(&value["maxOrderQty"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
+ max_qty: Decimal::from_f64(value["maxOrderQty"].as_f64().unwrap()).unwrap(),
|
|
|
min_notional,
|
|
|
- max_notional: Decimal::from_str(&value["maxPrice"].as_f64().unwrap().to_string()).unwrap(),
|
|
|
+ max_notional: Decimal::from_f64(value["maxPrice"].as_f64().unwrap()).unwrap(),
|
|
|
ct_val,
|
|
|
};
|
|
|
Ok(result)
|
|
|
@@ -626,9 +626,9 @@ impl Platform for KucoinSwap {
|
|
|
|
|
|
pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
|
|
|
let price = Decimal::from_str(order["price"].as_str().unwrap()).unwrap();
|
|
|
- let size = Decimal::from_str(&order["size"].as_f64().unwrap().to_string()).unwrap();
|
|
|
+ let size = Decimal::from_f64(order["size"].as_f64().unwrap()).unwrap();
|
|
|
let status = order["status"].as_str().unwrap_or("");
|
|
|
- let filled_size = Decimal::from_str(&order["filledSize"].as_f64().unwrap().to_string()).unwrap();
|
|
|
+ let filled_size = Decimal::from_f64(order["filledSize"].as_f64().unwrap()).unwrap();
|
|
|
let filled_value = Decimal::from_str(order["filledValue"].as_str().unwrap()).unwrap();
|
|
|
|
|
|
let amount = size * ct_val;
|