|
@@ -465,11 +465,12 @@ impl ClearCore {
|
|
|
match self.platform_rest.get_positions().await {
|
|
match self.platform_rest.get_positions().await {
|
|
|
Ok(val) => {
|
|
Ok(val) => {
|
|
|
info!("检查仓位信息");
|
|
info!("检查仓位信息");
|
|
|
- result.clear_position_num = val.len().to_string();
|
|
|
|
|
|
|
+ let mut position_num = 0;
|
|
|
for position in val {
|
|
for position in val {
|
|
|
if position.amount.eq(&Decimal::ZERO) {
|
|
if position.amount.eq(&Decimal::ZERO) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ position_num = position_num + 1;
|
|
|
info!(" 仓位:{:?}", position);
|
|
info!(" 仓位:{:?}", position);
|
|
|
let price = Decimal::ZERO;
|
|
let price = Decimal::ZERO;
|
|
|
let side;
|
|
let side;
|
|
@@ -516,6 +517,7 @@ impl ClearCore {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
+ result.clear_position_num = position_num.to_string();
|
|
|
}
|
|
}
|
|
|
Err(error) => {
|
|
Err(error) => {
|
|
|
result.clear_other_err = true;
|
|
result.clear_other_err = true;
|
|
@@ -531,13 +533,13 @@ impl ClearCore {
|
|
|
|
|
|
|
|
|
|
|
|
|
// #[instrument(skip(self), level="TRACE")]
|
|
// #[instrument(skip(self), level="TRACE")]
|
|
|
- pub async fn exit(&mut self, check_id: String) -> bool {
|
|
|
|
|
|
|
+ pub async fn exit(&mut self, r_id: String) -> bool {
|
|
|
info!("-------------------------启动退出流程({})----------------------------", self.exit_msg);
|
|
info!("-------------------------启动退出流程({})----------------------------", self.exit_msg);
|
|
|
info!("");
|
|
info!("");
|
|
|
|
|
|
|
|
let mut result = self.check_position().await;
|
|
let mut result = self.check_position().await;
|
|
|
// 设置机器人id
|
|
// 设置机器人id
|
|
|
- result.r_id = check_id;
|
|
|
|
|
|
|
+ result.r_id = r_id;
|
|
|
info!("清仓程序结果 {:?}", result);
|
|
info!("清仓程序结果 {:?}", result);
|
|
|
// 判断是否有清仓,是否有异常
|
|
// 判断是否有清仓,是否有异常
|
|
|
if result.clear_position_num != "0" || result.clear_order_num != "0" || result.clear_other_err{
|
|
if result.clear_position_num != "0" || result.clear_order_num != "0" || result.clear_other_err{
|
|
@@ -642,7 +644,7 @@ pub async fn send_clear_msg_request(body_params: &ClearPositionResult) {
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
// 发送 POST 请求
|
|
|
let res = client
|
|
let res = client
|
|
|
- .post("https://t4lapi.skyfffire.com/api/report/searchPositions")
|
|
|
|
|
|
|
+ .post("https://4lapi.skyfffire.com/api/report/searchPositions")
|
|
|
.body(body)
|
|
.body(body)
|
|
|
.headers(headers)
|
|
.headers(headers)
|
|
|
.send()
|
|
.send()
|