diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index 8f071db..b1ddbac 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -68,6 +68,7 @@ pub async fn list_up_for_buy( let mut keys_to_remove: HashSet = HashSet::new(); let adx_vec = adx(15, 15, &alldata.rt_price_1m_vec, &filtered_data).await?; for (symbol, values) in &mut filtered_data { + let mut do_buy = false; if let Some(adx_vec) = adx_vec.get(symbol) { if let Some(last_idx) = adx_vec.iter().position(|elem| elem.close_time == values.closetime) { if adx_vec.len() > 10 @@ -79,13 +80,11 @@ pub async fn list_up_for_buy( && adx_vec[last_idx-1].adx > adx_vec[last_idx-2].adx && adx_vec[last_idx-1].adx > adx_vec[last_idx-3].adx && adx_vec[last_idx-2].adx > adx_vec[last_idx-3].adx { - } else { - keys_to_remove.insert(symbol.clone()); - } - } else { - keys_to_remove.insert(symbol.clone()); - } - } else { + do_buy = true; + } + } + } + if do_buy == false { keys_to_remove.insert(symbol.clone()); } } @@ -144,6 +143,26 @@ pub async fn list_up_for_buy( } remove_keys(&mut filtered_data, keys_to_remove).await; + // Wiliams -20 > %R(100) > -80.0 + 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; + for (symbol, values) in &mut filtered_data { + let mut do_buy = false; + 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 > -80.0 + && wpr100_vec.last().unwrap().r_value < -20.0 { + do_buy = true; + } + } + if do_buy == false { + keys_to_remove.insert(symbol.clone()); + } + } + remove_keys(&mut filtered_data, keys_to_remove).await; + // current Tema(15) > current Tema(30) // let mut keys_to_remove: HashSet = HashSet::new(); // let tema_10 = tema(10, &alldata.rt_price_30m_vec, &filtered_data).await?; diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index 2d44903..f660dac 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -68,6 +68,7 @@ pub async fn list_up_for_buy( let mut keys_to_remove: HashSet = HashSet::new(); let adx_vec = adx(15, 15, &alldata.rt_price_1m_vec, &filtered_data).await?; for (symbol, values) in &mut filtered_data { + let mut do_buy = false; if let Some(adx_vec) = adx_vec.get(symbol) { if let Some(last_idx) = adx_vec.iter().position(|elem| elem.close_time == values.closetime) { if adx_vec.len() > 10 @@ -79,13 +80,11 @@ pub async fn list_up_for_buy( && adx_vec[last_idx-1].adx > adx_vec[last_idx-2].adx && adx_vec[last_idx-1].adx > adx_vec[last_idx-3].adx && adx_vec[last_idx-2].adx > adx_vec[last_idx-3].adx { - } else { - keys_to_remove.insert(symbol.clone()); - } - } else { - keys_to_remove.insert(symbol.clone()); - } - } else { + do_buy = true; + } + } + } + if do_buy == false { keys_to_remove.insert(symbol.clone()); } }