diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index f9e4c22..81935df 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -32,22 +32,22 @@ pub async fn list_up_for_buy( // current Tema(15) > current Tema(30) let mut keys_to_remove: HashSet = HashSet::new(); - let tema_15 = tema(15, &alldata.rt_price_30m_vec, &filtered_data).await?; + let tema_10 = tema(10, &alldata.rt_price_30m_vec, &filtered_data).await?; let tema_30 = tema(30, &alldata.rt_price_30m_vec, &filtered_data).await?; let server_epoch = get_server_epoch().await; for (symbol, values) in &mut filtered_data { let mut do_buy = false; let price_and_closetime = get_current_price_decimal(&symbol, &alldata.rt_price_1m_vec).await; - if let (Some(tema15_vec), Some(tema30_vec), Some(current_info)) = (tema_15.get(symbol), tema_30.get(symbol), price_and_closetime) { - if tema15_vec.len() > 10 + if let (Some(tema10_vec), Some(tema30_vec), Some(current_info)) = (tema_10.get(symbol), tema_30.get(symbol), price_and_closetime) { + if tema10_vec.len() > 10 && tema30_vec.len() > 10 - && tema15_vec.last().unwrap().close_time == tema30_vec.last().unwrap().close_time - && tema15_vec.last().unwrap().close_time > server_epoch + && tema10_vec.last().unwrap().close_time == tema30_vec.last().unwrap().close_time + && tema10_vec.last().unwrap().close_time > server_epoch && tema30_vec.last().unwrap().close_time > server_epoch { - if tema15_vec[tema15_vec.len()-1].tema_value > tema30_vec[tema30_vec.len()-1].tema_value - && tema15_vec[tema15_vec.len()-2].tema_value > tema30_vec[tema30_vec.len()-2].tema_value - && tema15_vec[tema15_vec.len()-1].tema_value > tema15_vec[tema15_vec.len()-2].tema_value + if tema10_vec[tema10_vec.len()-1].tema_value > tema30_vec[tema30_vec.len()-1].tema_value + && tema10_vec[tema10_vec.len()-2].tema_value > tema30_vec[tema30_vec.len()-2].tema_value + && tema10_vec[tema10_vec.len()-1].tema_value > tema10_vec[tema10_vec.len()-2].tema_value { do_buy = true; } diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index dbc4d48..9aa357f 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -32,22 +32,22 @@ pub async fn list_up_for_buy( // current Tema(15) < current Tema(30) let mut keys_to_remove: HashSet = HashSet::new(); - let tema_15 = tema(15, &alldata.rt_price_30m_vec, &filtered_data).await?; + let tema_10 = tema(10, &alldata.rt_price_30m_vec, &filtered_data).await?; let tema_30 = tema(30, &alldata.rt_price_30m_vec, &filtered_data).await?; let server_epoch = get_server_epoch().await; for (symbol, values) in &mut filtered_data { let mut do_buy = false; let price_and_closetime = get_current_price_decimal(&symbol, &alldata.rt_price_1m_vec).await; - if let (Some(tema15_vec), Some(tema30_vec), Some(current_info)) = (tema_15.get(symbol), tema_30.get(symbol), price_and_closetime) { - if tema15_vec.len() > 10 + if let (Some(tema10_vec), Some(tema30_vec), Some(current_info)) = (tema_10.get(symbol), tema_30.get(symbol), price_and_closetime) { + if tema10_vec.len() > 10 && tema30_vec.len() > 10 - && tema15_vec.last().unwrap().close_time == tema30_vec.last().unwrap().close_time - && tema15_vec.last().unwrap().close_time > server_epoch + && tema10_vec.last().unwrap().close_time == tema30_vec.last().unwrap().close_time + && tema10_vec.last().unwrap().close_time > server_epoch && tema30_vec.last().unwrap().close_time > server_epoch { - if tema15_vec[tema15_vec.len()-1].tema_value < tema30_vec[tema30_vec.len()-1].tema_value - && tema15_vec[tema15_vec.len()-2].tema_value < tema30_vec[tema30_vec.len()-2].tema_value - && tema15_vec[tema15_vec.len()-1].tema_value < tema15_vec[tema15_vec.len()-2].tema_value + if tema10_vec[tema10_vec.len()-1].tema_value < tema30_vec[tema30_vec.len()-1].tema_value + && tema10_vec[tema10_vec.len()-2].tema_value < tema30_vec[tema30_vec.len()-2].tema_value + && tema10_vec[tema10_vec.len()-1].tema_value < tema10_vec[tema10_vec.len()-2].tema_value { do_buy = true; }