diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index b17bad6..bf5e42a 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -36,14 +36,19 @@ pub async fn list_up_for_buy( // current lr > prev lr, current r_squared <= 0.01 let mut keys_to_remove: HashSet = HashSet::new(); let lr_map = linear_regression(10, 0, &alldata.rt_price_30m_vec, &filtered_data).await?; + let sma_map = sma(10, &alldata.rt_price_30m_vec, &filtered_data).await?; for (symbol, values) in &mut filtered_data { let mut do_buy = false; - if let (Some(lr_vec), Some(current_info)) = (lr_map.get(symbol), get_current_price_decimal(&symbol, &alldata.rt_price_30m_vec).await) { + if let (Some(lr_vec), Some(sma_vec), Some(current_info)) = (lr_map.get(symbol), sma_map.get(symbol), get_current_price_decimal(&symbol, &alldata.rt_price_30m_vec).await) { if lr_vec.len() > 10 + && sma_vec.len() > 10 && lr_vec.last().is_some_and(|x| x.close_time > server_epoch) + && sma_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 + && lr_vec[lr_vec.len()-1].lr_value >= sma_vec[sma_vec.len()-1].sma_value + && lr_vec[lr_vec.len()-2].lr_value <= sma_vec[sma_vec.len()-1].sma_value { values.closetime = current_info.1; do_buy = true; @@ -401,7 +406,7 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha } let minimum_candles = 5; - let maximum_candles = 6; + let maximum_candles = 20; // for count_candles in minimum_candles..=maximum_candles { // if count_candles < maximum_candles // && server_epoch - element.transact_time diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index 7180e03..38f01a2 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -36,14 +36,20 @@ pub async fn list_up_for_buy( // current lr < prev lr, current r_squared <= 0.01 let mut keys_to_remove: HashSet = HashSet::new(); let lr_map = linear_regression(10, 0, &alldata.rt_price_30m_vec, &filtered_data).await?; + let sma10_map = sma(10, &alldata.rt_price_30m_vec, &filtered_data).await?; for (symbol, values) in &mut filtered_data { let mut do_buy = false; - if let (Some(lr_vec), Some(current_info)) = (lr_map.get(symbol), get_current_price_decimal(&symbol, &alldata.rt_price_30m_vec).await) { + if let (Some(lr_vec), Some(sma_vec), Some(current_info)) = (lr_map.get(symbol), sma10_map.get(symbol), get_current_price_decimal(&symbol, &alldata.rt_price_30m_vec).await) { if lr_vec.len() > 10 + && sma_vec.len() > 10 && lr_vec.last().is_some_and(|x| x.close_time > server_epoch) + && sma_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 + && lr_vec[lr_vec.len()-1].lr_value <= sma_vec[sma_vec.len()-1].sma_value + && lr_vec[lr_vec.len()-2].lr_value >= sma_vec[sma_vec.len()-1].sma_value + { values.closetime = current_info.1; do_buy = true; @@ -405,7 +411,7 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha } let minimum_candles = 5; - let maximum_candles = 6; + let maximum_candles = 20; // for count_candles in minimum_candles..=maximum_candles { // if count_candles < maximum_candles // && server_epoch - element.transact_time