浏览代码

止损的基本封装完成(gate部分)

skyffire 1 年之前
父节点
当前提交
ca56879279

+ 4 - 4
exchanges/src/gate_swap_rest.rs

@@ -594,10 +594,10 @@ impl GateSwapRest {
 
         match json_value {
             Ok(data) => {
-                let message = data["label"].as_str().unwrap();
-                let mut error = ResponseData::error(self.label.clone(), message.to_string());
-                error.message = format!("请求地址:{}, 请求参数:{}", base_url, params);
-                error
+                let label = data["label"].as_str().unwrap();
+                let response_message =  format!("报错内容:{}, 请求地址:{}, 请求参数:{}, ", label, base_url, params);
+
+                ResponseData::error(self.label.clone(), response_message)
             }
             Err(e) => {
                 error!("解析错误:{:?}", e);

+ 3 - 4
standard/src/binance_swap.rs

@@ -6,11 +6,10 @@ use async_trait::async_trait;
 use rust_decimal::Decimal;
 use rust_decimal::prelude::FromPrimitive;
 use rust_decimal_macros::dec;
-use serde_json::Value;
 use tokio::sync::mpsc::Sender;
 use tokio::time::Instant;
 use tracing::{error, warn};
-use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, utils, PositionModeEnum};
+use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, utils, PositionModeEnum, PriceOrder};
 use exchanges::binance_swap_rest::BinanceSwapRest;
 use global::trace_stack::TraceStack;
 
@@ -339,11 +338,11 @@ impl Platform for BinanceSwap {
     async fn cancel_orders_all(&mut self) -> Result<Vec<Order>, Error> { Err(Error::new(ErrorKind::NotFound, "binance_swap:该交易所方法未实现".to_string())) }
 
 
-    async fn take_stop_loss_order(&mut self, _stop_price: Decimal, _price: Decimal, _side: &str) -> Result<Value, Error> {
+    async fn take_stop_loss_order(&mut self, _stop_price: Decimal, _price: Decimal, _side: &str) -> Result<PriceOrder, Error> {
         Err(Error::new(ErrorKind::NotFound, "binance_swap:该交易所方法未实现".to_string()))
     }
 
-    async fn cancel_stop_loss_order(&mut self, _order_id: &str) -> Result<Value, Error> {
+    async fn cancel_stop_loss_order(&mut self, _order_id: &str) -> Result<PriceOrder, Error> {
         Err(Error::new(ErrorKind::NotFound, "binance_swap:该交易所方法未实现".to_string()))
     }
 

+ 3 - 3
standard/src/bybit_swap.rs

@@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
 use tokio::time::Instant;
 use tracing::{error, trace};
 use exchanges::bybit_swap_rest::BybitSwapRest;
-use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum};
+use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum, PriceOrder};
 use global::trace_stack::TraceStack;
 
 #[derive(Debug, Clone, Deserialize, Serialize)]
@@ -483,11 +483,11 @@ impl Platform for BybitSwap {
         }
     }
 
-    async fn take_stop_loss_order(&mut self, _stop_price: Decimal, _price: Decimal, _side: &str) -> Result<Value, Error> {
+    async fn take_stop_loss_order(&mut self, _stop_price: Decimal, _price: Decimal, _side: &str) -> Result<PriceOrder, Error> {
         Err(Error::new(ErrorKind::NotFound, "bybit_swap:该交易所方法未实现".to_string()))
     }
 
-    async fn cancel_stop_loss_order(&mut self, _order_id: &str) -> Result<Value, Error> {
+    async fn cancel_stop_loss_order(&mut self, _order_id: &str) -> Result<PriceOrder, Error> {
         Err(Error::new(ErrorKind::NotFound, "bybit_swap:该交易所方法未实现".to_string()))
     }
 

+ 13 - 8
standard/src/gate_swap.rs

@@ -7,11 +7,11 @@ use futures::stream::FuturesUnordered;
 use futures::TryStreamExt;
 use rust_decimal::Decimal;
 use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
-use serde_json::{json, Value};
+use serde_json::{json};
 use tokio::spawn;
 use tokio::time::Instant;
 use tracing::{error, trace};
-use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum};
+use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum, PriceOrder};
 use exchanges::gate_swap_rest::GateSwapRest;
 use global::trace_stack::TraceStack;
 
@@ -469,11 +469,10 @@ impl Platform for GateSwap {
         }
     }
 
