Update filtering
This commit is contained in:
parent
5123ac7647
commit
4afe543dc4
|
|
@ -125,9 +125,9 @@ pub async fn list_up_for_buy(
|
||||||
.min_by(|x, y| x.opclo_price.partial_cmp(&y.opclo_price).unwrap())
|
.min_by(|x, y| x.opclo_price.partial_cmp(&y.opclo_price).unwrap())
|
||||||
.unwrap().opclo_price;
|
.unwrap().opclo_price;
|
||||||
if values.current_price.to_f64().is_some_and(|a| a > min_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();
|
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();
|
values.target_price = rust_decimal::prelude::FromPrimitive::from_f64(target_percent).unwrap();
|
||||||
if stoploss_percent < - 0.07 {
|
if stoploss_percent < - 0.07 {
|
||||||
do_buy = true;
|
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))
|
.timeout(tokio::time::Duration::from_millis(5000))
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let server_epoch = get_server_epoch().await;
|
||||||
for element in filled_positions {
|
for element in filled_positions {
|
||||||
let mut is_sell = false;
|
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;
|
is_sell = true;
|
||||||
} else if element.pure_profit_percent <= element.stoploss_percent {
|
} else if element.pure_profit_percent <= element.stoploss_percent {
|
||||||
is_sell = true;
|
is_sell = true;
|
||||||
|
} else if server_epoch - element.close_time > 1_800_000 {
|
||||||
|
is_sell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_sell == true {
|
if is_sell == true {
|
||||||
|
|
|
||||||
|
|
@ -125,9 +125,9 @@ pub async fn list_up_for_buy(
|
||||||
.max_by(|x, y| x.opclo_price.partial_cmp(&y.opclo_price).unwrap())
|
.max_by(|x, y| x.opclo_price.partial_cmp(&y.opclo_price).unwrap())
|
||||||
.unwrap().opclo_price;
|
.unwrap().opclo_price;
|
||||||
if values.current_price.to_f64().is_some_and(|a| a < max_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();
|
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();
|
values.target_price = rust_decimal::prelude::FromPrimitive::from_f64(target_percent).unwrap();
|
||||||
if stoploss_percent < - 0.07 {
|
if stoploss_percent < - 0.07 {
|
||||||
do_buy = true;
|
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))
|
.timeout(tokio::time::Duration::from_millis(5000))
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let server_epoch = get_server_epoch().await;
|
||||||
for element in filled_positions {
|
for element in filled_positions {
|
||||||
let mut is_sell = false;
|
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;
|
is_sell = true;
|
||||||
} else if element.pure_profit_percent <= element.stoploss_percent {
|
} else if element.pure_profit_percent <= element.stoploss_percent {
|
||||||
is_sell = true;
|
is_sell = true;
|
||||||
|
} else if server_epoch - element.close_time > 1_800_000 {
|
||||||
|
is_sell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_sell == true {
|
if is_sell == true {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user