Browse Source

更新基础架构
添加Depth结构体
添加Record结构体

gepangpang 2 years ago
parent
commit
6ecce9adb1

+ 53 - 9
standard/src/binance_spot.rs

@@ -1,6 +1,6 @@
 use std::collections::BTreeMap;
-// use crate::utils;
-use crate::{Account, Platform, ExchangeEnum};
+use crate::utils;
+use crate::{Platform, ExchangeEnum, Account, Depth, DepthItem};
 use exchanges::binance_spot_rest::BinanceSpotRest;
 use exchanges::binance_spot_ws::BinanceSpotWs;
 // use exchanges::response_base::ResponseData;
@@ -29,15 +29,44 @@ impl BinanceSpot {
 }
 
 impl Platform for BinanceSpot {
-    // 获取params信息
-    fn get_params_info(&self) -> BTreeMap<String, String> {
+    // 获取交易所模式
+    fn get_self_exchange(&self) -> ExchangeEnum {
+        ExchangeEnum::BinanceSpot
+    }
+    // 获取是否使用高速通道
+    fn get_self_is_colo(&self) -> bool {
+        self.is_colo
+    }
+    // 获取是否使用登录
+    fn get_self_is_login(&self) -> bool {
+        self.is_login
+    }
+    // 获取登录params信息
+    fn get_self_params(&self) -> BTreeMap<String, String> {
         self.params.clone()
     }
-    // 获取期货账号信息
-    fn get_account(&self) -> Account {
-        todo!()
+    // 获取现货账号信息
+    fn get_account(&self, symbol: &str) -> Account {
+        let format_symbol = utils::format_symbol(symbol, "");
+        println!("spot_real_symbol: {}", format_symbol);
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
     }
 
+    // 获取深度信息
+    fn get_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 1.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
+    }
 
     fn take_order(&self) {
         todo!()
@@ -51,8 +80,23 @@ impl Platform for BinanceSpot {
         todo!()
     }
 
-    fn subscribe_account(&self) {
-        // self.wss.subscribe_account();
+    fn subscribe_account(&self) -> Account {
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
+
+    fn subscribe_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 1.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
     fn subscribe_kline(&self) {}

+ 51 - 7
standard/src/binance_swap.rs

@@ -1,6 +1,6 @@
 use std::collections::BTreeMap;
-// use crate::utils;
-use crate::{Account, Platform, ExchangeEnum};
+use crate::utils;
+use crate::{Platform, ExchangeEnum, Account, Depth, DepthItem};
 use exchanges::binance_usdt_swap_rest::BinanceUsdtSwapRest;
 use exchanges::binance_usdt_swap_ws::BinanceUsdtSwapWs;
 use exchanges::response_base::ResponseData;
@@ -29,13 +29,42 @@ impl BinanceSwap {
 }
 
 impl Platform for BinanceSwap {
+    // 获取交易所模式
+    fn get_self_exchange(&self) -> ExchangeEnum {
+        ExchangeEnum::BinanceSwap
+    }
+    // 获取是否使用高速通道
+    fn get_self_is_colo(&self) -> bool {
+        self.is_colo
+    }
+    // 获取是否需要登录
+    fn get_self_is_login(&self) -> bool {
+        self.is_login
+    }
     // 获取params信息
-    fn get_params_info(&self) -> BTreeMap<String, String> {
+    fn get_self_params(&self) -> BTreeMap<String, String> {
         self.params.clone()
     }
     // 获取期货账号信息
-    fn get_account(&self) -> Account {
-        todo!()
+    fn get_account(&self, symbol: &str) -> Account {
+        let format_symbol = utils::format_symbol(symbol, "");
+        println!("swap_real_symbol: {}", format_symbol);
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
+    // 获取深度信息
+    fn get_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 2.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
 
@@ -51,8 +80,23 @@ impl Platform for BinanceSwap {
         todo!()
     }
 
-    fn subscribe_account(&self) {
-        // self.wss.subscribe_account();
+    fn subscribe_account(&self) -> Account {
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
+
+    fn subscribe_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 2.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
     fn subscribe_kline(&self) {

+ 69 - 0
standard/src/exchange.rs

@@ -0,0 +1,69 @@
+use std::collections::BTreeMap;
+use crate::binance_swap::BinanceSwap;
+use crate::binance_spot::BinanceSpot;
+use crate::gate_spot::GateSpot;
+use crate::gate_swap::GateSwap;
+use crate::Platform;
+
+/// 交易所交易模式枚举
+/// - `BinanceSwap`: Binance交易所期货;
+/// - `BinanceSpot`: Binance交易所现货;
+/// - `GateSwap`: Gate交易所期货;
+/// - `GateSpot`: Gate交易所现货;
+#[derive(Debug)]
+pub enum ExchangeEnum {
+    BinanceSwap,
+    BinanceSpot,
+    GateSwap,
+    GateSpot,
+}
+
+/// Exchange结构体
+///
+/// 方法:
+/// - 创建Exchange:
+///
+/// new(platform: [ExchangeEnum], is_colo: bool, is_login:bool, params: BTreeMap<String, String>) -> Box\<dyn Platform\>
+/// - `platform(`[ExchangeEnum]`)`: 交易所平台枚举
+/// - `is_colo(bool)`: 是否开始告诉模式
+/// - `is_login(bool)`: 是否需要登录
+/// - `params(BTreeMap<String, String>)`: 登录所需参数
+///
+/// 示例参数值:
+///
+/// | 交易所枚举 | params参数示例 BTreeMap<String, String> |
+/// | --- | --- |
+/// | BinanceSwap | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
+/// | BinanceSpot | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
+/// | GateSwap | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
+/// | GateSpot | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
+///  ```rust
+/// use std::collections::BTreeMap;
+/// use standard::exchange::{Exchange, ExchangeEnum};
+///
+/// let mut params:BTreeMap<String,String> = BTreeMap::new();
+/// params.insert("access_key".to_string(), "your_access_key".to_string());
+/// params.insert("access_key".to_string(), "your_secret_key".to_string());
+/// let exchange = Exchange::new(ExchangeEnum::BinanceSwap, true, true, params);
+pub struct Exchange {}
+
+impl Exchange {
+    pub fn new(exchange: ExchangeEnum, is_colo: bool, is_login: bool, params: BTreeMap<String, String>) -> Box<dyn Platform> {
+        match exchange {
+            ExchangeEnum::BinanceSwap => {
+                Box::new(BinanceSwap::new(is_colo, is_login, params))
+            }
+            ExchangeEnum::BinanceSpot => {
+                Box::new(BinanceSpot::new(is_colo, is_login, params))
+            }
+            ExchangeEnum::GateSwap => {
+                Box::new(GateSpot::new(is_colo, is_login, params))
+            }
+            ExchangeEnum::GateSpot => {
+                Box::new(GateSwap::new(is_colo, is_login, params))
+            }
+        }
+    }
+}
+
+

+ 53 - 8
standard/src/gate_spot.rs

@@ -1,6 +1,6 @@
 use std::collections::BTreeMap;
-// use crate::utils;
-use crate::{Account, Platform, ExchangeEnum};
+use crate::utils;
+use crate::{Platform, ExchangeEnum, Account, Depth, DepthItem};
 use exchanges::gate_spot_rest::GateSpotRest;
 use exchanges::gate_spot_ws::GateSpotWs;
 // use exchanges::response_base::ResponseData;
@@ -29,12 +29,42 @@ impl GateSpot {
 }
 
 impl Platform for GateSpot {
-    fn get_params_info(&self) -> BTreeMap<String, String> {
+    // 获取交易所模式
+    fn get_self_exchange(&self) -> ExchangeEnum {
+        ExchangeEnum::GateSpot
+    }
+    // 获取是否使用高速通道
+    fn get_self_is_colo(&self) -> bool {
+        self.is_colo
+    }
+    // 获取是否需要登录
+    fn get_self_is_login(&self) -> bool {
+        self.is_login
+    }
+    // 获取params信息
+    fn get_self_params(&self) -> BTreeMap<String, String> {
         self.params.clone()
     }
-
-    fn get_account(&self) -> Account {
-        todo!()
+    // 获取现货账号信息
+    fn get_account(&self, symbol: &str) -> Account {
+        let format_symbol = utils::format_symbol(symbol, "_");
+        println!("spot_real_symbol: {}", format_symbol);
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
+    // 获取深度信息
+    fn get_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 3.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
 
@@ -50,8 +80,23 @@ impl Platform for GateSpot {
         todo!()
     }
 
-    fn subscribe_account(&self) {
-        // self.wss.subscribe_account();
+    fn subscribe_account(&self) -> Account {
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
+
+    fn subscribe_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 3.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
     fn subscribe_kline(&self) {

+ 52 - 7
standard/src/gate_swap.rs

@@ -1,6 +1,6 @@
 use std::collections::BTreeMap;
-// use crate::utils;
-use crate::{Account, Platform, ExchangeEnum};
+use crate::utils;
+use crate::{Platform, ExchangeEnum, Account, Depth, DepthItem};
 use exchanges::gate_usdt_swap_rest::GateUsdtSwapRest;
 use exchanges::gate_usdt_swap_ws::GateUsdtSwapWs;
 // use exchanges::response_base::ResponseData;
@@ -29,12 +29,42 @@ impl GateSwap {
 }
 
 impl Platform for GateSwap {
-    fn get_params_info(&self) -> BTreeMap<String, String> {
+    // 获取交易所模式
+    fn get_self_exchange(&self) -> ExchangeEnum {
+        ExchangeEnum::GateSwap
+    }
+    // 获取是否使用高速通道
+    fn get_self_is_colo(&self) -> bool {
+        self.is_colo
+    }
+    // 获取是否需要登录
+    fn get_self_is_login(&self) -> bool {
+        self.is_login
+    }
+    // 获取params信息
+    fn get_self_params(&self) -> BTreeMap<String, String> {
         self.params.clone()
     }
+    // 获取期货账号信息
+    fn get_account(&self, symbol: &str) -> Account {
+        let format_symbol = utils::format_symbol(symbol, "_");
+        println!("swap_real_symbol: {}", format_symbol);
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
 
-    fn get_account(&self) -> Account {
-        todo!()
+    fn get_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 4.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
     fn take_order(&self) {
@@ -49,8 +79,23 @@ impl Platform for GateSwap {
         todo!()
     }
 
-    fn subscribe_account(&self) {
-        // self.wss.subscribe_account();
+    fn subscribe_account(&self) -> Account {
+        Account {
+            balance: 0.0,
+            frozen_balance: 0.0,
+            stocks: 0.0,
+            frozen_stocks: 0.0,
+        }
+    }
+
+    fn subscribe_depth(&self) -> Depth {
+        let depth_asks = vec![DepthItem { price: 4.0, amount: 0.0 }];
+        let depth_bids = vec![DepthItem { price: 0.0, amount: 0.0 }];
+        Depth {
+            time: 0,
+            asks: depth_asks,
+            bids: depth_bids,
+        }
     }
 
     fn subscribe_kline(&self) {

+ 65 - 80
standard/src/lib.rs

@@ -1,9 +1,8 @@
 use std::collections::BTreeMap;
-use crate::binance_swap::BinanceSwap;
-use crate::binance_spot::BinanceSpot;
-use crate::gate_spot::GateSpot;
-use crate::gate_swap::GateSwap;
+use crate::exchange::ExchangeEnum;
 
+// 引入exchange模块
+pub mod exchange;
 // 引入binance模块
 mod binance_swap;
 mod binance_spot;
@@ -13,12 +12,11 @@ mod gate_spot;
 // 引入工具模块
 pub mod utils;
 
-
 /// Account结构体
-/// - balance(f64): 可用计价币数量;
-/// - frozen_balance(f64): balance挂单的冻结数量
-/// - stocks(f64): 可用交易币数量
-/// - frozen_stocks(f64): stocks挂单的冻结数量
+/// - `balance(f64)`: 可用计价币数量;
+/// - `frozen_balance(f64)`: balance挂单的冻结数量
+/// - `stocks(f64)`: 可用交易币数量
+/// - `frozen_stocks(f64)`: stocks挂单的冻结数量
 #[derive(Debug)]
 pub struct Account {
     pub balance: f64,
@@ -27,12 +25,49 @@ pub struct Account {
     pub frozen_stocks: f64,
 }
 
+/// Depth结构体
+/// - `time(i64)`: 深度更新时间戳(ms);
+/// - `asks(Vec<DepthItem>)`: 卖方深度列表;
+/// - `bids(Vec<DepthItem>)`: 买方深度列表;
+#[derive(Debug)]
+pub struct Depth {
+    pub time: i64,
+    pub asks: Vec<DepthItem>,
+    pub bids: Vec<DepthItem>,
+}
+
+/// DepthItem结构体
+/// - `price(f64)`: 价格
+/// - `amount(f64)`: 数量
+#[derive(Debug)]
+pub struct DepthItem {
+    pub price: f64,
+    pub amount: f64,
+}
+
+/// Record结构体
+/// - `time(i64)`: 时间戳;
+/// - `open(f64)`: 开盘价;
+/// - `high(f64)`: 最高价;
+/// - `low(f64):` 最低价;
+/// - `close(f64)`: 收盘价;
+/// - `volume(f64)`: 交易量;
+#[derive(Debug)]
+pub struct Record {
+    pub time: i64,
+    pub open: f64,
+    pub high: f64,
+    pub low: f64,
+    pub close: f64,
+    pub volume: f64,
+}
+
 /// 交易所统一方法接口
 ///
 /// 使用方法前需实例化
 /// ```rust
 /// use std::collections::BTreeMap;
-/// use standard::{Exchange, ExchangeEnum};
+/// use standard::exchange::{Exchange, ExchangeEnum};
 ///
 /// let mut params:BTreeMap<String,String> = BTreeMap::new();
 /// params.insert("access_key".to_string(), "your_access_key".to_string());
@@ -43,7 +78,7 @@ pub struct Account {
 /// - fn get_params_info(&self) -> BTreeMap<String,String>;
 /// ```rust
 /// # use std::collections::BTreeMap;
-/// # use standard::{Exchange, ExchangeEnum};
+/// # use standard::exchange::{Exchange, ExchangeEnum};
 /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
 /// # params.insert("access_key".to_string(), "your_access_key".to_string());
 /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
@@ -54,18 +89,18 @@ pub struct Account {
 /// 获取账号信息
 /// ```rust
 /// # use std::collections::BTreeMap;
-/// # use standard::{Exchange, ExchangeEnum};
+/// # use standard::exchange::{Exchange, ExchangeEnum};
 /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
 /// # params.insert("access_key".to_string(), "your_access_key".to_string());
 /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
 /// # let exchange = Exchange::new(ExchangeEnum::BinanceSwap, true, true, params);
 ///
-/// exchange.get_account();
+/// exchange.get_account("BTC_USDT".to_string());
 /// ```
 /// 订阅账号信息
 /// ```rust
 /// # use std::collections::BTreeMap;
-/// # use standard::{Exchange, ExchangeEnum};
+/// # use standard::exchange::{Exchange, ExchangeEnum};
 /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
 /// # params.insert("access_key".to_string(), "your_access_key".to_string());
 /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
@@ -74,77 +109,27 @@ pub struct Account {
 /// exchange.subscribe_account();
 /// ```
 pub trait Platform {
-    fn get_params_info(&self) -> BTreeMap<String, String>;
-    fn get_account(&self) -> Account;
+    // 获取当前交易所交易模式
+    fn get_self_exchange(&self) -> ExchangeEnum;
+    // 获取当前是否使用高速模式
+    fn get_self_is_colo(&self) -> bool;
+    // 获取当前是否使用登录
+    fn get_self_is_login(&self) -> bool;
+    // 获取登录params信息
+    fn get_self_params(&self) -> BTreeMap<String, String>;
+    // 获取账号信息
+    fn get_account(&self, symbol: &str) -> Account;
+    // 获取深度信息
+    fn get_depth(&self) -> Depth;
     // 下单接口
     fn take_order(&self);
     // 获取订单列表
     fn get_order_list(&self);
     // 取消订单
     fn cancel_order(&self);
-    fn subscribe_account(&self);
+    // 订阅账号信息
+    fn subscribe_account(&self) -> Account;
+    // 订阅深度信息
+    fn subscribe_depth(&self) -> Depth;
     fn subscribe_kline(&self);
 }
-
-/// 交易所交易模式枚举
-/// - `BinanceSwap`: Binance交易所;
-/// - `BinanceSpot`: Binance交易所;
-/// - `GateSwap`: Gate交易所;
-/// - `GateSpot`: Gate交易所;
-#[derive(Debug)]
-pub enum ExchangeEnum {
-    BinanceSwap,
-    BinanceSpot,
-    GateSwap,
-    GateSpot,
-}
-
-/// Exchange结构体
-///
-/// 方法:
-/// - 创建Exchange:
-///
-/// new(platform: [PlatformEnum], is_colo: bool, is_login:bool, params: BTreeMap<String, String>) -> Box\<dyn Platform\>
-/// - platform([PlatformEnum]): 交易所平台枚举
-/// - is_colo(bool): 是否开始告诉模式
-/// - is_login(bool): 是否需要登录
-/// - params(BTreeMap\<String, String\>): 登录所需参数
-///
-/// 示例参数值:
-///
-/// | 交易所枚举 | params参数示例 BTreeMap<String,String> |
-/// | --- | --- |
-/// | BinanceSwap | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
-/// | BinanceSpot | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
-/// | GateSwap | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
-/// | GateSpot | {"access_key":"your_access_key","secret_key":"your_secret_key"} |
-///  ```rust
-/// use std::collections::BTreeMap;
-/// use standard::{Exchange, ExchangeEnum};
-///
-/// let mut params:BTreeMap<String,String> = BTreeMap::new();
-/// params.insert("access_key".to_string(), "your_access_key".to_string());
-/// params.insert("access_key".to_string(), "your_secret_key".to_string());
-/// let exchange = Exchange::new(ExchangeEnum::BinanceSwap, true, true, params);
-pub struct Exchange {}
-
-impl Exchange {
-    pub fn new(exchange: ExchangeEnum, is_colo: bool, is_login: bool, params: BTreeMap<String, String>) -> Box<dyn Platform> {
-        match exchange {
-            ExchangeEnum::BinanceSwap => {
-                Box::new(BinanceSwap::new(is_colo, is_login, params))
-            }
-            ExchangeEnum::BinanceSpot => {
-                Box::new(BinanceSpot::new(is_colo, is_login, params))
-            }
-            ExchangeEnum::GateSwap => {
-                Box::new(GateSpot::new(is_colo, is_login, params))
-            }
-            ExchangeEnum::GateSpot => {
-                Box::new(GateSwap::new(is_colo, is_login, params))
-            }
-        }
-    }
-}
-
-

+ 3 - 3
standard/src/utils.rs

@@ -1,6 +1,6 @@
 /// 修改交易对连接符号
-/// - `symbol`(str): 交易对, "BTC_USDT", 默认以下划线传递
-/// - `pat`(str): 替换字符, "-", 把 “_” 替换为 "-"
-pub fn replace_symbol(symbol: &str, pat: &str) -> String {
+/// - `symbol(str)`: 交易对, "BTC_USDT", 默认以下划线传递
+/// - `pat(str)`: 替换字符, "-", 把 “_” 替换为 "-"
+pub fn format_symbol(symbol: &str, pat: &str) -> String {
     return symbol.to_uppercase().replace("_", pat);
 }

+ 50 - 28
standard/tests/libs_test.rs

@@ -1,79 +1,101 @@
 use std::collections::BTreeMap;
-use standard::{Platform, ExchangeEnum, Exchange};
+use standard::Platform;
 use standard::utils;
+use standard::exchange::{Exchange, ExchangeEnum};
 
 // 创建交易所实体方法
-fn test_new_exchange(platform: ExchangeEnum) -> Box<dyn Platform> {
-    match platform {
+fn test_new_exchange(exchange: ExchangeEnum) -> Box<dyn Platform> {
+    match exchange {
         ExchangeEnum::BinanceSwap => {
             let mut params: BTreeMap<String, String> = BTreeMap::new();
             params.insert("access_key".to_string(), "binance_swap_access_key".to_string());
             params.insert("secret_key".to_string(), "binance_swap_secret_key".to_string());
-            Exchange::new(platform, false, false, params)
+            Exchange::new(exchange, false, false, params)
         }
         ExchangeEnum::BinanceSpot => {
             let mut params: BTreeMap<String, String> = BTreeMap::new();
             params.insert("access_key".to_string(), "binance_spot_access_key".to_string());
             params.insert("secret_key".to_string(), "binance_spot_secret_key".to_string());
-            Exchange::new(platform, false, false, params)
+            Exchange::new(exchange, false, false, params)
         }
         ExchangeEnum::GateSwap => {
             let mut params: BTreeMap<String, String> = BTreeMap::new();
             params.insert("access_key".to_string(), "gate_swap_access_key".to_string());
             params.insert("secret_key".to_string(), "gate_swap_secret_key".to_string());
-            Exchange::new(platform, true, false, params)
+            Exchange::new(exchange, true, false, params)
         }
         ExchangeEnum::GateSpot => {
             let mut params: BTreeMap<String, String> = BTreeMap::new();
             params.insert("access_key".to_string(), "gate_spot_access_key".to_string());
             params.insert("secret_key".to_string(), "gate_spot_secret_key".to_string());
-            Exchange::new(platform, true, false, params)
+            Exchange::new(exchange, true, false, params)
         }
     }
 }
 
 
-// 测试获取Binance交易所实体
+// 测试获取Binance交易所期货实体
 #[tokio::test]
 async fn test_binance_swap_account() {
-    let binance_exchange = test_new_exchange(ExchangeEnum::BinanceSwap);
-    binance_exchange.get_account();
-    binance_exchange.subscribe_account();
-    println!("{:?}", binance_exchange.get_params_info());
+    let binance_swap_exchange = test_new_exchange(ExchangeEnum::BinanceSwap);
+    println!("exchange: {:?}", binance_swap_exchange.get_self_exchange());
+    println!("is_colo: {:?}", binance_swap_exchange.get_self_is_colo());
+    println!("is_login: {:?}", binance_swap_exchange.get_self_is_login());
+    println!("params: {:?}", binance_swap_exchange.get_self_params());
 }
+
+// 测试获取Binance交易所现货实体
 #[tokio::test]
 async fn test_binance_spot_account() {
-    let binance_exchange = test_new_exchange(ExchangeEnum::BinanceSpot);
-    binance_exchange.get_account();
-    binance_exchange.subscribe_account();
-    println!("{:?}", binance_exchange.get_params_info());
+    let binance_spot_exchange = test_new_exchange(ExchangeEnum::BinanceSpot);
+    println!("exchange: {:?}", binance_spot_exchange.get_self_exchange());
+    println!("is_colo: {:?}", binance_spot_exchange.get_self_is_colo());
+    println!("is_login: {:?}", binance_spot_exchange.get_self_is_login());
+    println!("params: {:?}", binance_spot_exchange.get_self_params());
 }
-// 测试获取Gate交易所实体
+
+// 测试获取Gate交易所期货实体
 #[tokio::test]
 async fn test_gate_swap_account() {
-    let gate_exchange = test_new_exchange(ExchangeEnum::GateSwap);
-    gate_exchange.get_account();
-    gate_exchange.subscribe_account();
-    println!("{:?}", gate_exchange.get_params_info());
+    let gate_swap_exchange = test_new_exchange(ExchangeEnum::GateSwap);
+    println!("exchange: {:?}", gate_swap_exchange.get_self_exchange());
+    println!("is_colo: {:?}", gate_swap_exchange.get_self_is_colo());
+    println!("is_login: {:?}", gate_swap_exchange.get_self_is_login());
+    println!("params: {:?}", gate_swap_exchange.get_self_params());
 }
-// 测试获取Gate交易所实体
+
+// 测试获取Gate交易所现货实体
 #[tokio::test]
 async fn test_gate_spot_account() {
-    let gate_exchange = test_new_exchange(ExchangeEnum::GateSpot);
-    gate_exchange.get_account();
-    gate_exchange.subscribe_account();
-    println!("{:?}", gate_exchange.get_params_info());
+    let gate_spot_exchange = test_new_exchange(ExchangeEnum::GateSpot);
+    println!("exchange: {:?}", gate_spot_exchange.get_self_exchange());
+    println!("is_colo: {:?}", gate_spot_exchange.get_self_is_colo());
+    println!("is_login: {:?}", gate_spot_exchange.get_self_is_login());
+    println!("params: {:?}", gate_spot_exchange.get_self_params());
 }
 
 // 测试币对连接符号替换
 #[tokio::test]
 async fn test_replace_symbol() {
-    println!("test_replace_symbol: {}", utils::replace_symbol("BTC_USDT", "-"))
+    println!("test_replace_symbol: {}", utils::format_symbol("BTC_USDT", "-"))
+}
+
+// 测试Binance期货K线推送
+#[tokio::test]
+async fn test_get_account() {
+    let binance_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::BinanceSwap);
+    println!("binance_swap account:{:?}", binance_swap_exchange.get_account("BTC_USDT"));
+    let binance_spot_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::BinanceSpot);
+    println!("binance_spot account:{:?}", binance_spot_exchange.get_account("BTC_USDT"));
+    let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap);
+    println!("gate_swap account:{:?}", gate_swap_exchange.get_account("BTC_USDT"));
+    let gate_spot_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSpot);
+    println!("gate_spot account:{:?}", gate_spot_exchange.get_account("BTC_USDT"));
 }
 
 // 测试Binance期货K线推送
 #[tokio::test]
 async fn test_subscribe_kline() {
-    let binance_exchange:Box<dyn Platform> = test_new_exchange(ExchangeEnum::BinanceSwap);
+    let binance_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::BinanceSwap);
     binance_exchange.subscribe_kline();
 }