-    async fn take_stop_loss_order(&mut self, stop_price: Decimal, price: Decimal, side: &str) -> Result<Value, Error>
-    {
+    async fn take_stop_loss_order(&mut self, stop_price: Decimal, price: Decimal, side: &str) -> Result<PriceOrder, Error> {
         let mut params = json!({});
         let mut initial = json!({
-            "contract": "XRP_USDT",
+            "contract": self.symbol,
 
             "price": price.to_string(),
 
@@ -529,20 +528,24 @@ impl Platform for GateSwap {
         let base_coin = symbol_split[1].to_string();
         let response_data = self.request.place_price_order(base_coin, params).await;
         if response_data.code == "200" {
-            Ok(response_data.data)
+            Ok(PriceOrder {
+                id: response_data.data["id"].to_string(),
+            })
         } else {
             Err(Error::new(ErrorKind::Other, response_data.to_string()))
         }
     }
 
-    async fn cancel_stop_loss_order(&mut self, order_id: &str) -> Result<Value, Error> {
+    async fn cancel_stop_loss_order(&mut self, order_id: &str) -> Result<PriceOrder, Error> {
         let binding = self.symbol.clone().to_lowercase();
         let symbol_split: Vec<&str> = binding.split("_").collect();
         let base_coin = symbol_split[1].to_string();
 
         let response_data = self.request.cancel_price_order(base_coin, order_id.to_string()).await;
         if response_data.code == "200" {
-            Ok(response_data.data)
+            Ok(PriceOrder {
+                id: order_id.to_string(),
+            })
         } else {
             Err(Error::new(ErrorKind::Other, response_data.to_string()))
         }
@@ -615,6 +618,8 @@ impl Platform for GateSwap {
                         result.trace_stack = ts;
 
                         self_clone.order_sender.send(result).await.unwrap();
+
+
                     }
                     Err(error) => {
                         let mut err_order = Order::new();

+ 7 - 3
standard/src/lib.rs

@@ -4,7 +4,6 @@ use std::fmt::Formatter;
 use std::io::{Error};
 use async_trait::async_trait;
 use rust_decimal::Decimal;
-use serde_json::Value;
 use tokio::time::Instant;
 use global::trace_stack::TraceStack;
 
@@ -285,6 +284,11 @@ pub struct Order {
     pub trace_stack: TraceStack,
 }
 
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct PriceOrder {
+    pub id: String,
+}
+
 impl Order {
     pub fn new() -> Order {
         Order {
@@ -556,10 +560,10 @@ pub trait Platform {
     /// - stop_price: 触发价
     /// - price: 委托价,0就市价委托
     /// - side: 止损哪个方向[long多单,short空单]
-    async fn take_stop_loss_order(&mut self, stop_price: Decimal, price: Decimal, side: &str) -> Result<Value, Error>;
+    async fn take_stop_loss_order(&mut self, stop_price: Decimal, price: Decimal, side: &str) -> Result<PriceOrder, Error>;
     /// 撤销止损订单
     /// - order_id: 需要撤销的id
-    async fn cancel_stop_loss_order(&mut self, order_id: &str) -> Result<Value, Error>;
+    async fn cancel_stop_loss_order(&mut self, order_id: &str) -> Result<PriceOrder, Error>;
     // 设置持仓模式
     async fn set_dual_mode(&mut self, coin: &str, is_dual_mode: bool) -> Result<String, Error>;
     // 更新双持仓模式下杠杆

+ 525 - 526
standard/tests/exchange_test.rs

@@ -1,21 +1,15 @@
 use std::collections::{BTreeMap};
 use std::io::{Error};
-use std::sync::Arc;
-use std::sync::atomic::AtomicBool;
-use futures::StreamExt;
-use rust_decimal_macros::dec;
 use tokio::sync::mpsc::{channel, Receiver, Sender};
-use tokio::sync::Mutex;
-use tokio::try_join;
-use tracing::{error, trace};
+use tracing::{error};
 // use exchanges::binance_spot_ws::{BinanceSpotLogin, BinanceSpotSubscribeType, BinanceSpotWs, BinanceSpotWsType};
 // use exchanges::binance_swap_ws::{BinanceSwapLogin, BinanceSwapSubscribeType, BinanceSwapWs, BinanceSwapWsType};
 // use exchanges::kucoin_swap_ws::{KucoinSwapLogin, KucoinSwapSubscribeType, KucoinSwapWs, KucoinSwapWsType};
 // use exchanges::kucoin_spot_ws::{KucoinSpotLogin, KucoinSpotSubscribeType, KucoinSpotWs, KucoinSpotWsType};
 // use exchanges::gate_swap_ws::{GateSwapLogin, GateSwapSubscribeType, GateSwapWs, GateSwapWsType};
 // use exchanges::bitget_spot_ws::{BitgetSpotLogin, BitgetSpotSubscribeType, BitgetSpotWs, BitgetSpotWsType};
-use exchanges::okx_swap_ws::{OkxSwapLogin, OkxSwapSubscribeType, OkxSwapWs, OkxSwapWsType};
-use exchanges::response_base::ResponseData;
+// use exchanges::okx_swap_ws::{OkxSwapLogin, OkxSwapSubscribeType, OkxSwapWs, OkxSwapWsType};
+// use exchanges::response_base::ResponseData;
 use standard::exchange::{Exchange, ExchangeEnum};
 // use standard::{binance_spot_handle, Order, Platform, utils};
 // use standard::{binance_handle, Order, Platform, utils};
@@ -23,7 +17,7 @@ use standard::exchange::{Exchange, ExchangeEnum};
 // use standard::{kucoin_spot_handle, Order, Platform, utils};
 // use standard::{gate_handle, Order, Platform, utils};
 // use standard::{bitget_spot_handle, Order, Platform, utils};
-use standard::{okx_handle, Order, Platform, utils};
+use standard::{Order, Platform, utils};
 
 // 创建实体
 #[allow(dead_code)]
@@ -42,14 +36,14 @@ pub async fn test_new_exchange(exchange: ExchangeEnum, symbol: &str) -> Box<dyn
             params.insert("secret_key".to_string(), secret_key);
             Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
         }
-        ExchangeEnum::BinanceSpot => {
-            let mut params: BTreeMap<String, String> = BTreeMap::new();
-            let access_key = account_info.binance_access_key;
-            let secret_key = account_info.binance_secret_key;
-            params.insert("access_key".to_string(), access_key);
-            params.insert("secret_key".to_string(), secret_key);
-            Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
-        }
+        // ExchangeEnum::BinanceSpot => {
+        //     let mut params: BTreeMap<String, String> = BTreeMap::new();
+        //     let access_key = account_info.binance_access_key;
+        //     let secret_key = account_info.binance_secret_key;
+        //     params.insert("access_key".to_string(), access_key);
+        //     params.insert("secret_key".to_string(), secret_key);
+        //     Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // }
         ExchangeEnum::GateSwap => {
             let mut params: BTreeMap<String, String> = BTreeMap::new();
             let access_key = account_info.gate_access_key;
@@ -58,521 +52,526 @@ pub async fn test_new_exchange(exchange: ExchangeEnum, symbol: &str) -> Box<dyn
             params.insert("secret_key".to_string(), secret_key);
             Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
         }
-        ExchangeEnum::GateSpot => {
-            let mut params: BTreeMap<String, String> = BTreeMap::new();
-            let access_key = account_info.gate_access_key;
-            let secret_key = account_info.gate_secret_key;
-            params.insert("access_key".to_string(), access_key);
-            params.insert("secret_key".to_string(), secret_key);
-            Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
-        }
-        ExchangeEnum::KucoinSwap => {
-            let mut params: BTreeMap<String, String> = BTreeMap::new();
-            let access_key = account_info.kucoin_access_key;
-            let secret_key = account_info.kucoin_secret_key;
-            let pass_key = account_info.kucoin_pass;
-            params.insert("access_key".to_string(), access_key);
-            params.insert("secret_key".to_string(), secret_key);
-            params.insert("pass_key".to_string(), pass_key);
-            Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
-        }
-        ExchangeEnum::KucoinSpot => {
-            let mut params: BTreeMap<String, String> = BTreeMap::new();
-            let access_key = account_info.kucoin_access_key;
-            let secret_key = account_info.kucoin_secret_key;
-            let pass_key = account_info.kucoin_pass;
-            params.insert("access_key".to_string(), access_key);
-            params.insert("secret_key".to_string(), secret_key);
-            params.insert("pass_key".to_string(), pass_key);
-            Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
-        }
-        ExchangeEnum::OkxSwap => {
-            let mut params: BTreeMap<String, String> = BTreeMap::new();
-            let access_key = account_info.okx_access_key;
-            let secret_key = account_info.okx_secret_key;
-            let pass_key = account_info.okx_pass;
-            params.insert("access_key".to_string(), access_key);
-            params.insert("secret_key".to_string(), secret_key);
-            params.insert("pass_key".to_string(), pass_key);
-            Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
-        }
-        ExchangeEnum::BitgetSpot => {
-            let mut params: BTreeMap<String, String> = BTreeMap::new();
-            let access_key = account_info.bitget_access_key;
-            let secret_key = account_info.bitget_secret_key;
-            let pass_key = account_info.bitget_pass;
-            params.insert("access_key".to_string(), access_key);
-            params.insert("secret_key".to_string(), secret_key);
-            params.insert("pass_key".to_string(), pass_key);
-            Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // ExchangeEnum::GateSpot => {
+        //     let mut params: BTreeMap<String, String> = BTreeMap::new();
+        //     let access_key = account_info.gate_access_key;
+        //     let secret_key = account_info.gate_secret_key;
+        //     params.insert("access_key".to_string(), access_key);
+        //     params.insert("secret_key".to_string(), secret_key);
+        //     Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // }
+        // ExchangeEnum::KucoinSwap => {
+        //     let mut params: BTreeMap<String, String> = BTreeMap::new();
+        //     let access_key = account_info.kucoin_access_key;
+        //     let secret_key = account_info.kucoin_secret_key;
+        //     let pass_key = account_info.kucoin_pass;
+        //     params.insert("access_key".to_string(), access_key);
+        //     params.insert("secret_key".to_string(), secret_key);
+        //     params.insert("pass_key".to_string(), pass_key);
+        //     Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // }
+        // ExchangeEnum::KucoinSpot => {
+        //     let mut params: BTreeMap<String, String> = BTreeMap::new();
+        //     let access_key = account_info.kucoin_access_key;
+        //     let secret_key = account_info.kucoin_secret_key;
+        //     let pass_key = account_info.kucoin_pass;
+        //     params.insert("access_key".to_string(), access_key);
+        //     params.insert("secret_key".to_string(), secret_key);
+        //     params.insert("pass_key".to_string(), pass_key);
+        //     Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // }
+        // ExchangeEnum::OkxSwap => {
+        //     let mut params: BTreeMap<String, String> = BTreeMap::new();
+        //     let access_key = account_info.okx_access_key;
+        //     let secret_key = account_info.okx_secret_key;
+        //     let pass_key = account_info.okx_pass;
+        //     params.insert("access_key".to_string(), access_key);
+        //     params.insert("secret_key".to_string(), secret_key);
+        //     params.insert("pass_key".to_string(), pass_key);
+        //     Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // }
+        // ExchangeEnum::BitgetSpot => {
+        //     let mut params: BTreeMap<String, String> = BTreeMap::new();
+        //     let access_key = account_info.bitget_access_key;
+        //     let secret_key = account_info.bitget_secret_key;
+        //     let pass_key = account_info.bitget_pass;
+        //     params.insert("access_key".to_string(), access_key);
+        //     params.insert("secret_key".to_string(), secret_key);
+        //     params.insert("pass_key".to_string(), pass_key);
+        //     Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
+        // }
+        _ => {
+            panic!("exchange_test_110 不认识的交易所。")
         }
     }
 }
 
 #[allow(dead_code)]
-pub async fn test_new_exchange_wss<T>(exchange: ExchangeEnum, symbol: &str, subscriber_type: T, mold: &str) where Vec<OkxSwapSubscribeType>: From<T> {
+// pub async fn test_new_exchange_wss<T>(exchange: ExchangeEnum, symbol: &str, subscriber_type: T, mold: &str)
+//     where Vec<OkxSwapSubscribeType>: From<T> {
+pub async fn test_new_exchange_wss(exchange: ExchangeEnum, _symbol: &str, _mold: &str) {
     utils::proxy_handle();
-    let account_info = global::account_info::get_account_info("../test_account.toml");
+    // let account_info = global::account_info::get_account_info("../test_account.toml");
     match exchange {
-        ExchangeEnum::BinanceSpot => {
-            // let symbol_format = utils::format_symbol(symbol.to_string(), "").to_uppercase();
-            // trace!(symbol_format);
-            // let name = format!("binance_spot@{}", symbol.to_string().to_lowercase());
-            // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            // let write_tx_am = Arc::new(Mutex::new(write_tx));
-            // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-            //
-            // let params = BinanceSpotLogin {
-            //     api_key: account_info.binance_access_key,
-            //     api_secret: account_info.binance_secret_key,
-            // };
-            // let mut exchange_wss;
-            // exchange_wss = BinanceSpotWs::new_label(name, false, Option::from(params), BinanceSpotWsType::PublicAndPrivate);
-            // exchange_wss.set_symbols(vec![symbol_format]);
-            // exchange_wss.set_subscribe(subscriber_type.into());
-            //
-            //
-            // let mold_arc = Arc::new(mold.to_string());
-            // //读取
-            // tokio::spawn(async move {
-            //     let mold_clone = Arc::clone(&mold_arc);
-            //     loop {
-            //         if let Some(data) = read_rx.next().await {
-            //             trace!("原始数据 data:{:?}",data);
-            //             match mold_clone.as_str() {
-            //                 "depth" => {
-            //                     if data.data != "" {
-            //                         let result = binance_spot_handle::handle_special_depth(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "ticker" => {
-            //                     if data.data != "" {
-            //                         let result = binance_spot_handle::handle_special_ticker(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 _ => {
-            //                     error!("没有该命令!mode={}", mold_clone);
-            //                     panic!("没有该命令!mode={}", mold_clone)
-            //                 }
-            //             }
-            //         }
-            //     };
-            // });
-            //
-            // let t1 = tokio::spawn(async move {
-            //     //链接
-            //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-            //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            // });
-            // try_join!(t1).unwrap();
-        }
-        ExchangeEnum::BinanceSwap => {
-            // let symbol_format = utils::format_symbol(symbol.to_string(), "").to_uppercase();
-            // trace!(symbol_format);
-            // let name = format!("binance_swap@{}", symbol.to_string().to_lowercase());
-            // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            // let write_tx_am = Arc::new(Mutex::new(write_tx));
-            // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-            //
-            // let params = BinanceSwapLogin {
-            //     api_key: account_info.binance_access_key,
-            //     api_secret: account_info.binance_secret_key,
-            // };
-            // let mut exchange_wss;
-            // exchange_wss = BinanceSwapWs::new_label(name, false, Option::from(params), BinanceSwapWsType::PublicAndPrivate);
-            // exchange_wss.set_symbols(vec![symbol_format]);
-            // exchange_wss.set_subscribe(subscriber_type.into());
-            //
-            //
-            // let mold_arc = Arc::new(mold.to_string());
-            // //读取
-            // tokio::spawn(async move {
-            //     let mold_clone = Arc::clone(&mold_arc);
-            //     loop {
-            //         if let Some(data) = read_rx.next().await {
-            //             trace!("原始数据 data:{:?}",data);
-            //             match mold_clone.as_str() {
-            //                 "depth" => {
-            //                     if data.data != "" {
-            //                         let result = binance_handle::handle_special_depth(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "ticker" => {
-            //                     if data.data != "" {
-            //                         let result = binance_handle::handle_special_ticker(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 _ => {
-            //                     error!("没有该命令!mode={}", mold_clone);
-            //                     panic!("没有该命令!mode={}", mold_clone)
-            //                 }
-            //             }
-            //         }
-            //     };
-            // });
-            //
-            // let t1 = tokio::spawn(async move {
-            //     //链接
-            //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-            //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            // });
-            // try_join!(t1).unwrap();
-        }
-        ExchangeEnum::KucoinSwap => {
-            // let symbol_format = format!("{}M", utils::format_symbol(symbol.to_string(), ""));
-            // let symbol_back = utils::format_symbol(symbol.to_string(), "_");
-            //
-            // let name = format!("kucoin_swap@{}", symbol.to_string().to_lowercase());
-            // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            // let write_tx_am = Arc::new(Mutex::new(write_tx));
-            // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-            //
-            // let params = KucoinSwapLogin {
-            //     access_key: account_info.kucoin_access_key,
-            //     secret_key: account_info.kucoin_secret_key,
-            //     pass_key: account_info.kucoin_pass,
-            // };
-            // let mut exchange_wss;
-            // if ["depth", "ticker"].contains(&mold) {
-            //     exchange_wss = KucoinSwapWs::new_label(name, false, Option::from(params), KucoinSwapWsType::Public).await;
-            // } else {
-            //     exchange_wss = KucoinSwapWs::new_label(name, false, Option::from(params), KucoinSwapWsType::Private).await;
-            // }
-            // exchange_wss.set_symbols(vec![symbol_format]);
-            // exchange_wss.set_subscribe(subscriber_type.into());
-            //
-            // let mold_arc = Arc::new(mold.to_string());
-            // tokio::spawn(async move {
-            //     let mold_clone = Arc::clone(&mold_arc);
-            //     loop {
-            //         if let Some(data) = read_rx.next().await {
-            //             trace!("原始数据 data:{:?}",data);
-            //             match mold_clone.as_str() {
-            //                 "depth" => {
-            //                     let result = kucoin_handle::handle_special_depth(data);
-            //                     trace!(?result)
-            //                 }
-            //                 "ticker" => {
-            //                     let result = kucoin_handle::handle_special_ticker(data);
-            //                     trace!(?result)
-            //                 }
-            //                 "account" => {
-            //                     let result = kucoin_handle::handle_account_info(data, symbol_back.clone());
-            //                     trace!(?result)
-            //                 }
-            //                 "position" => {
-            //                     let result = kucoin_handle::handle_position(data, dec!(1));
-            //                     trace!(?result)
-            //                 }
-            //                 "orders" => {
-            //                     let result = kucoin_handle::handle_order(data, dec!(0.001));
-            //                     trace!(?result)
-            //                 }
-            //                 _ => {
-            //                     error!("没有该命令!mode={}", mold_clone);
-            //                     panic!("没有该命令!mode={}", mold_clone)
-            //                 }
-            //             }
-            //         }
-            //     }
-            // });
-            //
-            // let t1 = tokio::spawn(async move {
-            //     //链接
-            //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-            //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            // });
-            // try_join!(t1).unwrap();
-        }
-        ExchangeEnum::KucoinSpot => {
-            // let symbol_format = utils::format_symbol(symbol.to_string(), "-").to_uppercase();
-            // let symbol_back = utils::format_symbol(symbol.to_string(), "_");
-            // trace!(symbol_format);
-            // let name = format!("kucoin_spot@{}", symbol.to_string().to_lowercase());
-            // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            // let write_tx_am = Arc::new(Mutex::new(write_tx));
-            // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-            //
-            // let params = KucoinSpotLogin {
-            //     access_key: account_info.kucoin_access_key,
-            //     secret_key: account_info.kucoin_secret_key,
-            //     pass_key: account_info.kucoin_pass,
-            // };
-            // let mut exchange_wss = if ["depth", "ticker"].contains(&mold) {
-            //     KucoinSpotWs::new_label(name, false, Option::from(params), KucoinSpotWsType::Public).await
-            // } else {
-            //     KucoinSpotWs::new_label(name, false, Option::from(params), KucoinSpotWsType::Private).await
-            // };
-            // exchange_wss.set_symbols(vec![symbol_format]);
-            // exchange_wss.set_subscribe(subscriber_type.into());
-            //
-            // let mold_arc = Arc::new(mold.to_string());
-            // tokio::spawn(async move {
-            //     let mold_clone = Arc::clone(&mold_arc);
-            //     loop {
-            //         if let Some(data) = read_rx.next().await {
-            //             trace!("原始数据 data:{:?}",data);
-            //             match mold_clone.as_str() {
-            //                 "depth" => {
-            //                     if data.data != "" {
-            //                         let result = kucoin_spot_handle::handle_special_depth(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "ticker" => {
-            //                     if data.data != "" {
-            //                         let result = kucoin_spot_handle::handle_special_ticker(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "account" => {
-            //                     if data.data != "" {
-            //                         let result = kucoin_spot_handle::handle_account_info(data, symbol_back.clone());
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "orders" => {
-            //                     if data.data != "" {
-            //                         let result = kucoin_spot_handle::handle_order(data, dec!(1));
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 _ => {
-            //                     error!("没有该命令!mode={}", mold_clone);
-            //                     panic!("没有该命令!mode={}", mold_clone)
-            //                 }
-            //             }
-            //         }
-            //     }
-            // });
-            // let t1 = tokio::spawn(async move {
-            //     //链接
-            //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-            //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            // });
-            // try_join!(t1).unwrap();
-        }
-        ExchangeEnum::GateSwap => {
-            // let symbol_format = utils::format_symbol(symbol.to_string(), "_").to_uppercase();
-            // trace!(symbol_format);
-            // let name = format!("gate_swap@{}", symbol.to_string().to_lowercase());
-            // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            // let write_tx_am = Arc::new(Mutex::new(write_tx));
-            // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-            //
-            // let params = GateSwapLogin {
-            //     api_key: account_info.gate_access_key,
-            //     secret: account_info.gate_secret_key,
-            // };
-            // let mut exchange_wss = GateSwapWs::new_label(name, false, Option::from(params), GateSwapWsType::PublicAndPrivate("usdt".to_string()));
-            // exchange_wss.set_symbols(vec![symbol_format.clone()]);
-            // exchange_wss.set_subscribe(subscriber_type.into());
-            //
-            // let mold_arc = Arc::new(mold.to_string());
-            // tokio::spawn(async move {
-            //     let mold_clone = Arc::clone(&mold_arc);
-            //     loop {
-            //         if let Some(data) = read_rx.next().await {
-            //             trace!("原始数据 data:{:?}",data);
-            //             match mold_clone.as_str() {
-            //                 "depth" => {
-            //                     if data.data != "" {
-            //                         let result = gate_handle::handle_special_depth(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "ticker" => {
-            //                     if data.data != "" {
-            //                         let result = gate_handle::handle_special_ticker(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "account" => {
-            //                     if data.data != "" {
-            //                         let result = gate_handle::handle_account_info(data, symbol_format.clone());
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "orders" => {
-            //                     if data.data != "" {
-            //                         let result = gate_handle::handle_order(data, dec!(1));
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 _ => {
-            //                     error!("没有该命令!mode={}", mold_clone);
-            //                     panic!("没有该命令!mode={}", mold_clone)
-            //                 }
-            //             }
-            //         }
-            //     }
-            // });
-            // let t1 = tokio::spawn(async move {
-            //     //链接
-            //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-            //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            // });
-            // try_join!(t1).unwrap();
-        }
-        ExchangeEnum::BitgetSpot => {
-            // let symbol_format = utils::format_symbol(symbol.to_string(), "-").to_uppercase();
-            // let symbol_back = utils::format_symbol(symbol.to_string(), "_");
-            // trace!(symbol_format);
-            // let name = format!("bitget_spot@{}", symbol.to_string().to_lowercase());
-            // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            // let write_tx_am = Arc::new(Mutex::new(write_tx));
-            // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-            //
-            // let params = BitgetSpotLogin {
-            //     api_key: account_info.bitget_access_key,
-            //     secret_key: account_info.bitget_secret_key,
-            //     passphrase_key: account_info.bitget_pass,
-            // };
-            //
-            // let mut exchange_wss = if ["depth", "ticker"].contains(&mold) {
-            //     BitgetSpotWs::new_label(name, false, Option::from(params), BitgetSpotWsType::Public)
-            // } else {
-            //     BitgetSpotWs::new_label(name, false, Option::from(params), BitgetSpotWsType::Private)
-            // };
-            // exchange_wss.set_symbols(vec![symbol_format]);
-            // exchange_wss.set_subscribe(subscriber_type.into());
-            //
-            // let mold_arc = Arc::new(mold.to_string());
-            // //读取
-            // tokio::spawn(async move {
-            //     loop {
-            //         let mold_clone = Arc::clone(&mold_arc);
-            //         if let Some(data) = read_rx.next().await {
-            //             trace!("原始数据 data:{:?}",data);
-            //             match mold_clone.as_str() {
-            //                 "depth" => {
-            //                     if data.data != "" {
-            //                         let result = bitget_spot_handle::handle_special_depth(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "ticker" => {
-            //                     if data.data != "" {
-            //                         let result = bitget_spot_handle::handle_special_ticker(data);
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "account" => {
-            //                     if data.data != "" {
-            //                         let result = bitget_spot_handle::handle_account_info(data, symbol_back.clone());
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 "orders" => {
-            //                     if data.data != "" {
-            //                         let result = bitget_spot_handle::handle_order(data, dec!(1));
-            //                         trace!(?result)
-            //                     }
-            //                 }
-            //                 _ => {
-            //                     error!("没有该命令!mode={}", mold_clone);
-            //                     panic!("没有该命令!mode={}", mold_clone)
-            //                 }
-            //             }
-            //         }
-            //     }
-            // });
-            // let t1 = tokio::spawn(async move {
-            //     //链接
-            //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-            //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            // });
-            // try_join!(t1).unwrap();
-        }
-        ExchangeEnum::OkxSwap => {
-            let symbol_format = utils::format_symbol(symbol.to_string(), "-").to_uppercase();
-            trace!(symbol_format);
-            let name = format!("okx_swap@{}", symbol.to_string().to_lowercase());
-            let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-            let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
-            let write_tx_am = Arc::new(Mutex::new(write_tx));
-            let is_shutdown_arc = Arc::new(AtomicBool::new(true));
-
-            let params = OkxSwapLogin {
-                api_key: account_info.okx_access_key,
-                secret_key: account_info.okx_secret_key,
-                passphrase: account_info.okx_pass,
-            };
-
-            let mut exchange_wss = if ["depth", "ticker"].contains(&mold) {
-                OkxSwapWs::new_label(name, false, Option::from(params), OkxSwapWsType::Public)
-            } else if ["account", "orders", "position"].contains(&mold) {
-                OkxSwapWs::new_label(name, false, Option::from(params), OkxSwapWsType::Private)
-            } else {
-                OkxSwapWs::new_label(name, false, Option::from(params), OkxSwapWsType::Business)
-            };
-
-            exchange_wss.set_symbols(vec![symbol_format.clone()]);
-            exchange_wss.set_subscribe(subscriber_type.into());
-
-            let mold_arc = Arc::new(mold.to_string());
-            tokio::spawn(async move {
-                let mold_clone = Arc::clone(&mold_arc);
-                loop {
-                    if let Some(data) = read_rx.next().await {
-                        trace!("原始数据 data:{:?}",data);
-                        match mold_clone.as_str() {
-                            "depth" => {
-                                if data.data != "" {
-                                    let result = okx_handle::handle_special_depth(data);
-                                    trace!(?result)
-                                }
-                            }
-                            "ticker" => {
-                                if data.data != "" {
-                                    let result = okx_handle::handle_special_ticker(data);
-                                    trace!(?result)
-                                }
-                            }
-                            "account" => {
-                                if data.data != "" {
-                                    let result = okx_handle::handle_account_info(data, symbol_format.clone());
-                                    trace!(?result)
-                                }
-                            }
-                            "position" => {
-                                if data.data != "" {
-                                    let result = okx_handle::handle_position(data, dec!(10));
-                                    trace!(?result)
-                                }
-                            }
-                            "orders" => {
-                                if data.data != "" {
-                                    let result = okx_handle::handle_order(data, dec!(10));
-                                    trace!(?result)
-                                }
-                            }
-                            _ => {
-                                error!("没有该命令!mode={}", mold_clone);
-                                panic!("没有该命令!mode={}", mold_clone)
-                            }
-                        }
-                    }
-                }
-            });
-
-            let t1 = tokio::spawn(async move {
-                //链接
-                let bool_v3_clone = Arc::clone(&is_shutdown_arc);
-                exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
-            });
-            try_join!(t1).unwrap();
-        }
+        // ExchangeEnum::BinanceSpot => {
+        //     // let symbol_format = utils::format_symbol(symbol.to_string(), "").to_uppercase();
+        //     // trace!(symbol_format);
+        //     // let name = format!("binance_spot@{}", symbol.to_string().to_lowercase());
+        //     // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     // let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //     //
+        //     // let params = BinanceSpotLogin {
+        //     //     api_key: account_info.binance_access_key,
+        //     //     api_secret: account_info.binance_secret_key,
+        //     // };
+        //     // let mut exchange_wss;
+        //     // exchange_wss = BinanceSpotWs::new_label(name, false, Option::from(params), BinanceSpotWsType::PublicAndPrivate);
+        //     // exchange_wss.set_symbols(vec![symbol_format]);
+        //     // exchange_wss.set_subscribe(subscriber_type.into());
+        //     //
+        //     //
+        //     // let mold_arc = Arc::new(mold.to_string());
+        //     // //读取
+        //     // tokio::spawn(async move {
+        //     //     let mold_clone = Arc::clone(&mold_arc);
+        //     //     loop {
+        //     //         if let Some(data) = read_rx.next().await {
+        //     //             trace!("原始数据 data:{:?}",data);
+        //     //             match mold_clone.as_str() {
+        //     //                 "depth" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = binance_spot_handle::handle_special_depth(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "ticker" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = binance_spot_handle::handle_special_ticker(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 _ => {
+        //     //                     error!("没有该命令!mode={}", mold_clone);
+        //     //                     panic!("没有该命令!mode={}", mold_clone)
+        //     //                 }
+        //     //             }
+        //     //         }
+        //     //     };
+        //     // });
+        //     //
+        //     // let t1 = tokio::spawn(async move {
+        //     //     //链接
+        //     //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //     //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     // });
+        //     // try_join!(t1).unwrap();
+        // }
+        // ExchangeEnum::BinanceSwap => {
+        //     // let symbol_format = utils::format_symbol(symbol.to_string(), "").to_uppercase();
+        //     // trace!(symbol_format);
+        //     // let name = format!("binance_swap@{}", symbol.to_string().to_lowercase());
+        //     // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     // let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //     //
+        //     // let params = BinanceSwapLogin {
+        //     //     api_key: account_info.binance_access_key,
+        //     //     api_secret: account_info.binance_secret_key,
+        //     // };
+        //     // let mut exchange_wss;
+        //     // exchange_wss = BinanceSwapWs::new_label(name, false, Option::from(params), BinanceSwapWsType::PublicAndPrivate);
+        //     // exchange_wss.set_symbols(vec![symbol_format]);
+        //     // exchange_wss.set_subscribe(subscriber_type.into());
+        //     //
+        //     //
+        //     // let mold_arc = Arc::new(mold.to_string());
+        //     // //读取
+        //     // tokio::spawn(async move {
+        //     //     let mold_clone = Arc::clone(&mold_arc);
+        //     //     loop {
+        //     //         if let Some(data) = read_rx.next().await {
+        //     //             trace!("原始数据 data:{:?}",data);
+        //     //             match mold_clone.as_str() {
+        //     //                 "depth" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = binance_handle::handle_special_depth(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "ticker" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = binance_handle::handle_special_ticker(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 _ => {
+        //     //                     error!("没有该命令!mode={}", mold_clone);
+        //     //                     panic!("没有该命令!mode={}", mold_clone)
+        //     //                 }
+        //     //             }
+        //     //         }
+        //     //     };
+        //     // });
+        //     //
+        //     // let t1 = tokio::spawn(async move {
+        //     //     //链接
+        //     //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //     //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     // });
+        //     // try_join!(t1).unwrap();
+        // }
+        // ExchangeEnum::KucoinSwap => {
+        //     // let symbol_format = format!("{}M", utils::format_symbol(symbol.to_string(), ""));
+        //     // let symbol_back = utils::format_symbol(symbol.to_string(), "_");
+        //     //
+        //     // let name = format!("kucoin_swap@{}", symbol.to_string().to_lowercase());
+        //     // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     // let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //     //
+        //     // let params = KucoinSwapLogin {
+        //     //     access_key: account_info.kucoin_access_key,
+        //     //     secret_key: account_info.kucoin_secret_key,
+        //     //     pass_key: account_info.kucoin_pass,
+        //     // };
+        //     // let mut exchange_wss;
+        //     // if ["depth", "ticker"].contains(&mold) {
+        //     //     exchange_wss = KucoinSwapWs::new_label(name, false, Option::from(params), KucoinSwapWsType::Public).await;
+        //     // } else {
+        //     //     exchange_wss = KucoinSwapWs::new_label(name, false, Option::from(params), KucoinSwapWsType::Private).await;
+        //     // }
+        //     // exchange_wss.set_symbols(vec![symbol_format]);
+        //     // exchange_wss.set_subscribe(subscriber_type.into());
+        //     //
+        //     // let mold_arc = Arc::new(mold.to_string());
+        //     // tokio::spawn(async move {
+        //     //     let mold_clone = Arc::clone(&mold_arc);
+        //     //     loop {
+        //     //         if let Some(data) = read_rx.next().await {
+        //     //             trace!("原始数据 data:{:?}",data);
+        //     //             match mold_clone.as_str() {
+        //     //                 "depth" => {
+        //     //                     let result = kucoin_handle::handle_special_depth(data);
+        //     //                     trace!(?result)
+        //     //                 }
+        //     //                 "ticker" => {
+        //     //                     let result = kucoin_handle::handle_special_ticker(data);
+        //     //                     trace!(?result)
+        //     //                 }
+        //     //                 "account" => {
+        //     //                     let result = kucoin_handle::handle_account_info(data, symbol_back.clone());
+        //     //                     trace!(?result)
+        //     //                 }
+        //     //                 "position" => {
+        //     //                     let result = kucoin_handle::handle_position(data, dec!(1));
+        //     //                     trace!(?result)
+        //     //                 }
+        //     //                 "orders" => {
+        //     //                     let result = kucoin_handle::handle_order(data, dec!(0.001));
+        //     //                     trace!(?result)
+        //     //                 }
+        //     //                 _ => {
+        //     //                     error!("没有该命令!mode={}", mold_clone);
+        //     //                     panic!("没有该命令!mode={}", mold_clone)
+        //     //                 }
+        //     //             }
+        //     //         }
+        //     //     }
+        //     // });
+        //     //
+        //     // let t1 = tokio::spawn(async move {
+        //     //     //链接
+        //     //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //     //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     // });
+        //     // try_join!(t1).unwrap();
+        // }
+        // ExchangeEnum::KucoinSpot => {
+        //     // let symbol_format = utils::format_symbol(symbol.to_string(), "-").to_uppercase();
+        //     // let symbol_back = utils::format_symbol(symbol.to_string(), "_");
+        //     // trace!(symbol_format);
+        //     // let name = format!("kucoin_spot@{}", symbol.to_string().to_lowercase());
+        //     // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     // let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //     //
+        //     // let params = KucoinSpotLogin {
+        //     //     access_key: account_info.kucoin_access_key,
+        //     //     secret_key: account_info.kucoin_secret_key,
+        //     //     pass_key: account_info.kucoin_pass,
+        //     // };
+        //     // let mut exchange_wss = if ["depth", "ticker"].contains(&mold) {
+        //     //     KucoinSpotWs::new_label(name, false, Option::from(params), KucoinSpotWsType::Public).await
+        //     // } else {
+        //     //     KucoinSpotWs::new_label(name, false, Option::from(params), KucoinSpotWsType::Private).await
+        //     // };
+        //     // exchange_wss.set_symbols(vec![symbol_format]);
+        //     // exchange_wss.set_subscribe(subscriber_type.into());
+        //     //
+        //     // let mold_arc = Arc::new(mold.to_string());
+        //     // tokio::spawn(async move {
+        //     //     let mold_clone = Arc::clone(&mold_arc);
+        //     //     loop {
+        //     //         if let Some(data) = read_rx.next().await {
+        //     //             trace!("原始数据 data:{:?}",data);
+        //     //             match mold_clone.as_str() {
+        //     //                 "depth" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = kucoin_spot_handle::handle_special_depth(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "ticker" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = kucoin_spot_handle::handle_special_ticker(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "account" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = kucoin_spot_handle::handle_account_info(data, symbol_back.clone());
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "orders" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = kucoin_spot_handle::handle_order(data, dec!(1));
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 _ => {
+        //     //                     error!("没有该命令!mode={}", mold_clone);
+        //     //                     panic!("没有该命令!mode={}", mold_clone)
+        //     //                 }
+        //     //             }
+        //     //         }
+        //     //     }
+        //     // });
+        //     // let t1 = tokio::spawn(async move {
+        //     //     //链接
+        //     //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //     //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     // });
+        //     // try_join!(t1).unwrap();
+        // }
+        // ExchangeEnum::GateSwap => {
+        //     // let symbol_format = utils::format_symbol(symbol.to_string(), "_").to_uppercase();
+        //     // trace!(symbol_format);
+        //     // let name = format!("gate_swap@{}", symbol.to_string().to_lowercase());
+        //     // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     // let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //     //
+        //     // let params = GateSwapLogin {
+        //     //     api_key: account_info.gate_access_key,
+        //     //     secret: account_info.gate_secret_key,
+        //     // };
+        //     // let mut exchange_wss = GateSwapWs::new_label(name, false, Option::from(params), GateSwapWsType::PublicAndPrivate("usdt".to_string()));
+        //     // exchange_wss.set_symbols(vec![symbol_format.clone()]);
+        //     // exchange_wss.set_subscribe(subscriber_type.into());
+        //     //
+        //     // let mold_arc = Arc::new(mold.to_string());
+        //     // tokio::spawn(async move {
+        //     //     let mold_clone = Arc::clone(&mold_arc);
+        //     //     loop {
+        //     //         if let Some(data) = read_rx.next().await {
+        //     //             trace!("原始数据 data:{:?}",data);
+        //     //             match mold_clone.as_str() {
+        //     //                 "depth" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = gate_handle::handle_special_depth(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "ticker" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = gate_handle::handle_special_ticker(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "account" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = gate_handle::handle_account_info(data, symbol_format.clone());
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "orders" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = gate_handle::handle_order(data, dec!(1));
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 _ => {
+        //     //                     error!("没有该命令!mode={}", mold_clone);
+        //     //                     panic!("没有该命令!mode={}", mold_clone)
+        //     //                 }
+        //     //             }
+        //     //         }
+        //     //     }
+        //     // });
+        //     // let t1 = tokio::spawn(async move {
+        //     //     //链接
+        //     //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //     //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     // });
+        //     // try_join!(t1).unwrap();
+        // }
+        // ExchangeEnum::BitgetSpot => {
+        //     // let symbol_format = utils::format_symbol(symbol.to_string(), "-").to_uppercase();
+        //     // let symbol_back = utils::format_symbol(symbol.to_string(), "_");
+        //     // trace!(symbol_format);
+        //     // let name = format!("bitget_spot@{}", symbol.to_string().to_lowercase());
+        //     // let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     // let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     // let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     // let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //     //
+        //     // let params = BitgetSpotLogin {
+        //     //     api_key: account_info.bitget_access_key,
+        //     //     secret_key: account_info.bitget_secret_key,
+        //     //     passphrase_key: account_info.bitget_pass,
+        //     // };
+        //     //
+        //     // let mut exchange_wss = if ["depth", "ticker"].contains(&mold) {
+        //     //     BitgetSpotWs::new_label(name, false, Option::from(params), BitgetSpotWsType::Public)
+        //     // } else {
+        //     //     BitgetSpotWs::new_label(name, false, Option::from(params), BitgetSpotWsType::Private)
+        //     // };
+        //     // exchange_wss.set_symbols(vec![symbol_format]);
+        //     // exchange_wss.set_subscribe(subscriber_type.into());
+        //     //
+        //     // let mold_arc = Arc::new(mold.to_string());
+        //     // //读取
+        //     // tokio::spawn(async move {
+        //     //     loop {
+        //     //         let mold_clone = Arc::clone(&mold_arc);
+        //     //         if let Some(data) = read_rx.next().await {
+        //     //             trace!("原始数据 data:{:?}",data);
+        //     //             match mold_clone.as_str() {
+        //     //                 "depth" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = bitget_spot_handle::handle_special_depth(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "ticker" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = bitget_spot_handle::handle_special_ticker(data);
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "account" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = bitget_spot_handle::handle_account_info(data, symbol_back.clone());
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 "orders" => {
+        //     //                     if data.data != "" {
+        //     //                         let result = bitget_spot_handle::handle_order(data, dec!(1));
+        //     //                         trace!(?result)
+        //     //                     }
+        //     //                 }
+        //     //                 _ => {
+        //     //                     error!("没有该命令!mode={}", mold_clone);
+        //     //                     panic!("没有该命令!mode={}", mold_clone)
+        //     //                 }
+        //     //             }
+        //     //         }
+        //     //     }
+        //     // });
+        //     // let t1 = tokio::spawn(async move {
+        //     //     //链接
+        //     //     let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //     //     exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     // });
+        //     // try_join!(t1).unwrap();
+        // }
+        // ExchangeEnum::OkxSwap => {
+        //     let symbol_format = utils::format_symbol(symbol.to_string(), "-").to_uppercase();
+        //     trace!(symbol_format);
+        //     let name = format!("okx_swap@{}", symbol.to_string().to_lowercase());
+        //     let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
+        //     let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+        //     let write_tx_am = Arc::new(Mutex::new(write_tx));
+        //     let is_shutdown_arc = Arc::new(AtomicBool::new(true));
+        //
+        //     let params = OkxSwapLogin {
+        //         api_key: account_info.okx_access_key,
+        //         secret_key: account_info.okx_secret_key,
+        //         passphrase: account_info.okx_pass,
+        //     };
+        //
+        //     let mut exchange_wss = if ["depth", "ticker"].contains(&mold) {
+        //         OkxSwapWs::new_label(name, false, Option::from(params), OkxSwapWsType::Public)
+        //     } else if ["account", "orders", "position"].contains(&mold) {
+        //         OkxSwapWs::new_label(name, false, Option::from(params), OkxSwapWsType::Private)
+        //     } else {
+        //         OkxSwapWs::new_label(name, false, Option::from(params), OkxSwapWsType::Business)
+        //     };
+        //
+        //     exchange_wss.set_symbols(vec![symbol_format.clone()]);
+        //     exchange_wss.set_subscribe(subscriber_type.into());
+        //
+        //     let mold_arc = Arc::new(mold.to_string());
+        //     tokio::spawn(async move {
+        //         let mold_clone = Arc::clone(&mold_arc);
+        //         loop {
+        //             if let Some(data) = read_rx.next().await {
+        //                 trace!("原始数据 data:{:?}",data);
+        //                 match mold_clone.as_str() {
+        //                     "depth" => {
+        //                         if data.data != "" {
+        //                             let result = okx_handle::handle_special_depth(data);
+        //                             trace!(?result)
+        //                         }
+        //                     }
+        //                     "ticker" => {
+        //                         if data.data != "" {
+        //                             let result = okx_handle::handle_special_ticker(data);
+        //                             trace!(?result)
+        //                         }
+        //                     }
+        //                     "account" => {
+        //                         if data.data != "" {
+        //                             let result = okx_handle::handle_account_info(data, symbol_format.clone());
+        //                             trace!(?result)
+        //                         }
+        //                     }
+        //                     "position" => {
+        //                         if data.data != "" {
+        //                             let result = okx_handle::handle_position(data, dec!(10));
+        //                             trace!(?result)
+        //                         }
+        //                     }
+        //                     "orders" => {
+        //                         if data.data != "" {
+        //                             let result = okx_handle::handle_order(data, dec!(10));
+        //                             trace!(?result)
+        //                         }
+        //                     }
+        //                     _ => {
+        //                         error!("没有该命令!mode={}", mold_clone);
+        //                         panic!("没有该命令!mode={}", mold_clone)
+        //                     }
+        //                 }
+        //             }
+        //         }
+        //     });
+        //
+        //     let t1 = tokio::spawn(async move {
+        //         //链接
+        //         let bool_v3_clone = Arc::clone(&is_shutdown_arc);
+        //         exchange_wss.ws_connect_async(bool_v3_clone, &write_tx_am, write_rx, read_tx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
+        //     });
+        //     try_join!(t1).unwrap();
+        // }
         _ => {
             error!("该交易所不支持!test_new_exchange_wss:{:?}",exchange);
             panic!("该交易所不支持!test_new_exchange_wss:{:?}", exchange)

+ 52 - 2
standard/tests/gate_swap_test.rs

@@ -3,9 +3,12 @@ mod exchange_test;
 use std::collections::BTreeMap;
 use std::env;
 use std::io::Error;
+use rust_decimal::Decimal;
 use rust_decimal_macros::dec;
 use tokio::sync::mpsc;
-use tracing::{instrument, trace};
+use tokio::time::Instant;
+use tracing::{info, instrument, trace};
+use global::trace_stack::TraceStack;
 use standard::exchange::{Exchange, ExchangeEnum};
 use standard::{Order, OrderCommand, Platform, utils};
 use crate::exchange_test::{test_new_exchange};
@@ -243,6 +246,53 @@ async fn test_set_dual_leverage() {
     trace!(?gate_set_dual_leverage);
 }
 
+#[tokio::test]
+async fn test_price_order() {
+    global::log_utils::init_log_with_info();
+
+    let mut gate_swap_exchange = test_new_exchange(ExchangeEnum::GateSwap, "DYM_USDT").await;
+    let place_response = gate_swap_exchange.take_stop_loss_order(dec!(7.72), Decimal::ZERO, "kd").await;
+
+    info!(?place_response);
+
+    // place_response=Ok(
+    // Object {
+    //  "create_time": Number(1707459777),
+    //  "finish_time": Number(1707459777),
+    //  "id": Number(60416891),
+    //  "in_dual_mode": Bool(true),
+    //  "initial": Object {
+    //      "auto_size": String("close_long"),
+    //      "contract": String("DYM_USDT"),
+    //      "iceberg": Number(0),
+    //      "is_close": Bool(false),
+    //      "is_reduce_only": Bool(true),
+    //      "price": String("0"),
+    //      "size": Number(0),
+    //      "text": String(""),
+    //      "tif": String("ioc")},
+    //      "is_stop_order": Bool(false),
+    //      "me_order_id": Number(0),
+    //      "order_type": String(""),
+    //      "reason": String(""),
+    //      "status": String("open"),
+    //      "stop_trigger": Object {
+    //          "order_price": String(""),
+    //          "rule": Number(0),
+    //          "trigger_price": String("")
+    //      },
+    //      "trade_id": Number(0),
+    //      "trigger": Object {
+    //          "expiration": Number(0),
+    //          "price": String("7.72"),
+    //          "price_type": Number(0),
+    //          "rule": Number(2),
+    //          "strategy_type": Number(0)
+    //      },
+    //      "user": Number(457317)
+    // })
+}
+
 // 测试指令下单
 #[tokio::test]
 #[instrument(level = "TRACE")]
@@ -266,7 +316,7 @@ async fn test_command_order() {
     command.limits_open.insert("888888".to_string(), vec!["100".to_string(), "kd".to_string(), "0.18".to_string(), "888888".to_string()]);
     command.limits_close.insert("999999".to_string(), vec!["100".to_string(), "kk".to_string(), "0.25".to_string(), "999999".to_string()]);
     command.check.insert("888888".to_string(), vec!["999999".to_string(), "".to_string()]);
-    gate_swap_exchange.command_order(command, Default::default()).await;
+    gate_swap_exchange.command_order(&mut command, &TraceStack::new(0, Instant::now())).await;
 
     loop {
         if let Ok(order) = order_receiver.try_recv() {