|
|
@@ -4,14 +4,14 @@ use std::sync::atomic::AtomicBool;
|
|
|
use rust_decimal::Decimal;
|
|
|
use tokio::spawn;
|
|
|
use tokio::sync::Mutex;
|
|
|
-use tracing::{error, info};
|
|
|
+use tracing::{error};
|
|
|
use tokio_tungstenite::tungstenite::Message;
|
|
|
use exchanges::bitget_swap_ws::{BitgetSwapLogin, BitgetSwapSubscribeType, BitgetSwapWs, BitgetSwapWsType};
|
|
|
use exchanges::response_base::ResponseData;
|
|
|
use global::trace_stack::TraceStack;
|
|
|
use standard::exchange::ExchangeEnum::BitgetSwap;
|
|
|
use standard::exchange_struct_handler::ExchangeStructHandler;
|
|
|
-use standard::{Depth, OrderBook};
|
|
|
+use standard::{Depth, OrderBook, Position, PositionModeEnum};
|
|
|
use crate::core::Core;
|
|
|
use crate::exchange_disguise::{on_depth, on_record, on_ticker, on_trade};
|
|
|
use crate::model::OrderInfo;
|
|
|
@@ -133,9 +133,9 @@ async fn on_private_data(core_arc_clone: Arc<Mutex<Core>>, ct_val: &Decimal, run
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if order.deal_amount != Decimal::ZERO {
|
|
|
- info!("bitget order 消息原文:{:?}", response);
|
|
|
- }
|
|
|
+ // if order.deal_amount != Decimal::ZERO {
|
|
|
+ // info!("bitget order 消息原文:{:?}", response);
|
|
|
+ // }
|
|
|
|
|
|
let order_info = OrderInfo::parse_order_to_order_info(&mut order);
|
|
|
order_infos.push(order_info);
|
|
|
@@ -145,8 +145,22 @@ async fn on_private_data(core_arc_clone: Arc<Mutex<Core>>, ct_val: &Decimal, run
|
|
|
core.update_order(order_infos, trace_stack).await;
|
|
|
}
|
|
|
"position" => {
|
|
|
- let positions = ExchangeStructHandler::position_handle(BitgetSwap, response, ct_val);
|
|
|
+ let mut positions = ExchangeStructHandler::position_handle(BitgetSwap, response, ct_val);
|
|
|
let mut core = core_arc_clone.lock().await;
|
|
|
+
|
|
|
+ if positions.is_empty() {
|
|
|
+ positions.push(Position {
|
|
|
+ symbol: run_symbol.to_string(),
|
|
|
+ margin_level: Default::default(),
|
|
|
+ amount: Default::default(),
|
|
|
+ frozen_amount: Default::default(),
|
|
|
+ price: Default::default(),
|
|
|
+ profit: Default::default(),
|
|
|
+ position_mode: PositionModeEnum::Both,
|
|
|
+ margin: Default::default(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
core.update_position(positions).await;
|
|
|
}
|
|
|
_ => {
|