Przeglądaj źródła

一些修正,mac上的延时可能不一样。

skyfffire 1 rok temu
rodzic
commit
623871312f
3 zmienionych plików z 28 dodań i 4 usunięć
  1. 0 1
      exchanges/Cargo.toml
  2. 24 2
      exchanges/src/socket_tool.rs
  3. 4 1
      standard/src/gate_swap.rs

+ 0 - 1
exchanges/Cargo.toml

@@ -40,7 +40,6 @@ rust_decimal_macros = "1.32.0"
 global = { path="../global" }
 tracing = "0.1"
 tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
-log = "0.4.20"
 
 ##生成 xlsx
 rust_xlsxwriter = "0.58.0"

+ 24 - 2
exchanges/src/socket_tool.rs

@@ -13,7 +13,7 @@ use tokio::net::TcpStream;
 use tokio::sync::Mutex;
 use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
 use tokio_tungstenite::tungstenite::{Error, Message};
-use tracing::trace;
+use tracing::{trace};
 
 use crate::proxy;
 use crate::proxy::{ProxyEnum, ProxyResponseEnum};
@@ -85,6 +85,10 @@ impl AbstractWsMode {
                     let write_clone3 = Arc::clone(&write_arc);
                     let ws_to_stdout = async {
                         while let Some(message) = read.next().await {
+                            if !bool_v1.load(Ordering::Relaxed) {
+                                continue;
+                            }
+
                             let mut write_lock3 = write_clone3.lock().await;
                             let response_data = AbstractWsMode::analysis_message(message, message_text, message_ping, message_pong);
                             // let response_data = func(message);
@@ -102,7 +106,25 @@ impl AbstractWsMode {
                                 */
                                 match code.as_str() {
                                     "200" => {
-                                        if bool_v1.load(Ordering::Relaxed) {
+                                        if data.label.contains("gate_usdt_swap") {
+                                            if data.channel == "futures.order_book" && read_tx.is_empty() {
+                                                read_tx.unbounded_send(data).unwrap();
+                                            } else {
+                                                read_tx.unbounded_send(data).unwrap();
+                                            }
+                                        } else if data.label.contains("binance_usdt_swap") {
+                                            if data.channel == "bookTicker" && read_tx.is_empty() {
+                                                read_tx.unbounded_send(data).unwrap();
+                                            } else {
+                                                read_tx.unbounded_send(data).unwrap();
+                                            }
+                                        } else if data.label.contains("bybit_usdt_swap") {
+                                            if data.channel == "orderbook" && read_tx.is_empty() {
+                                                read_tx.unbounded_send(data).unwrap();
+                                            } else {
+                                                read_tx.unbounded_send(data).unwrap();
+                                            }
+                                        } else {
                                             read_tx.unbounded_send(data).unwrap();
                                         }
                                     }

+ 4 - 1
standard/src/gate_swap.rs

@@ -8,7 +8,7 @@ use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
 use serde_json::json;
 use futures::stream::FuturesUnordered;
 use futures::{TryStreamExt};
-use tracing::{error, debug, trace};
+use tracing::{error, debug, trace, info};
 use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum};
 use exchanges::gate_swap_rest::GateSwapRest;
 use global::trace_stack::TraceStack;
@@ -586,6 +586,9 @@ impl Platform for GateSwap {
                     Ok(mut result) => {
                         // 记录此订单完成时间
                         ts.on_after_send();
+
+                        info!("{}", ts.to_string());
+
                         result.trace_stack = ts;
 
                         result_sd.send(result).await.unwrap();