瀏覽代碼

部分字段含义修正。

skyfffire 2 年之前
父節點
當前提交
5d3a3943fb

+ 10 - 10
standard/src/binance_swap.rs

@@ -117,12 +117,12 @@ impl Platform for BinanceSwap {
     // 获取仓位信息
     async fn get_position(&mut self) -> Result<Vec<Position>, Error> {
         let symbol_format = utils::format_symbol(self.symbol.clone(), "");
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_position_risk(symbol_format).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| { format_position_item(item, amount_size) }).collect();
+            let result = res_data_json.iter().map(|item| { format_position_item(item, ct_val) }).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -130,12 +130,12 @@ impl Platform for BinanceSwap {
     }
 
     async fn get_positions(&mut self) -> Result<Vec<Position>, Error> {
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_position_risk("".to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| { format_position_item(item, amount_size) }).collect();
+            let result = res_data_json.iter().map(|item| { format_position_item(item, ct_val) }).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -211,14 +211,14 @@ impl Platform for BinanceSwap {
                         base_asset,
                         quote_asset,
                         tick_size: Decimal::from_str(&price_filter["tickSize"].as_str().unwrap()).unwrap(),
-                        amount_size: dec!(1),
+                        amount_size: Default::default(),
+                        ct_val: dec!(1),
                         price_precision: Decimal::from_str(&value["pricePrecision"].to_string()).unwrap(),
                         amount_precision: Decimal::from_str(&value["quantityPrecision"].to_string()).unwrap(),
                         min_qty: Decimal::from_str(lot_size_filter["minQty"].as_str().unwrap()).unwrap(),
                         max_qty: Decimal::from_str(lot_size_filter["maxQty"].as_str().unwrap()).unwrap(),
                         min_notional: Decimal::from_str(price_filter["minPrice"].as_str().unwrap()).unwrap(),
                         max_notional: Decimal::from_str(price_filter["maxPrice"].as_str().unwrap()).unwrap(),
-                        ct_val: Default::default(),
                     };
                     Ok(result)
                 }
@@ -254,14 +254,14 @@ impl Platform for BinanceSwap {
                         base_asset,
                         quote_asset,
                         tick_size: Decimal::from_str(&price_filter["tickSize"].as_str().unwrap()).unwrap(),
-                        amount_size: dec!(1),
+                        amount_size: Default::default(),
+                        ct_val: dec!(1),
                         price_precision: Decimal::from_str(&value["pricePrecision"].to_string()).unwrap(),
                         amount_precision: Decimal::from_str(&value["quantityPrecision"].to_string()).unwrap(),
                         min_qty: Decimal::from_str(lot_size_filter["minQty"].as_str().unwrap()).unwrap(),
                         max_qty: Decimal::from_str(lot_size_filter["maxQty"].as_str().unwrap()).unwrap(),
                         min_notional: Decimal::from_str(price_filter["minPrice"].as_str().unwrap()).unwrap(),
                         max_notional: Decimal::from_str(price_filter["maxPrice"].as_str().unwrap()).unwrap(),
-                        ct_val: Default::default(),
                     };
                     Ok(result)
                 }
@@ -353,7 +353,7 @@ impl Platform for BinanceSwap {
     async fn command_order(&mut self, _order_command: OrderCommand, _trace_stack: TraceStack) { warn!("binance_swap:该交易所方法未实现"); }
 }
 
-pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal) -> Position {
+pub fn format_position_item(position: &serde_json::Value, ct_val: Decimal) -> Position {
     let mut position_mode = match position["positionSide"].as_str().unwrap_or("") {
         "BOTH" => PositionModeEnum::Both,
         "LONG" => PositionModeEnum::Long,
@@ -364,7 +364,7 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
         }
     };
     let size = Decimal::from_str(position["positionAmt"].as_str().unwrap()).unwrap();
-    let amount = size * amount_size;
+    let amount = size * ct_val;
     match position_mode {
         PositionModeEnum::Both => {
             position_mode = match amount {

+ 11 - 10
standard/src/bitget_spot.rs

@@ -172,21 +172,22 @@ impl Platform for BitgetSpot {
                     let price_precision = Decimal::from_str(value["pricePrecision"].as_str().unwrap()).unwrap();
                     let amount_precision = Decimal::from_str(value["quantityPrecision"].as_str().unwrap()).unwrap();
                     let tick_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(price_precision).unwrap()))).unwrap();
-                    let amount_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(amount_precision).unwrap()))).unwrap();
+                    // let amount__size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(amount_precision).unwrap()))).unwrap();
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
                         base_asset,
                         quote_asset,
                         tick_size,
-                        amount_size,
+                        // ct_val: amount__size,
                         price_precision,
                         amount_precision,
                         min_qty: Decimal::from_str(&value["minTradeAmount"].as_str().unwrap()).unwrap(),
                         max_qty: Decimal::from_str(&value["maxTradeAmount"].as_str().unwrap()).unwrap(),
                         min_notional: Default::default(),
                         max_notional: Default::default(),
-                        ct_val: Default::default(),
+                        ct_val: Decimal::ONE,
+                        amount_size: Default::default(),
                     };
                     Ok(result)
                 }
@@ -214,21 +215,21 @@ impl Platform for BitgetSpot {
                     let price_precision = Decimal::from_str(value["pricePrecision"].as_str().unwrap()).unwrap();
                     let amount_precision = Decimal::from_str(value["quantityPrecision"].as_str().unwrap()).unwrap();
                     let tick_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(price_precision).unwrap()))).unwrap();
