Update filtering

This commit is contained in:
Sik Yoon 2024-05-30 23:06:20 +09:00
parent 5123ac7647
commit 4afe543dc4
2 changed files with 10 additions and 6 deletions

View File

@ -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 {

View File

@ -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 {