|
|
@@ -3,14 +3,11 @@ use std::sync::Arc;
|
|
|
use std::sync::atomic::AtomicBool;
|
|
|
use std::time::Duration;
|
|
|
use rust_decimal::Decimal;
|
|
|
-use serde_json::Value;
|
|
|
-use tracing::{info};
|
|
|
use tokio::spawn;
|
|
|
-use tokio::sync::mpsc::channel;
|
|
|
use tokio::sync::Mutex;
|
|
|
use tokio::time::sleep;
|
|
|
-use exchanges::gate_swap_rest::GateSwapRest;
|
|
|
-use exchanges::gate_swap_ws::{GateSubscribeType, GateSwapWs, GateWsType};
|
|
|
+use tokio::sync::mpsc::channel;
|
|
|
+// use exchanges::gate_swap_ws::{GateSubscribeType, GateSwapWs, GateWsType};
|
|
|
use exchanges::response_base::ResponseData;
|
|
|
use global::trace_stack::TraceStack;
|
|
|
use standard::exchange::ExchangeEnum::GateSwap;
|
|
|
@@ -20,41 +17,41 @@ use crate::quant::Quant;
|
|
|
// 1交易、0参考 gate 合约 启动
|
|
|
pub async fn gate_swap_run(bool_v1 :Arc<AtomicBool>, type_num: i8, quant_arc: Arc<Mutex<Quant>>, name: String, symbols: Vec<String>, exchange_params: BTreeMap<String, String>){
|
|
|
let (tx, mut rx) = channel(100);
|
|
|
- let mut gate_exc = GateSwapRest::new(false, exchange_params.clone());
|
|
|
- let mut user_id= "".to_string();
|
|
|
- let symbols_one = symbols.clone();
|
|
|
-
|
|
|
- // 交易
|
|
|
- if type_num == 1{
|
|
|
- // 获取user_id
|
|
|
- let res_data = gate_exc.wallet_fee().await;
|
|
|
- assert_eq!(res_data.code, "200", "获取gate交易所参数 user_id 失败, 启动失败!");
|
|
|
-
|
|
|
- let wallet_obj :Value = serde_json::from_str(&res_data.data).unwrap();
|
|
|
- info!(?wallet_obj);
|
|
|
- user_id = wallet_obj["user_id"].to_string();
|
|
|
- }
|
|
|
-
|
|
|
- spawn( async move {
|
|
|
- let mut gate_exc = GateSwapWs::new_label(name, false, exchange_params,
|
|
|
- GateWsType::PublicAndPrivate("usdt".to_string()), tx);
|
|
|
- // 交易
|
|
|
- if type_num == 1 {
|
|
|
- gate_exc.set_subscribe(vec![
|
|
|
- GateSubscribeType::PuFuturesTrades,
|
|
|
- GateSubscribeType::PuFuturesOrderBook,
|
|
|
- GateSubscribeType::PrFuturesOrders(user_id.clone()),
|
|
|
- GateSubscribeType::PrFuturesPositions(user_id.clone()),
|
|
|
- GateSubscribeType::PrFuturesBalances(user_id.clone()),
|
|
|
- ]);
|
|
|
- } else { // 参考
|
|
|
- gate_exc.set_subscribe(vec![
|
|
|
- GateSubscribeType::PuFuturesTrades,
|
|
|
- GateSubscribeType::PuFuturesOrderBook
|
|
|
- ]);
|
|
|
- }
|
|
|
- gate_exc.custom_subscribe(bool_v1,symbols_one).await;
|
|
|
- });
|
|
|
+ // let mut gate_exc = GateSwapRest::new(false, exchange_params.clone());
|
|
|
+ // let mut user_id= "".to_string();
|
|
|
+ // let symbols_one = symbols.clone();
|
|
|
+ //
|
|
|
+ // // 交易
|
|
|
+ // if type_num == 1{
|
|
|
+ // // 获取user_id
|
|
|
+ // let res_data = gate_exc.wallet_fee().await;
|
|
|
+ // assert_eq!(res_data.code, "200", "获取gate交易所参数 user_id 失败, 启动失败!");
|
|
|
+ //
|
|
|
+ // let wallet_obj :Value = serde_json::from_str(&res_data.data).unwrap();
|
|
|
+ // info!(?wallet_obj);
|
|
|
+ // user_id = wallet_obj["user_id"].to_string();
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // spawn( async move {
|
|
|
+ // let mut gate_exc = GateSwapWs::new_label(name, false, exchange_params,
|
|
|
+ // GateWsType::PublicAndPrivate("usdt".to_string()), tx);
|
|
|
+ // // 交易
|
|
|
+ // if type_num == 1 {
|
|
|
+ // gate_exc.set_subscribe(vec![
|
|
|
+ // GateSubscribeType::PuFuturesTrades,
|
|
|
+ // GateSubscribeType::PuFuturesOrderBook,
|
|
|
+ // GateSubscribeType::PrFuturesOrders(user_id.clone()),
|
|
|
+ // GateSubscribeType::PrFuturesPositions(user_id.clone()),
|
|
|
+ // GateSubscribeType::PrFuturesBalances(user_id.clone()),
|
|
|
+ // ]);
|
|
|
+ // } else { // 参考
|
|
|
+ // gate_exc.set_subscribe(vec![
|
|
|
+ // GateSubscribeType::PuFuturesTrades,
|
|
|
+ // GateSubscribeType::PuFuturesOrderBook
|
|
|
+ // ]);
|
|
|
+ // }
|
|
|
+ // gate_exc.custom_subscribe(bool_v1,symbols_one).await;
|
|
|
+ // });
|
|
|
spawn(async move {
|
|
|
let bot_arc_clone = Arc::clone(&quant_arc);
|
|
|
let multiplier = bot_arc_clone.lock().await.platform_rest.get_self_market().amount_size;
|