From 805d8c87e869177a0c873b3f1702fad2c1520028 Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Thu, 6 Jun 2024 14:14:09 +0900 Subject: [PATCH] Update filtering --- src/strategy_team/future_strategy_long.rs | 9 ++++++--- src/strategy_team/future_strategy_short.rs | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index 965aca1..b17bad6 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -42,6 +42,7 @@ pub async fn list_up_for_buy( if lr_vec.len() > 10 && lr_vec.last().is_some_and(|x| x.close_time > server_epoch) && lr_vec[lr_vec.len()-1].lr_value > lr_vec[lr_vec.len()-2].lr_value + && lr_vec[lr_vec.len()-2].lr_value > lr_vec[lr_vec.len()-3].lr_value && lr_vec.last().unwrap().r_squared <= 0.01 { values.closetime = current_info.1; @@ -161,7 +162,7 @@ pub async fn list_up_for_buy( // } // remove_keys(&mut filtered_data, keys_to_remove).await; - // Wiliams -50 > %R(100) + // Wiliams -60 > %R(100) let mut keys_to_remove: HashSet = HashSet::new(); let mut wpr100_map = wiliams_percent_r(100, &alldata.rt_price_1m_vec, &filtered_data).await?; let server_epoch = get_server_epoch().await; @@ -170,7 +171,7 @@ pub async fn list_up_for_buy( if let Some(wpr100_vec) = wpr100_map.get(symbol) { if wpr100_vec.len() > 15 && wpr100_vec.last().unwrap().close_time > server_epoch - && wpr100_vec.last().unwrap().r_value < -50.0 { + && wpr100_vec.last().unwrap().r_value < -60.0 { do_buy = true; } } @@ -393,7 +394,9 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha // is_sell = true; // } else - if lr_vec.last().unwrap().r_squared >= 0.55 { + if element.pure_profit_percent.is_sign_positive() && lr_vec.last().unwrap().r_squared >= 0.7 { + is_sell = true; + } else if lr_vec[lr_vec.len()-1].lr_value < lr_vec[lr_vec.len()-2].lr_value { is_sell = true; } diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index e836081..7180e03 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -42,6 +42,7 @@ pub async fn list_up_for_buy( if lr_vec.len() > 10 && lr_vec.last().is_some_and(|x| x.close_time > server_epoch) && lr_vec[lr_vec.len()-1].lr_value < lr_vec[lr_vec.len()-2].lr_value + && lr_vec[lr_vec.len()-2].lr_value < lr_vec[lr_vec.len()-3].lr_value && lr_vec.last().unwrap().r_squared <= 0.01 { values.closetime = current_info.1; @@ -159,7 +160,7 @@ pub async fn list_up_for_buy( // } // remove_keys(&mut filtered_data, keys_to_remove).await; - // Wiliams -50.0 < %R(100) + // Wiliams -40.0 < %R(100) let mut keys_to_remove: HashSet = HashSet::new(); let mut wpr100_map = wiliams_percent_r(100, &alldata.rt_price_1m_vec, &filtered_data).await?; let server_epoch = get_server_epoch().await; @@ -168,7 +169,7 @@ pub async fn list_up_for_buy( if let Some(wpr100_vec) = wpr100_map.get(symbol) { if wpr100_vec.len() > 15 && wpr100_vec.last().unwrap().close_time > server_epoch - && wpr100_vec.last().unwrap().r_value > -50.0 { + && wpr100_vec.last().unwrap().r_value > -40.0 { do_buy = true; } } @@ -397,7 +398,9 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha // } else if element.pure_profit_percent <= element.stoploss_percent { // is_sell = true; // } else - if lr_vec.last().unwrap().r_squared >= 0.55 { + if element.pure_profit_percent.is_sign_positive() && lr_vec.last().unwrap().r_squared >= 0.7 { + is_sell = true; + } else if lr_vec[lr_vec.len()-1].lr_value > lr_vec[lr_vec.len()-2].lr_value { is_sell = true; }