|
|
@@ -1101,7 +1101,7 @@ impl Quant {
|
|
|
}
|
|
|
|
|
|
pub async fn check_position_spot(&mut self, target_hold_coin: Decimal) {
|
|
|
- info!("检查遗漏仓位(现货),目标持仓:{}USDT。", target_hold_coin);
|
|
|
+ info!("---------------------------检查遗漏仓位(现货),目标持仓:{}USDT---------------------------", target_hold_coin);
|
|
|
match self.platform_rest.get_spot_account().await {
|
|
|
Ok(mut val) => {
|
|
|
// 如果返回的数组里没有交易货币,则补充交易货币
|
|
|
@@ -1176,16 +1176,18 @@ impl Quant {
|
|
|
error!("获取仓位信息异常: {}", err);
|
|
|
}
|
|
|
}
|
|
|
+ info!("---------------------------遗漏仓位检查完毕(现货)!-----------------------------------");
|
|
|
}
|
|
|
|
|
|
pub async fn check_position_swap(&mut self) {
|
|
|
- info!("检查遗漏仓位(合约)!");
|
|
|
+ info!("---------------------------检查遗漏仓位(合约)!-----------------------------------");
|
|
|
match self.platform_rest.get_positions().await {
|
|
|
Ok(val) => {
|
|
|
for position in val {
|
|
|
if position.amount.eq(&Decimal::ZERO) {
|
|
|
continue;
|
|
|
}
|
|
|
+ info!("仓位获取到:{:?}", position);
|
|
|
match self.platform_rest.get_ticker_symbol(position.symbol.clone()).await {
|
|
|
Ok(ticker) => {
|
|
|
let ap = ticker.sell;
|
|
|
@@ -1200,7 +1202,7 @@ impl Quant {
|
|
|
market_info = market;
|
|
|
}
|
|
|
Err(err) => {
|
|
|
- error!("获取当前market异常: {}", err);
|
|
|
+ error!("{} 获取当前market异常: {}", position.symbol.clone(), err);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -1217,7 +1219,7 @@ impl Quant {
|
|
|
side = "pk";
|
|
|
}
|
|
|
_ => {
|
|
|
- info!("仓位匹配失败,不做操作!");
|
|
|
+ info!("仓位position_mode匹配失败,不做操作!");
|
|
|
// 执行完当前币对 结束循环
|
|
|
continue;
|
|
|
}
|
|
|
@@ -1225,19 +1227,19 @@ impl Quant {
|
|
|
// 发起清仓订单
|
|
|
match self.platform_rest.take_order_symbol(position.symbol.clone(), Decimal::ONE, utils::generate_client_id(None).as_str(), side, price, position.amount.abs()).await {
|
|
|
Ok(order) => {
|
|
|
- info!("{} 清仓下单,{:?}", position.symbol, order);
|
|
|
+ info!("{}仓位清除下单成功 {:?}", position.symbol.clone(), order);
|
|
|
// 执行完当前币对 结束循环
|
|
|
continue;
|
|
|
}
|
|
|
Err(error) => {
|
|
|
- error!("{} 清仓下单异常:{}", position.symbol, error);
|
|
|
+ error!("{}仓位清除下单异常 {}", position.symbol.clone(), error);
|
|
|
// 执行完当前币对 结束循环
|
|
|
continue;
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
Err(err) => {
|
|
|
- error!("获取当前ticker异常: {}",err)
|
|
|
+ error!("{} 获取当前ticker异常: {}", position.symbol.clone(), err)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1246,6 +1248,7 @@ impl Quant {
|
|
|
error!("获取仓位信息异常: {}", error);
|
|
|
}
|
|
|
}
|
|
|
+ info!("---------------------------遗漏仓位检查完毕(合约)!-----------------------------------");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1365,10 +1368,10 @@ impl Quant {
|
|
|
short_one_hand_amount = (short_one_hand_value / mp / self.strategy.step_size).floor() * self.strategy.step_size;
|
|
|
}
|
|
|
info!("最低单手交易下单量为 buy: {}, sell: {}", long_one_hand_amount, short_one_hand_amount);
|
|
|
+ info!(?long_one_hand_value, ?short_one_hand_value, ?long_one_hand_amount, ?short_one_hand_amount, ?self.local_cash, ?self.local_coin);
|
|
|
let hand_min_limit = Decimal::new(5, 0);
|
|
|
if (long_one_hand_amount.is_zero() && short_one_hand_amount.is_zero()) ||
|
|
|
(long_one_hand_value < hand_min_limit && short_one_hand_value < hand_min_limit) {
|
|
|
- info!(?long_one_hand_value, ?short_one_hand_value, ?long_one_hand_amount, ?short_one_hand_amount, ?self.local_cash, ?self.local_coin);
|
|
|
self.exit_msg = format!("请检查账户余额!初始下单量太少 buy: {} sell: {}", long_one_hand_amount, short_one_hand_amount);
|
|
|
// 停止程序
|
|
|
self.stop().await;
|