From 583787432eaa030b27586f95b424e1e60849a4ab Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Sat, 25 May 2024 03:24:43 +0900 Subject: [PATCH] Update filtering --- src/strategy_team/future_strategy_long.rs | 48 +++++++++++----------- src/strategy_team/future_strategy_short.rs | 48 +++++++++++----------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index 5182e00..45d4dae 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -30,30 +30,30 @@ pub async fn list_up_for_buy( filtered_data.insert(symbol.clone(), FilteredDataValue::new()); } - // current Tema(15) < current Tema(60) - // let mut keys_to_remove: HashSet = HashSet::new(); - // let tema_15 = tema(15, &alldata.rt_price_1m_vec, &filtered_data).await?; - // let tema_60 = tema(60, &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(tema15_vec), Some(tema60_vec)) = (tema_15.get(symbol), tema_60.get(symbol)) { - // if tema15_vec.len() > 10 - // && tema60_vec.len() > 10 - // && tema15_vec.last().unwrap().close_time == tema60_vec.last().unwrap().close_time - // && tema15_vec.last().unwrap().close_time > server_epoch - // && tema60_vec.last().unwrap().close_time > server_epoch - // { - // if tema15_vec.last().unwrap().tema_value > tema60_vec.last().unwrap().tema_value { - // 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_15 = tema(15, &alldata.rt_price_1m_vec, &filtered_data).await?; + let tema_30 = tema(30, &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(tema15_vec), Some(tema30_vec)) = (tema_15.get(symbol), tema_30.get(symbol)) { + if tema15_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 + && tema30_vec.last().unwrap().close_time > server_epoch + { + if tema15_vec.last().unwrap().tema_value > tema30_vec.last().unwrap().tema_value { + do_buy = true; + } + } + } + if do_buy == false { + keys_to_remove.insert(symbol.clone()); + } + } + remove_keys(&mut filtered_data, keys_to_remove).await; // Heatmap volume: filtering close price with Extra High is over the previous candle from 30 previous candles // let mut keys_to_remove: HashSet = HashSet::new(); diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index 189a966..6ddb107 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -30,30 +30,30 @@ pub async fn list_up_for_buy( filtered_data.insert(symbol.clone(), FilteredDataValue::new()); } - // current Tema(15) < current Tema(60) - // let mut keys_to_remove: HashSet = HashSet::new(); - // let tema_15 = tema(15, &alldata.rt_price_1m_vec, &filtered_data).await?; - // let tema_60 = tema(60, &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(tema15_vec), Some(tema60_vec)) = (tema_15.get(symbol), tema_60.get(symbol)) { - // if tema15_vec.len() > 10 - // && tema60_vec.len() > 10 - // && tema15_vec.last().unwrap().close_time == tema60_vec.last().unwrap().close_time - // && tema15_vec.last().unwrap().close_time > server_epoch - // && tema60_vec.last().unwrap().close_time > server_epoch - // { - // if tema15_vec.last().unwrap().tema_value < tema60_vec.last().unwrap().tema_value { - // 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_15 = tema(15, &alldata.rt_price_1m_vec, &filtered_data).await?; + let tema_30 = tema(30, &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(tema15_vec), Some(tema30_vec)) = (tema_15.get(symbol), tema_30.get(symbol)) { + if tema15_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 + && tema30_vec.last().unwrap().close_time > server_epoch + { + if tema15_vec.last().unwrap().tema_value < tema30_vec.last().unwrap().tema_value { + do_buy = true; + } + } + } + if do_buy == false { + keys_to_remove.insert(symbol.clone()); + } + } + remove_keys(&mut filtered_data, keys_to_remove).await; // Heatmap volume: filtering close price with Extra High is over the previous candle from 30 previous candles // let mut keys_to_remove: HashSet = HashSet::new();