瀏覽代碼

※※※修改kucoin Ticker信息类型改变

gepangpang 1 年之前
父節點
當前提交
15f2bcca6e
共有 1 個文件被更改,包括 13 次插入12 次删除
  1. 13 12
      standard/src/kucoin_swap.rs

+ 13 - 12
standard/src/kucoin_swap.rs

@@ -160,14 +160,15 @@ impl Platform for KucoinSwap {
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
             let ticker_info = res_data_json;
             let time = (Decimal::from_str(&*ticker_info["ts"].to_string()).unwrap() / dec!(1000000)).floor().to_i64().unwrap();
+
             let result = Ticker {
                 time,
-                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(),
+                high: Decimal::from_str(ticker_info["bestAskPrice"].as_str().unwrap()).unwrap(),
+                low: Decimal::from_str(ticker_info["bestBidPrice"].as_str().unwrap()).unwrap(),
+                sell: Decimal::from_str(ticker_info["bestAskPrice"].as_str().unwrap()).unwrap(),
+                buy: Decimal::from_str(ticker_info["bestBidPrice"].as_str().unwrap()).unwrap(),
+                last: Decimal::from_str(ticker_info["price"].as_str().unwrap()).unwrap(),
+                volume: Decimal::from_str(&ticker_info["size"].to_string()).unwrap(),
             };
             Ok(result)
         } else {
@@ -186,12 +187,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_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(),
+                high: Decimal::from_str(ticker_info["bestAskPrice"].as_str().unwrap()).unwrap(),
+                low: Decimal::from_str(ticker_info["bestBidPrice"].as_str().unwrap()).unwrap(),
+                sell: Decimal::from_str(ticker_info["bestAskPrice"].as_str().unwrap()).unwrap(),
+                buy: Decimal::from_str(ticker_info["bestBidPrice"].as_str().unwrap()).unwrap(),
+                last: Decimal::from_str(ticker_info["price"].as_str().unwrap()).unwrap(),
+                volume: Decimal::from_str(&ticker_info["size"].to_string()).unwrap(),
             };
             Ok(result)
         } else {