|
|
@@ -2,11 +2,9 @@ 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 exchanges::binance_spot_ws::{BinanceSpotLogin, BinanceSpotSubscribeType, BinanceSpotWs, BinanceSpotWsType};
|
|
|
// use exchanges::binance_swap_ws::{BinanceSwapLogin, BinanceSwapSubscribeType, BinanceSwapWs, BinanceSwapWsType};
|
|
|
@@ -14,16 +12,18 @@ use tracing::{error, trace};
|
|
|
// 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::okx_swap_ws::{OkxSwapLogin, OkxSwapSubscribeType, OkxSwapWs, OkxSwapWsType};
|
|
|
+use exchanges::htx_swap_ws::{HtxSwapLogin, HtxSwapSubscribeType, HtxSwapWs, HtxSwapWsType};
|
|
|
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};
|
|
|
// use standard::{kucoin_handle, Order, Platform, utils};
|
|
|
// use standard::{kucoin_spot_handle, Order, Platform, utils};
|
|
|
-// use standard::{gate_handle, Order, Platform, utils};
|
|
|
+// use standard::{gate_swap_handle, handle_info, Order, Platform, utils};
|
|
|
// use standard::{bitget_spot_handle, Order, Platform, utils};
|
|
|
-use standard::{okx_handle, Order, Platform, utils};
|
|
|
+// use standard::{okx_handle, Order, Platform, utils};
|
|
|
+use standard::{htx_swap_handle, handle_info, Order, Platform, utils};
|
|
|
|
|
|
// 创建实体
|
|
|
#[allow(dead_code)]
|
|
|
@@ -42,14 +42,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,14 +58,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::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::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;
|
|
|
@@ -76,99 +76,132 @@ pub async fn test_new_exchange(exchange: ExchangeEnum, symbol: &str) -> Box<dyn
|
|
|
params.insert("pass_key".to_string(), pass_key);
|
|
|
Exchange::new(exchange, symbol.to_string(), false, params, order_sender, error_sender).await
|
|
|
}
|
|
|
- ExchangeEnum::KucoinSpot => {
|
|
|
+ // 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::BitgetSwap => {
|
|
|
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;
|
|
|
+ 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::OkxSwap => {
|
|
|
+ ExchangeEnum::BybitSwap => {
|
|
|
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;
|
|
|
+ let access_key = account_info.bybit_access_key;
|
|
|
+ let secret_key = account_info.bybit_secret_key;
|
|
|
+ let pass_key = account_info.bybit_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 => {
|
|
|
+ ExchangeEnum::HtxSwap => {
|
|
|
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;
|
|
|
+ let access_key = account_info.htx_access_key;
|
|
|
+ let secret_key = account_info.htx_secret_key;
|
|
|
+ let pass_key = account_info.htx_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!("该交易所未实现!")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#[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<HtxSwapSubscribeType>: From<T> {
|
|
|
utils::proxy_handle();
|
|
|
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::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);
|
|
|
@@ -291,81 +324,80 @@ pub async fn test_new_exchange_wss<T>(exchange: ExchangeEnum, symbol: &str, subs
|
|
|
// });
|
|
|
// 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::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));
|
|
|
//
|
|
|
@@ -377,204 +409,268 @@ pub async fn test_new_exchange_wss<T>(exchange: ExchangeEnum, symbol: &str, subs
|
|
|
// 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 bool_v3_clone = Arc::clone(&is_shutdown_arc);
|
|
|
+ // let mold_clone = mold.to_string().clone();
|
|
|
+ // let fun = move |data: ResponseData| {
|
|
|
+ // let symbol_format_c = symbol_format.clone();
|
|
|
+ // let mold_cc = mold_clone.clone();
|
|
|
//
|
|
|
- // 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)
|
|
|
- // }
|
|
|
+ // async move {
|
|
|
+ // trace!("原始数据 data:{:?}",data);
|
|
|
+ // match mold_cc.as_str() {
|
|
|
+ // "depth" => {
|
|
|
+ // if data.data != "" {
|
|
|
+ // let result = handle_info::format_depth(ExchangeEnum::GateSwap, &data);
|
|
|
+ // trace!(?result)
|
|
|
// }
|
|
|
- // "account" => {
|
|
|
- // if data.data != "" {
|
|
|
- // let result = bitget_spot_handle::handle_account_info(data, symbol_back.clone());
|
|
|
- // trace!(?result)
|
|
|
- // }
|
|
|
+ // }
|
|
|
+ // "ticker" => {
|
|
|
+ // if data.data != "" {
|
|
|
+ // let result = gate_swap_handle::handle_book_ticker(&data);
|
|
|
+ // trace!(?result)
|
|
|
// }
|
|
|
- // "orders" => {
|
|
|
- // if data.data != "" {
|
|
|
- // let result = bitget_spot_handle::handle_order(data, dec!(1));
|
|
|
- // trace!(?result)
|
|
|
- // }
|
|
|
+ // }
|
|
|
+ // "account" => {
|
|
|
+ // if data.data != "" {
|
|
|
+ // let result = gate_swap_handle::handle_account_info(&data, &symbol_format_c);
|
|
|
+ // trace!(?result)
|
|
|
// }
|
|
|
- // _ => {
|
|
|
- // error!("没有该命令!mode={}", mold_clone);
|
|
|
- // panic!("没有该命令!mode={}", mold_clone)
|
|
|
+ // }
|
|
|
+ // "orders" => {
|
|
|
+ // if data.data != "" {
|
|
|
+ // let result = gate_swap_handle::handle_order(data, dec!(1));
|
|
|
+ // trace!(?result)
|
|
|
// }
|
|
|
// }
|
|
|
- // }
|
|
|
+ // _ => {
|
|
|
+ // error!("没有该命令!mode={}", mold_cc);
|
|
|
+ // panic!("没有该命令!mode={}", mold_cc)
|
|
|
+ // }
|
|
|
+ // };
|
|
|
// }
|
|
|
- // });
|
|
|
- // 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();
|
|
|
+ // };
|
|
|
+ // exchange_wss.ws_connect_async(bool_v3_clone, fun, &write_tx_am, write_rx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
|
|
|
}
|
|
|
- ExchangeEnum::OkxSwap => {
|
|
|
+ // 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::HtxSwap => {
|
|
|
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 name = format!("htx_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 params = HtxSwapLogin {
|
|
|
+ api_key: account_info.htx_access_key,
|
|
|
+ secret: account_info.htx_secret_key,
|
|
|
};
|
|
|
|
|
|
- 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)
|
|
|
+ let htx_wss_type = match mold.to_string().clone().as_str() {
|
|
|
+ "depth" => HtxSwapWsType::Public,
|
|
|
+ _ => HtxSwapWsType::Private
|
|
|
};
|
|
|
|
|
|
+ let mut exchange_wss = HtxSwapWs::new_label(name, Option::from(params), htx_wss_type);
|
|
|
exchange_wss.set_symbols(vec![symbol_format.clone()]);
|
|
|
exchange_wss.set_subscribe(subscriber_type.into());
|
|
|
+ let bool_v3_clone = Arc::clone(&is_shutdown_arc);
|
|
|
+ let mold_clone = mold.to_string().clone();
|
|
|
+ let fun = move |data: ResponseData| {
|
|
|
+ let symbol_format_c = symbol_format.clone();
|
|
|
+ let mold_cc = mold_clone.clone();
|
|
|
|
|
|
- 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)
|
|
|
- }
|
|
|
+ async move {
|
|
|
+ trace!("原始数据 data:{:?}",data);
|
|
|
+ match mold_cc.as_str() {
|
|
|
+ "depth" => {
|
|
|
+ if data.data != "" {
|
|
|
+ let result = handle_info::format_depth(ExchangeEnum::HtxSwap, &data);
|
|
|
+ trace!("-------------------------------");
|
|
|
+ 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)
|
|
|
- }
|
|
|
+ }
|
|
|
+ "position" => {
|
|
|
+ if data.data != "" {
|
|
|
+ let result = htx_swap_handle::handle_position(&data, &dec!(10));
|
|
|
+ trace!("-------------------------------");
|
|
|
+ trace!(?result)
|
|
|
}
|
|
|
- "orders" => {
|
|
|
- if data.data != "" {
|
|
|
- let result = okx_handle::handle_order(data, dec!(10));
|
|
|
- trace!(?result)
|
|
|
- }
|
|
|
+ }
|
|
|
+ "account" => {
|
|
|
+ if data.data != "" {
|
|
|
+ let result = htx_swap_handle::handle_account_info(&data, &symbol_format_c);
|
|
|
+ trace!("-------------------------------");
|
|
|
+ trace!(?result)
|
|
|
}
|
|
|
- _ => {
|
|
|
- error!("没有该命令!mode={}", mold_clone);
|
|
|
- panic!("没有该命令!mode={}", mold_clone)
|
|
|
+ }
|
|
|
+ "orders" => {
|
|
|
+ println!("{:?}", data);
|
|
|
+ if data.data != "" {
|
|
|
+ let result = htx_swap_handle::handle_order(data, dec!(10));
|
|
|
+ trace!("-------------------------------");
|
|
|
+ trace!(?result)
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ _ => {
|
|
|
+ error!("没有该命令!mode={}", mold_cc);
|
|
|
+ panic!("没有该命令!mode={}", mold_cc)
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- 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();
|
|
|
+ };
|
|
|
+ exchange_wss.ws_connect_async(bool_v3_clone, fun, &write_tx_am, write_rx).await.expect("链接失败(内部一个心跳线程应该已经关闭了)");
|
|
|
}
|
|
|
_ => {
|
|
|
- error!("该交易所不支持!test_new_exchange_wss:{:?}",exchange);
|
|
|
+ error!("该交易所不支持!test_new_exchange_wss:{:?}", exchange);
|
|
|
panic!("该交易所不支持!test_new_exchange_wss:{:?}", exchange)
|
|
|
}
|
|
|
}
|