// use std::str::FromStr; // use rust_decimal::Decimal; // use rust_decimal::prelude::FromPrimitive; // use serde_json::Value; // use exchanges::response_base::ResponseData; // use crate::{OrderBook, Trade, Record}; // // pub fn handle_records(value: &Value) -> Vec { // let mut records = vec![]; // let record = value["data"].clone(); // records.push(Record { // time: Decimal::from_i64(record["startTime"].as_i64().unwrap()).unwrap(), // open: Decimal::from_f64(record["open"].as_f64().unwrap()).unwrap(), // high: Decimal::from_f64(record["high"].as_f64().unwrap()).unwrap(), // low: Decimal::from_f64(record["low"].as_f64().unwrap()).unwrap(), // close: Decimal::from_f64(record["close"].as_f64().unwrap()).unwrap(), // volume: Decimal::from_f64(record["volume"].as_f64().unwrap()).unwrap(), // symbol: record["symbol"].as_str().unwrap().replace("PERP_", ""), // }); // // return records; // } // // pub fn format_depth_items(value: &Value) -> Vec { // let mut depth_items: Vec = vec![]; // for value in value.as_array().unwrap() { // depth_items.push(OrderBook { // price: Decimal::from_str(value[0].as_str().unwrap()).unwrap(), // amount: Decimal::from_str(value[1].as_str().unwrap()).unwrap(), // }) // } // return depth_items; // } // // pub fn format_trade_items(res_data: &ResponseData) -> Vec { // let result = res_data.data["data"].as_array().unwrap(); // let mut trades = vec![]; // for item in result { // let side = item["b"] == "BUY"; // let size = Decimal::from_f64(item["a"].as_f64().unwrap()).unwrap(); // let price = Decimal::from_f64(item["p"].as_f64().unwrap()).unwrap(); // trades.push(Trade { // id: res_data.data["ts"].to_string(), // time: Decimal::from_i64(res_data.data["ts"].as_i64().unwrap()).unwrap(), // size: if side { size * price } else { -size * price }, // price, // symbol: item["s"].as_str().unwrap().replace("PERP_", ""), // }) // } // // return trades; // }