| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- // 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};
- // // 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 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::{bitget_spot_handle, Order, Platform, utils};
- // use standard::{okx_handle, Order, Platform, utils};
- //
- // // 创建实体
- // #[allow(dead_code)]
- // pub async fn test_new_exchange(exchange: ExchangeEnum, symbol: &str) -> Box<dyn Platform> {
- // utils::proxy_handle();
- // let (order_sender, _order_receiver): (Sender<Order>, Receiver<Order>) = channel(1024);
- // let (error_sender, _error_receiver): (Sender<Error>, Receiver<Error>) = channel(1024);
- //
- // let account_info = global::account_info::get_account_info("../test_account.toml");
- // match exchange {
- // ExchangeEnum::BinanceSwap => {
- // 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;
- // 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;
- // 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
- // }
- // }
- // }
- //
- // #[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> {
- // 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_with_tag(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_with_tag(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_with_tag(name, false, Option::from(params), KucoinSwapWsType::Public).await;
- // // } else {
- // // exchange_wss = KucoinSwapWs::new_with_tag(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_with_tag(name, false, Option::from(params), KucoinSpotWsType::Public).await
- // // } else {
- // // KucoinSpotWs::new_with_tag(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_with_tag(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_with_tag(name, false, Option::from(params), BitgetSpotWsType::Public)
- // // } else {
- // // BitgetSpotWs::new_with_tag(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_with_tag(name, false, Option::from(params), OkxSwapWsType::Public)
- // } else if ["account", "orders", "position"].contains(&mold) {
- // OkxSwapWs::new_with_tag(name, false, Option::from(params), OkxSwapWsType::Private)
- // } else {
- // OkxSwapWs::new_with_tag(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)
- // }
- // }
- // }
|