Change filtering

This commit is contained in:
Sik Yoon 2024-03-28 01:17:29 +09:00
parent f62078793e
commit 3193cfac5f

View File

@ -89,7 +89,7 @@ pub async fn list_up_for_buy(
values.current_price = current_price;
values.closetime = rt_price_vec.last().unwrap().close_time;
values.stoploss = band_value;
values.target_price = decimal_add(decimal_mul(decimal_sub(open_price, values.stoploss), dec!(2.0)), open_price);
values.target_price = decimal_add(decimal_mul(decimal_sub(current_price, values.stoploss), dec!(2.0)), current_price);
} else if supertrend_vec.last().unwrap().area == SuperTrendArea::DOWN &&
band_value > current_price &&
band_value > open_price
@ -97,7 +97,7 @@ pub async fn list_up_for_buy(
values.current_price = current_price;
values.closetime = rt_price_vec.last().unwrap().close_time;
values.stoploss = decimal_sub(open_price, decimal_sub(band_value, open_price));
values.target_price = decimal_add(decimal_mul(decimal_sub(open_price, values.stoploss), dec!(2.0)), open_price);
values.target_price = decimal_add(decimal_mul(decimal_sub(open_price, values.stoploss), dec!(2.0)), current_price);
} else {
keys_to_remove.insert(symbol.clone());
@ -131,7 +131,7 @@ pub async fn list_up_for_buy(
}
remove_keys(&mut filtered_data, keys_to_remove).await;
// limit buy price: 3 * abs(이전 3 개 중 최대값 제거 한 opclo 값 평균 - 현재 open 값) + 현재 open 값 > current_price
// limit buy price: 2 * abs(이전 5 개 중 최대값 제거 한 opclo 값 평균 - 현재 open 값) + 현재 open 값 > current_price
let mut keys_to_remove: HashSet<String> = HashSet::new();
let server_epoch = get_server_epoch().await;
for (symbol, values) in &mut filtered_data {
@ -154,7 +154,7 @@ pub async fn list_up_for_buy(
let current_price = rt_price_vec.last().unwrap().close_price;
let difference = (mean - rt_price_vec.last().unwrap().open_price).abs();
if current_price < rt_price_vec.last().unwrap().open_price + (3.0 * difference) {
if current_price < rt_price_vec.last().unwrap().open_price + (2.0 * difference) {
} else {
keys_to_remove.insert(symbol.clone());
}