diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index 6df913b..f5d7404 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -125,9 +125,9 @@ pub async fn list_up_for_buy( .min_by(|x, y| x.opclo_price.partial_cmp(&y.opclo_price).unwrap()) .unwrap().opclo_price; if values.current_price.to_f64().is_some_and(|a| a > min_price) { - let stoploss_percent = ((min_price - values.current_price.to_f64().unwrap()) * 100.0) / values.current_price.to_f64().unwrap(); + let stoploss_percent = ((min_price - values.current_price.to_f64().unwrap()) * 100.0) / (values.current_price.to_f64().unwrap() * 2.0); values.stoploss = rust_decimal::prelude::FromPrimitive::from_f64(stoploss_percent).unwrap(); - let target_percent = stoploss_percent.abs() * 2.0; + let target_percent = stoploss_percent.abs() * 1.25; values.target_price = rust_decimal::prelude::FromPrimitive::from_f64(target_percent).unwrap(); if stoploss_percent < - 0.07 { do_buy = true; @@ -331,7 +331,7 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha .timeout(tokio::time::Duration::from_millis(5000)) .build() .unwrap(); - + let server_epoch = get_server_epoch().await; for element in filled_positions { let mut is_sell = false; @@ -357,6 +357,8 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha is_sell = true; } else if element.pure_profit_percent <= element.stoploss_percent { is_sell = true; + } else if server_epoch - element.close_time > 1_800_000 { + is_sell = true; } if is_sell == true { diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index a9dddb5..1ac51ea 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -125,9 +125,9 @@ pub async fn list_up_for_buy( .max_by(|x, y| x.opclo_price.partial_cmp(&y.opclo_price).unwrap()) .unwrap().opclo_price; if values.current_price.to_f64().is_some_and(|a| a < max_price) { - let stoploss_percent = ((values.current_price.to_f64().unwrap() - max_price) * 100.0) / values.current_price.to_f64().unwrap(); + let stoploss_percent = ((values.current_price.to_f64().unwrap() - max_price) * 100.0) / (values.current_price.to_f64().unwrap() * 2.0); values.stoploss = rust_decimal::prelude::FromPrimitive::from_f64(stoploss_percent).unwrap(); - let target_percent = stoploss_percent.abs() * 2.0; + let target_percent = stoploss_percent.abs() * 1.25; values.target_price = rust_decimal::prelude::FromPrimitive::from_f64(target_percent).unwrap(); if stoploss_percent < - 0.07 { do_buy = true; @@ -331,7 +331,7 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha .timeout(tokio::time::Duration::from_millis(5000)) .build() .unwrap(); - + let server_epoch = get_server_epoch().await; for element in filled_positions { let mut is_sell = false; @@ -348,6 +348,8 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha is_sell = true; } else if element.pure_profit_percent <= element.stoploss_percent { is_sell = true; + } else if server_epoch - element.close_time > 1_800_000 { + is_sell = true; } if is_sell == true {