From be190a8c7aabe107e867612dda352d5bbbb0fc5f Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Wed, 16 Aug 2023 22:32:21 +0900 Subject: [PATCH] Add more RSI criteria --- src/coex/strategy_team.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/coex/strategy_team.rs b/src/coex/strategy_team.rs index a25afec..3943bf9 100644 --- a/src/coex/strategy_team.rs +++ b/src/coex/strategy_team.rs @@ -273,7 +273,7 @@ pub async fn strategist_001( } try_join_all(task_vec).await?; - // 4th filtering: RSI (length: 10, 30m close price) the current index should be lower than 28. + // 4th filtering: RSI (length: 10, 30m close price) the current index should be lower than 20, 25, 28. let filtered_4th_symbol_c = filtered_4th_symbols_arc.lock().await.clone(); let mut rsi10_30m_data: Vec<(String, Vec)> = rsi( 10, @@ -285,6 +285,17 @@ pub async fn strategist_001( let mut filtered_5th_symbols: Vec<(String, i64)> = Vec::new(); // (symbol, closetime) let mut filtered_5th_symbols_arc: Arc>> = Arc::new(Mutex::new(filtered_5th_symbols)); // (symbol, closetime) + let market_cap_angle = select_marketcap().await; + let rsi_criterion = if market_cap_angle.last().unwrap().market_cap_index < -30.0 { + 15.0 + } else if market_cap_angle.last().unwrap().market_cap_index > -30.0 && market_cap_angle.last().unwrap().market_cap_index < -20.0 { + 20.0 + } else if market_cap_angle.last().unwrap().market_cap_index > -20.0 && market_cap_angle.last().unwrap().market_cap_index < -10.0 { + 25.0 + } else { + 28.0 + }; + for element in filtered_4th_symbol_c { let rsi10_30m_option = rsi10_30m_data.iter().position(|x| *x.0 == element.0); let filtered_5th_symbols_arc_c = Arc::clone(&filtered_5th_symbols_arc); @@ -303,7 +314,7 @@ pub async fn strategist_001( }| close_time, ); if rsi_search_result.is_ok() { - if rsi10_30m_vec[rsi_search_result.unwrap()].rsi_value <= 28.0 { + if rsi10_30m_vec[rsi_search_result.unwrap()].rsi_value <= rsi_criterion { let mut filtered_5th_symbols_lock = filtered_5th_symbols_arc_c.lock().await; filtered_5th_symbols_lock.push(element_c); @@ -316,7 +327,7 @@ pub async fn strategist_001( } try_join_all(task_vec).await?; - // 5th filtering: StochRSI (RSI length: 14, Stoch length: 14, smooth k: 3, smooth d: 3) smooth k should be lower than 20. + // 5th filtering: StochRSI (RSI length: 14, Stoch length: 14, smooth k: 3, smooth d: 3) smooth kn <= 15, kn-1 <= 25 let filtered_5th_symbol_c = filtered_5th_symbols_arc.lock().await.clone(); let mut rsi14_30m_data: Vec<(String, Vec)> = rsi( 14, @@ -343,7 +354,7 @@ pub async fn strategist_001( }| close_time, ); if stoch_rsi_search_result.is_ok() { - if stoch_rsi14_30m_vec[stoch_rsi_search_result.unwrap()].k <= 20.0 { + if stoch_rsi14_30m_vec[stoch_rsi_search_result.unwrap()].k <= 15.0 && stoch_rsi14_30m_vec[stoch_rsi_search_result.unwrap()-1].k <= 25.0 { filtered_6th_symbols.push(element); } }