-                    let amount_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(amount_precision).unwrap()))).unwrap();
+                    // let amount__size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(amount_precision).unwrap()))).unwrap();
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
                         base_asset,
                         quote_asset,
                         tick_size,
-                        amount_size,
                         price_precision,
                         amount_precision,
                         min_qty: Decimal::from_str(&value["minTradeAmount"].as_str().unwrap()).unwrap(),
                         max_qty: Decimal::from_str(&value["maxTradeAmount"].as_str().unwrap()).unwrap(),
                         min_notional: Default::default(),
                         max_notional: Default::default(),
-                        ct_val: Default::default(),
+                        ct_val: Decimal::ONE,
+                        amount_size: Default::default(),
                     };
                     Ok(result)
                 }
@@ -239,13 +240,13 @@ impl Platform for BitgetSpot {
     }
 
     async fn get_order_detail(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error> {
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_order(order_id.to_string(), custom_id.to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
             let order_info = res_data_json[0].clone();
-            let result = bitget_spot_handle::format_order_item(order_info, amount_size);
+            let result = bitget_spot_handle::format_order_item(order_info, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -254,12 +255,12 @@ impl Platform for BitgetSpot {
 
     async fn get_orders_list(&mut self, _status: &str) -> Result<Vec<Order>, Error> {
         let symbol_format = utils::format_symbol(self.symbol.clone(), "");
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_unfilled_orders(symbol_format.to_string(), "".to_string(), "".to_string(), "".to_string(), "100".to_string(), "".to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| bitget_spot_handle::format_order_item(item.clone(), amount_size)).collect();
+            let result = res_data_json.iter().map(|item| bitget_spot_handle::format_order_item(item.clone(), ct_val)).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))

+ 5 - 5
standard/src/bitget_spot_handle.rs

@@ -31,12 +31,12 @@ pub fn format_account_info(data: serde_json::Value) -> Account {
 }
 
 // 处理order信息
-pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrder {
+pub fn handle_order(res_data: ResponseData, ct_val: Decimal) -> SpecialOrder {
     let res_data_str = res_data.data;
     let res_data_json: Vec<serde_json::Value> = serde_json::from_str(&*res_data_str).unwrap();
     let mut order_info = Vec::new();
     for item in res_data_json.iter() {
-        order_info.push(format_order_item(item.clone(), amount_size));
+        order_info.push(format_order_item(item.clone(), ct_val));
     }
     trace!(?order_info);
     SpecialOrder {
@@ -46,7 +46,7 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
 }
 
 // 处理订单信息
-pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
+pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
     let price = Decimal::from_str(order["price"].as_str().unwrap_or(order["priceAvg"].as_str().unwrap())).unwrap();
     let size = Decimal::from_str(order["size"].as_str().unwrap()).unwrap();
     let status = order["status"].as_str().unwrap_or("");
@@ -54,8 +54,8 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
 
     let avg_price = Decimal::from_str(order["priceAvg"].as_str().unwrap()).unwrap();
 
-    let amount = size * amount_size;
-    let deal_amount = acc_base_volume * amount_size;
+    let amount = size * ct_val;
+    let deal_amount = acc_base_volume * ct_val;
     let custom_status = if ["filled", "cancelled"].contains(&status) {
         "REMOVE".to_string()
     } else if ["init", "live", "new", "partially_filled"].contains(&status) {

+ 9 - 9
standard/src/gate_handle.rs

@@ -37,13 +37,13 @@ pub fn format_account_info(data: Vec<serde_json::Value>, symbol: String) -> Acco
 }
 
 // 处理position信息
-pub fn handle_position(res_data: ResponseData, amount_size: Decimal) -> Vec<Position> {
+pub fn handle_position(res_data: ResponseData, ct_val: Decimal) -> Vec<Position> {
     let res_data_str = res_data.data;
     let res_data_json: Vec<serde_json::Value> = serde_json::from_str(&res_data_str).unwrap();
-    res_data_json.iter().map(|item| { format_position_item(item, amount_size) }).collect()
+    res_data_json.iter().map(|item| { format_position_item(item, ct_val) }).collect()
 }
 
-pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal) -> Position {
+pub fn format_position_item(position: &serde_json::Value, ct_val: Decimal) -> Position {
     let mut position_mode = match position["mode"].as_str().unwrap_or("") {
         "single" => PositionModeEnum::Both,
         "dual_long" => PositionModeEnum::Long,
@@ -54,7 +54,7 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
         }
     };
     let size = Decimal::from_str(&position["size"].to_string()).unwrap();
-    let amount = size * amount_size;
+    let amount = size * ct_val;
     match position_mode {
         PositionModeEnum::Both => {
             position_mode = match amount {
@@ -78,12 +78,12 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
 }
 
 // 处理order信息
-pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrder {
+pub fn handle_order(res_data: ResponseData, ct_val: Decimal) -> SpecialOrder {
     let res_data_str = res_data.data;
     let res_data_json: Vec<serde_json::Value> = serde_json::from_str(&*res_data_str).unwrap();
     let mut order_info = Vec::new();
     for item in res_data_json.iter() {
-        order_info.push(format_order_item(item.clone(), amount_size));
+        order_info.push(format_order_item(item.clone(), ct_val));
     };
 
     SpecialOrder {
@@ -92,7 +92,7 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
     }
 }
 
-pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
+pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
     debug!("format-order-start, gate_handle");
     debug!(?order);
     let status = order["status"].as_str().unwrap_or("");
@@ -100,8 +100,8 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
     let size = Decimal::from_str(&order["size"].to_string()).unwrap();
     let left = Decimal::from_str(&order["left"].to_string()).unwrap();
 
-    let amount = size * amount_size;
-    let deal_amount = (size - left) * amount_size;
+    let amount = size * ct_val;
+    let deal_amount = (size - left) * ct_val;
     let custom_status = if status == "finished" { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else {
         error!("Gate:格式化订单状态错误!\nformat_order_item:status={:?}", status);
         panic!("Gate:格式化订单状态错误!\nformat_order_item:status={:?}", status)

+ 31 - 31
standard/src/gate_swap.rs

@@ -123,12 +123,12 @@ impl Platform for GateSwap {
     // 获取持仓信息
     async fn get_position(&mut self) -> Result<Vec<Position>, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_position(symbol_array[1].to_string().to_lowercase(), self.symbol.clone()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| { format_position_item(item, amount_size) }).collect();
+            let result = res_data_json.iter().map(|item| { format_position_item(item, ct_val) }).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -137,12 +137,12 @@ impl Platform for GateSwap {
     // 获取所有持仓
     async fn get_positions(&mut self) -> Result<Vec<Position>, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_user_position(symbol_array[1].to_string().to_lowercase()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| { format_position_item(item, amount_size) }).collect();
+            let result = res_data_json.iter().map(|item| { format_position_item(item, ct_val) }).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -225,23 +225,23 @@ impl Platform for GateSwap {
                     let name = value["name"].as_str().unwrap();
                     let name_array: Vec<&str> = name.split("_").collect();
                     let tick_size = Decimal::from_str(value["order_price_round"].as_str().unwrap()).unwrap();
-                    let amount_size = Decimal::from_str(value["quanto_multiplier"].as_str().unwrap()).unwrap();
+                    let ct_val = Decimal::from_str(value["quanto_multiplier"].as_str().unwrap()).unwrap();
                     let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
-                    let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
+                    let amount_precision = Decimal::from_u32(ct_val.scale()).unwrap();
 
                     let result = Market {
                         symbol: name.to_string(),
                         base_asset: name_array[0].to_string(),
                         quote_asset: name_array[1].to_string(),
                         tick_size,
-                        amount_size,
+                        amount_size: Default::default(),
+                        ct_val,
                         price_precision,
                         amount_precision,
                         min_qty: Decimal::from_str(&value["order_size_min"].to_string()).unwrap(),
                         max_qty: Decimal::from_str(&value["order_size_max"].to_string()).unwrap(),
                         min_notional: Default::default(),
                         max_notional: Default::default(),
-                        ct_val: Default::default(),
                     };
                     Ok(result)
                 }
@@ -267,23 +267,23 @@ impl Platform for GateSwap {
                     let name = value["name"].as_str().unwrap();
                     let name_array: Vec<&str> = name.split("_").collect();
                     let tick_size = Decimal::from_str(value["order_price_round"].as_str().unwrap()).unwrap();
-                    let amount_size = Decimal::from_str(value["quanto_multiplier"].as_str().unwrap()).unwrap();
+                    let ct_val = Decimal::from_str(value["quanto_multiplier"].as_str().unwrap()).unwrap();
                     let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
-                    let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
+                    let amount_precision = Decimal::from_u32(ct_val.scale()).unwrap();
 
                     let result = Market {
                         symbol: name.to_string(),
                         base_asset: name_array[0].to_string(),
                         quote_asset: name_array[1].to_string(),
                         tick_size,
-                        amount_size,
+                        amount_size: Default::default(),
+                        ct_val,
                         price_precision,
                         amount_precision,
                         min_qty: Decimal::from_str(&value["order_size_min"].to_string()).unwrap(),
                         max_qty: Decimal::from_str(&value["order_size_max"].to_string()).unwrap(),
                         min_notional: Default::default(),
                         max_notional: Default::default(),
-                        ct_val: Default::default(),
                     };
                     Ok(result)
                 }
@@ -296,13 +296,13 @@ impl Platform for GateSwap {
     // 获取订单详情
     async fn get_order_detail(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let id = if order_id.eq("") { format!("t-my-custom-id_{}", custom_id) } else { order_id.to_string() };
         let res_data = self.request.get_order_details(symbol_array[1].to_string().to_lowercase(), id).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = format_order_item(res_data_json, amount_size);
+            let result = format_order_item(res_data_json, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -311,13 +311,13 @@ impl Platform for GateSwap {
     // 获取订单列表
     async fn get_orders_list(&mut self, status: &str) -> Result<Vec<Order>, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_orders(symbol_array[1].to_string().to_lowercase(), status.to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
             let order_info: Vec<_> = res_data_json.iter().filter(|item| item["contract"].as_str().unwrap_or("") == self.symbol).collect();
-            let result = order_info.iter().map(|&item| format_order_item(item.clone(), amount_size)).collect();
+            let result = order_info.iter().map(|&item| format_order_item(item.clone(), ct_val)).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -326,13 +326,13 @@ impl Platform for GateSwap {
     // 下单接口
     async fn take_order(&mut self, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let mut params = json!({
             "text": format!("t-my-custom-id_{}", custom_id),
             "contract": self.symbol.to_string(),
             "price": price.to_string(),
         });
-        let size = (amount / amount_size).floor();
+        let size = (amount / ct_val).floor();
         if price.eq(&dec!(0)) {
             params["tif"] = json!("ioc".to_string());
         }
@@ -359,7 +359,7 @@ impl Platform for GateSwap {
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = format_order_item(res_data_json, amount_size);
+            let result = format_order_item(res_data_json, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -368,13 +368,13 @@ impl Platform for GateSwap {
 
     async fn take_order_symbol(&mut self, symbol: String, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error> {
         let symbol_array: Vec<&str> = symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let mut params = json!({
             "text": format!("t-my-custom-id_{}", custom_id),
             "contract": self.symbol.to_string(),
             "price": price.to_string(),
         });
-        let size = (amount / amount_size).floor();
+        let size = (amount / ct_val).floor();
         if price.eq(&dec!(0)) {
             params["tif"] = json!("ioc".to_string());
         }
@@ -401,7 +401,7 @@ impl Platform for GateSwap {
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = format_order_item(res_data_json, amount_size);
+            let result = format_order_item(res_data_json, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -411,14 +411,14 @@ impl Platform for GateSwap {
     // 撤销订单
     async fn cancel_order(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let settle = symbol_array[1].to_string().to_lowercase();
         let id = if order_id.eq("") { format!("t-my-custom-id_{}", custom_id) } else { order_id.to_string() };
         let res_data = self.request.cancel_order(settle, id.to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = format_order_item(res_data_json, amount_size);
+            let result = format_order_item(res_data_json, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -427,12 +427,12 @@ impl Platform for GateSwap {
     // 批量撤销订单
     async fn cancel_orders(&mut self) -> Result<Vec<Order>, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.tick_size;
+        let ct_val = self.market.tick_size;
         let res_data = self.request.cancel_orders(symbol_array[1].to_string().to_lowercase(), self.symbol.to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| format_order_item(item.clone(), amount_size)).collect();
+            let result = res_data_json.iter().map(|item| format_order_item(item.clone(), ct_val)).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -587,7 +587,7 @@ impl Platform for GateSwap {
     }
 }
 
-pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal) -> Position {
+pub fn format_position_item(position: &serde_json::Value, ct_val: Decimal) -> Position {
     let mut position_mode = match position["mode"].as_str().unwrap_or("") {
         "single" => PositionModeEnum::Both,
         "dual_long" => PositionModeEnum::Long,
@@ -598,7 +598,7 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
         }
     };
     let size = Decimal::from_str(&position["size"].to_string()).unwrap();
-    let amount = size * amount_size;
+    let amount = size * ct_val;
     match position_mode {
         PositionModeEnum::Both => {
             position_mode = match amount {
@@ -621,7 +621,7 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
     }
 }
 
-pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
+pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
     debug!("format-order-start, gate_swap");
     debug!(?order);
     let status = order["status"].as_str().unwrap_or("");
@@ -629,8 +629,8 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
     let size = Decimal::from_str(&order["size"].to_string()).unwrap();
     let left = Decimal::from_str(&order["left"].to_string()).unwrap();
 
-    let amount = size * amount_size;
-    let deal_amount = (size - left) * amount_size;
+    let amount = size * ct_val;
+    let deal_amount = (size - left) * ct_val;
     let custom_status = if status == "finished" { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else {
         error!("Gate:格式化订单状态错误!\nformat_order_item:status={:?}", status);
         panic!("Gate:格式化订单状态错误!\nformat_order_item:status={:?}", status)

+ 7 - 7
standard/src/handle_info.rs

@@ -61,17 +61,17 @@ impl HandleSwapInfo {
         }
     }
     // 处理position信息
-    pub fn handle_position(exchange: ExchangeEnum, res_data: ResponseData, amount_size: Decimal) -> Vec<Position> {
+    pub fn handle_position(exchange: ExchangeEnum, res_data: ResponseData, ct_val: Decimal) -> Vec<Position> {
         match exchange {
             ExchangeEnum::BinanceSwap => {
                 error!("暂未提供此交易所方法!handle_position:{:?}", exchange);
                 panic!("暂未提供此交易所方法!handle_position:{:?}", exchange);
             }
             ExchangeEnum::GateSwap => {
-                gate_handle::handle_position(res_data, amount_size)
+                gate_handle::handle_position(res_data, ct_val)
             }
             ExchangeEnum::KucoinSwap => {
-                kucoin_handle::handle_position(res_data, amount_size)
+                kucoin_handle::handle_position(res_data, ct_val)
             }
             ExchangeEnum::BitgetSpot =>{
                 error!("暂未提供此交易所方法!handle_position:{:?}", exchange);
@@ -84,20 +84,20 @@ impl HandleSwapInfo {
         }
     }
     // 处理订单信息
-    pub fn handle_order(exchange: ExchangeEnum, res_data: ResponseData, amount_size: Decimal) -> SpecialOrder {
+    pub fn handle_order(exchange: ExchangeEnum, res_data: ResponseData, ct_val: Decimal) -> SpecialOrder {
         match exchange {
             ExchangeEnum::BinanceSwap => {
                 error!("暂未提供此交易所方法!handle_order:{:?}", exchange);
                 panic!("暂未提供此交易所方法!handle_order:{:?}", exchange);
             }
             ExchangeEnum::GateSwap => {
-                gate_handle::handle_order(res_data, amount_size)
+                gate_handle::handle_order(res_data, ct_val)
             }
             ExchangeEnum::KucoinSwap => {
-                kucoin_handle::handle_order(res_data, amount_size)
+                kucoin_handle::handle_order(res_data, ct_val)
             }
             ExchangeEnum::BitgetSpot =>{
-                bitget_spot_handle::handle_order(res_data, amount_size)
+                bitget_spot_handle::handle_order(res_data, ct_val)
             }
             _ => {
                 error!("参数错误!handle_order: {:?}",exchange);

+ 9 - 9
standard/src/kucoin_handle.rs

@@ -52,14 +52,14 @@ pub fn format_special_ticker(data: serde_json::Value, label: String) -> SpecialD
 }
 
 // 处理position信息
-pub fn handle_position(res_data: ResponseData, amount_size: Decimal) -> Vec<Position> {
+pub fn handle_position(res_data: ResponseData, ct_val: Decimal) -> Vec<Position> {
     let res_data_str = res_data.data;
     let res_data_json: serde_json::Value = serde_json::from_str(&res_data_str).unwrap();
-    let result = format_position_item(&res_data_json, amount_size);
+    let result = format_position_item(&res_data_json, ct_val);
     return vec![result];
 }
 
-pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal) -> Position {
+pub fn format_position_item(position: &serde_json::Value, ct_val: Decimal) -> Position {
     let symbol = position["symbol"].as_str().unwrap_or("");
     let real_leverage = Decimal::from_str(&position["realLeverage"].to_string()).unwrap();
     let currency = position["settleCurrency"].as_str().unwrap_or("");
@@ -69,7 +69,7 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
     let pos_margin = Decimal::from_str(&position["posMargin"].to_string()).unwrap();
 
     let current_qty = Decimal::from_str(&position["currentQty"].to_string()).unwrap();
-    let amount = current_qty * amount_size;
+    let amount = current_qty * ct_val;
     let position_mode = match amount {
         amount if amount > dec!(0) => PositionModeEnum::Long,
         amount if amount < dec!(0) => PositionModeEnum::Short,
@@ -88,12 +88,12 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
 }
 
 // 处理order信息
-pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrder {
+pub fn handle_order(res_data: ResponseData, ct_val: Decimal) -> SpecialOrder {
     let res_data_str = res_data.data;
     let res_data_json: Vec<serde_json::Value> = vec![serde_json::from_str(&*res_data_str).unwrap()];
     let mut order_info = Vec::new();
     for item in res_data_json.iter() {
-        order_info.push(format_order_item(item.clone(), amount_size));
+        order_info.push(format_order_item(item.clone(), ct_val));
     }
     SpecialOrder {
         name: res_data.label,
@@ -102,7 +102,7 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
 }
 
 // ws处理
-pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
+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_str().unwrap()).unwrap();
     let status = order["status"].as_str().unwrap_or("");
@@ -111,8 +111,8 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
 
     let avg_price = price;
 
-    let amount = size * amount_size;
-    let deal_amount = filled_size * amount_size;
+    let amount = size * ct_val;
+    let deal_amount = filled_size * ct_val;
     let custom_status;
      if ["filled", "canceled"].contains(&type_) {
          custom_status = "REMOVE".to_string();

+ 25 - 25
standard/src/kucoin_swap.rs

@@ -112,12 +112,12 @@ impl Platform for KucoinSwap {
 
     async fn get_position(&mut self) -> Result<Vec<Position>, Error> {
         let symbol_format = format!("{}M", utils::format_symbol(self.symbol.clone(), ""));
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_position(symbol_format).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = kucoin_handle::format_position_item(&res_data_json, amount_size);
+            let result = kucoin_handle::format_position_item(&res_data_json, ct_val);
             Ok(vec![result])
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -126,14 +126,14 @@ impl Platform for KucoinSwap {
 
     async fn get_positions(&mut self) -> Result<Vec<Position>, Error> {
         let symbol_array: Vec<&str> = self.symbol.split("_").collect();
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_positions(symbol_array[1].to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
             let mut result = Vec::new();
             for item in res_data_json.iter() {
-                result.push(kucoin_handle::format_position_item(item, amount_size))
+                result.push(kucoin_handle::format_position_item(item, ct_val))
             }
             Ok(result)
         } else {
@@ -203,26 +203,26 @@ impl Platform for KucoinSwap {
                     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"].to_string()).unwrap();
-                    let amount_size = Decimal::from_str(&value["multiplier"].to_string()).unwrap();
+                    let ct_val = Decimal::from_str(&value["multiplier"].to_string()).unwrap();
                     let min_qty = Decimal::from_str(&value["lotSize"].to_string()).unwrap();
 
                     let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
-                    let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
-                    let min_notional = min_qty * amount_size;
+                    let amount_precision = Decimal::from_u32(ct_val.scale()).unwrap();
+                    let min_notional = min_qty * ct_val;
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
                         base_asset,
                         quote_asset,
                         tick_size,
-                        amount_size,
+                        amount_size: Default::default(),
+                        ct_val,
                         price_precision,
                         amount_precision,
                         min_qty,
                         max_qty: Decimal::from_str(&value["maxOrderQty"].to_string()).unwrap(),
                         min_notional,
                         max_notional: Decimal::from_str(&value["maxPrice"].to_string()).unwrap(),
-                        ct_val: Default::default(),
                     };
                     Ok(result)
                 }
@@ -248,26 +248,26 @@ impl Platform for KucoinSwap {
                     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"].to_string()).unwrap();
-                    let amount_size = Decimal::from_str(&value["multiplier"].to_string()).unwrap();
+                    let ct_val = Decimal::from_str(&value["multiplier"].to_string()).unwrap();
                     let min_qty = Decimal::from_str(&value["lotSize"].to_string()).unwrap();
 
                     let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
-                    let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
-                    let min_notional = min_qty * amount_size;
+                    let amount_precision = Decimal::from_u32(ct_val.scale()).unwrap();
+                    let min_notional = min_qty * ct_val;
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
                         base_asset,
                         quote_asset,
                         tick_size,
-                        amount_size,
+                        amount_size: Default::default(),
+                        ct_val,
                         price_precision,
                         amount_precision,
                         min_qty,
                         max_qty: Decimal::from_str(&value["maxOrderQty"].to_string()).unwrap(),
                         min_notional,
                         max_notional: Decimal::from_str(&value["maxPrice"].to_string()).unwrap(),
-                        ct_val: Default::default(),
                     };
                     Ok(result)
                 }
@@ -278,12 +278,12 @@ impl Platform for KucoinSwap {
     }
 
     async fn get_order_detail(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error> {
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_orders_details(order_id.to_string(), custom_id.to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = format_order_item(res_data_json, amount_size);
+            let result = format_order_item(res_data_json, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -292,14 +292,14 @@ impl Platform for KucoinSwap {
 
     async fn get_orders_list(&mut self, status: &str) -> Result<Vec<Order>, Error> {
         let symbol_format = format!("{}M", utils::format_symbol(self.symbol.clone(), ""));
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_orders(status.to_string(), symbol_format.clone()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
             let order_list: Vec<serde_json::Value> = res_data_json["items"].as_array().unwrap().clone();
             let order_info: Vec<&serde_json::Value> = order_list.iter().filter(|item| item["symbol"].as_str().unwrap_or("") == symbol_format.clone()).collect();
-            let result = order_info.iter().map(|&item| format_order_item(item.clone(), amount_size)).collect();
+            let result = order_info.iter().map(|&item| format_order_item(item.clone(), ct_val)).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -308,7 +308,7 @@ impl Platform for KucoinSwap {
 
     async fn take_order(&mut self, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error> {
         let symbol_format = format!("{}M", utils::format_symbol(self.symbol.clone(), ""));
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let mut params = json!({
             "clientOid": custom_id,
             "symbol": symbol_format,
@@ -316,7 +316,7 @@ impl Platform for KucoinSwap {
             "reduceOnly":false,
             "price": price.to_string(),
         });
-        let size = (amount / amount_size).floor();
+        let size = (amount / ct_val).floor();
         params["size"] = json!(size);
         match origin_side {
             "kd" => {
@@ -358,7 +358,7 @@ impl Platform for KucoinSwap {
 
     async fn take_order_symbol(&mut self, symbol: String, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error> {
         let symbol_format = format!("{}M", utils::format_symbol(symbol.clone(), ""));
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let mut params = json!({
             "clientOid": custom_id,
             "symbol": symbol_format,
@@ -366,7 +366,7 @@ impl Platform for KucoinSwap {
             "reduceOnly":false,
             "price": price.to_string(),
         });
-        let size = (amount / amount_size).floor();
+        let size = (amount / ct_val).floor();
         params["size"] = json!(size);
         match origin_side {
             "kd" => {
@@ -617,15 +617,15 @@ impl Platform for KucoinSwap {
     }
 }
 
-pub fn format_order_item(order: Value, amount_size: Decimal) -> Order {
+pub fn format_order_item(order: Value, ct_val: Decimal) -> Order {
     let price = Decimal::from_str(order["price"].as_str().unwrap()).unwrap();
     let size = Decimal::from_str(&order["size"].to_string()).unwrap();
     let status = order["status"].as_str().unwrap_or("");
     let filled_size = Decimal::from_str(&order["filledSize"].to_string()).unwrap();
     let filled_value = Decimal::from_str(order["filledValue"].as_str().unwrap()).unwrap();
 
-    let amount = size * amount_size;
-    let deal_amount = filled_size * amount_size;
+    let amount = size * ct_val;
+    let deal_amount = filled_size * ct_val;
     let avg_price = if deal_amount.is_zero() { dec!(0) } else { filled_value / deal_amount };
     let custom_status;
     if ["cancelled", "closed", "finished"].contains(&status) {

+ 2 - 2
standard/src/lib.rs

@@ -332,13 +332,13 @@ pub struct Market {
     pub quote_asset: String,
     pub tick_size: Decimal,
     pub amount_size: Decimal,
+    pub ct_val: Decimal,
     pub price_precision: Decimal,
     pub amount_precision: Decimal,
     pub min_qty: Decimal,
     pub max_qty: Decimal,
     pub min_notional: Decimal,
     pub max_notional: Decimal,
-    pub ct_val: Decimal,
 }
 
 impl Market {
@@ -349,13 +349,13 @@ impl Market {
             quote_asset: "".to_string(),
             tick_size: Default::default(),
             amount_size: Default::default(),
+            ct_val: Default::default(),
             price_precision: Default::default(),
             amount_precision: Default::default(),
             min_qty: Default::default(),
             max_qty: Default::default(),
             min_notional: Default::default(),
             max_notional: Default::default(),
-            ct_val: Default::default(),
         }
     }
 }

+ 9 - 9
standard/src/okx_handle.rs

@@ -28,13 +28,13 @@ pub fn format_account_info(data: serde_json::Value) -> Account {
 }
 
 // 处理order信息
-pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrder {
+pub fn handle_order(res_data: ResponseData, ct_val: Decimal) -> SpecialOrder {
     let res_data_str = res_data.data;
     let res_data_json: Vec<serde_json::Value> = serde_json::from_str(&*res_data_str).unwrap();
     trace!(?res_data_json);
     let mut order_info = Vec::new();
     for item in res_data_json.iter() {
-        order_info.push(format_order_item(item.clone(), amount_size));
+        order_info.push(format_order_item(item.clone(), ct_val));
     }
     trace!(?order_info);
     SpecialOrder {
@@ -44,7 +44,7 @@ pub fn handle_order(res_data: ResponseData, amount_size: Decimal) -> SpecialOrde
 }
 
 // 处理订单信息
-pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
+pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
     let price = Decimal::from_str(order["px"].as_str().unwrap()).unwrap();
     let size = Decimal::from_str(order["sz"].as_str().unwrap()).unwrap();
     let status = order["state"].as_str().unwrap_or("");
@@ -52,8 +52,8 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
 
     let avg_price = Decimal::from_str(order["avgPx"].as_str().unwrap()).unwrap();
 
-    let amount = size * amount_size;
-    let deal_amount = filled_size * amount_size;
+    let amount = size * ct_val;
+    let deal_amount = filled_size * ct_val;
     let custom_status = if ["canceled", "filled", "mmp_canceled"].contains(&status) {
         "REMOVE".to_string()
     } else if ["live", "partially_filled"].contains(&status) {
@@ -117,15 +117,15 @@ pub fn format_special_ticker(data: serde_json::Value, label: String) -> SpecialD
 }
 
 // 处理position信息
-pub fn handle_position(res_data: ResponseData, amount_size: Decimal) -> Vec<Position> {
+pub fn handle_position(res_data: ResponseData, ct_val: Decimal) -> Vec<Position> {
     let res_data_str = res_data.data;
     let res_data_json: serde_json::Value = serde_json::from_str(&res_data_str).unwrap();
     let position_data = res_data_json[0]["posData"].clone();
-    let result = format_position_item(position_data, amount_size);
+    let result = format_position_item(position_data, ct_val);
     return vec![result];
 }
 
-pub fn format_position_item(position: serde_json::Value, amount_size: Decimal) -> Position {
+pub fn format_position_item(position: serde_json::Value, ct_val: Decimal) -> Position {
     let symbol = position["instId"].as_str().unwrap_or("");
     let real_leverage = dec!(-1);
     let currency = position["ccy"].as_str().unwrap_or("");
@@ -135,7 +135,7 @@ pub fn format_position_item(position: serde_json::Value, amount_size: Decimal) -
     let pos_margin = Decimal::from_str(&position["posSide"].to_string()).unwrap();
 
     let current_qty = Decimal::from_str(&position["pos"].to_string()).unwrap();
-    let amount = current_qty * amount_size;
+    let amount = current_qty * ct_val;
     let position_mode = match amount {
         amount if amount > dec!(0) => PositionModeEnum::Long,
         amount if amount < dec!(0) => PositionModeEnum::Short,

+ 25 - 25
standard/src/okx_swap.rs

@@ -104,7 +104,7 @@ impl Platform for OkxSwap {
 
     async fn get_position(&mut self) -> Result<Vec<Position>, Error> {
         let symbol_format = utils::format_symbol(self.symbol.to_string(), "-");
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_positions("SWAP".to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
@@ -116,7 +116,7 @@ impl Platform for OkxSwap {
                     panic!("Okx:获取Position信息错误!\nget_position:res_data={:?}", res_data_str)
                 }
                 Some(value) => {
-                    let result = okx_handle::format_position_item(value.clone(), amount_size);
+                    let result = okx_handle::format_position_item(value.clone(), ct_val);
                     Ok(vec![result])
                 }
             }
@@ -126,12 +126,12 @@ impl Platform for OkxSwap {
     }
 
     async fn get_positions(&mut self) -> Result<Vec<Position>, Error> {
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_positions("SWAP".to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| okx_handle::format_position_item(item.clone(), amount_size)).collect();
+            let result = res_data_json.iter().map(|item| okx_handle::format_position_item(item.clone(), ct_val)).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -214,28 +214,28 @@ impl Platform for OkxSwap {
                     let base_asset = value["ctValCcy"].as_str().unwrap_or("").to_string();
                     let quote_asset = value["settleCcy"].as_str().unwrap_or("").to_string();
                     let tick_size = Decimal::from_str(&value["tickSz"].as_str().unwrap()).unwrap();
-                    let amount_size = Decimal::from_str(&value["ctVal"].as_str().unwrap()).unwrap();
+                    let ct_val = Decimal::from_str(&value["ctVal"].as_str().unwrap()).unwrap();
                     let min_qty = Decimal::from_str(&value["minSz"].as_str().unwrap()).unwrap();
                     let max_qty = Decimal::from_str(&value["maxLmtSz"].as_str().unwrap()).unwrap();
 
                     let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
-                    let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
-                    let min_notional = min_qty * amount_size;
-                    let max_notional = max_qty * amount_size;
+                    // let amount_precision = Decimal::from_u32(amount__size.scale()).unwrap();
+                    let min_notional = min_qty * ct_val;
+                    let max_notional = max_qty * ct_val;
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
                         base_asset,
                         quote_asset,
                         tick_size,
-                        amount_size,
                         price_precision,
-                        amount_precision,
+                        amount_precision: Default::default(),
                         min_qty,
                         max_qty,
                         min_notional,
                         max_notional,
-                        ct_val: Decimal::from_str(&value["ctVal"].as_str().unwrap()).unwrap(),
+                        ct_val,
+                        amount_size: Default::default(),
                     };
                     Ok(result)
                 }
@@ -261,28 +261,28 @@ impl Platform for OkxSwap {
                     let base_asset = value["ctValCcy"].as_str().unwrap_or("").to_string();
                     let quote_asset = value["settleCcy"].as_str().unwrap_or("").to_string();
                     let tick_size = Decimal::from_str(&value["tickSz"].as_str().unwrap()).unwrap();
-                    let amount_size = Decimal::from_str(&value["ctVal"].as_str().unwrap()).unwrap();
+                    let ct_val = Decimal::from_str(&value["ctVal"].as_str().unwrap()).unwrap();
                     let min_qty = Decimal::from_str(&value["minSz"].as_str().unwrap()).unwrap();
                     let max_qty = Decimal::from_str(&value["maxLmtSz"].as_str().unwrap()).unwrap();
 
                     let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
-                    let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
-                    let min_notional = min_qty * amount_size;
-                    let max_notional = max_qty * amount_size;
+                    // let amount_precision = Decimal::from_u32(amount__size.scale()).unwrap();
+                    let min_notional = min_qty * ct_val;
+                    let max_notional = max_qty * ct_val;
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
                         base_asset,
                         quote_asset,
                         tick_size,
-                        amount_size,
                         price_precision,
-                        amount_precision,
+                        amount_precision: Default::default(),
                         min_qty,
                         max_qty,
                         min_notional,
                         max_notional,
-                        ct_val: Decimal::from_str(&value["ctVal"].as_str().unwrap()).unwrap(),
+                        ct_val,
+                        amount_size: Default::default(),
                     };
                     Ok(result)
                 }
@@ -293,13 +293,13 @@ impl Platform for OkxSwap {
     }
 
     async fn get_order_detail(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error> {
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_order(self.symbol.clone(), order_id.to_string(), custom_id.to_string()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
             let order_info = res_data_json[0].clone();
-            let result = okx_handle::format_order_item(order_info, amount_size);
+            let result = okx_handle::format_order_item(order_info, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -308,12 +308,12 @@ impl Platform for OkxSwap {
 
     async fn get_orders_list(&mut self, _status: &str) -> Result<Vec<Order>, Error> {
         let symbol_format = utils::format_symbol(self.symbol.clone(), "-");
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let res_data = self.request.get_incomplete_order(symbol_format.clone()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
-            let result = res_data_json.iter().map(|item| okx_handle::format_order_item(item.clone(), amount_size)).collect();
+            let result = res_data_json.iter().map(|item| okx_handle::format_order_item(item.clone(), ct_val)).collect();
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
@@ -322,7 +322,7 @@ impl Platform for OkxSwap {
 
     async fn take_order(&mut self, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error> {
         let symbol_format = utils::format_symbol(self.symbol.clone(), "-");
-        let amount_size = self.market.amount_size;
+        let ct_val = self.market.ct_val;
         let mut params = json!({
             "tdMode": "cross",
             "clOrdId": custom_id.to_string(),
@@ -330,7 +330,7 @@ impl Platform for OkxSwap {
             "px": price.to_string(),
             "ordType": "limit",
         });
-        let size = (amount / amount_size).floor();
+        let size = (amount / ct_val).floor();
         params["sz"] = json!(size);
         match origin_side {
             "kd" => {
@@ -351,7 +351,7 @@ impl Platform for OkxSwap {
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            let result = okx_handle::format_order_item(res_data_json, amount_size);
+            let result = okx_handle::format_order_item(res_data_json, ct_val);
             Ok(result)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))

+ 1 - 1
strategy/src/exchange_disguise.rs

@@ -240,7 +240,7 @@ async fn kucoin_swap_run(bool_v1 :Arc<AtomicBool>, type_num: i8, quant_arc: Arc<
         // trade
         let mut max_buy = Decimal::ZERO;
         let mut min_sell = Decimal::ZERO;
-        let multiplier = bot_arc_clone.lock().await.platform_rest.get_self_market().amount_size;
+        let multiplier = bot_arc_clone.lock().await.platform_rest.get_self_market().ct_val;
         loop {
             sleep(Duration::from_millis(1)).await;
             let mut trace_stack = TraceStack::default();

+ 2 - 2
strategy/src/quant.rs

@@ -170,7 +170,6 @@ impl Quant {
                 base_asset: "".to_string(),
                 quote_asset: "".to_string(),
                 tick_size: Default::default(),
-                amount_size: Default::default(),
                 price_precision: Default::default(),
                 amount_precision: Default::default(),
                 min_qty: Default::default(),
@@ -178,6 +177,7 @@ impl Quant {
                 min_notional: Default::default(),
                 max_notional: Default::default(),
                 ct_val: Default::default(),
+                amount_size: Default::default(),
             },
             platform_rest: match exchange.as_str() {
                 "kucoin_usdt_swap" => {
@@ -1136,7 +1136,7 @@ impl Quant {
         self.strategy.equity = self.strategy.start_equity.clone();
         self.strategy.total_amount = self.strategy.equity * self.strategy.lever_rate / self.strategy.mp;
         // 获取数量精度
-        self.strategy.step_size = self.market.amount_size.clone();
+        self.strategy.step_size = self.market.ct_val.clone();
         if self.strategy.step_size > Decimal::ONE {
             self.strategy.step_size = self.strategy.step_size.trunc();
         }