From 1bd4b30418f5e4c1cb93a603b5f5e9d67a833b21 Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Sun, 7 Apr 2024 01:23:56 +0900 Subject: [PATCH] Update filtering --- src/strategy_team/strategy_008.rs | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/strategy_team/strategy_008.rs b/src/strategy_team/strategy_008.rs index b1bc12b..cbb49af 100644 --- a/src/strategy_team/strategy_008.rs +++ b/src/strategy_team/strategy_008.rs @@ -44,20 +44,20 @@ pub async fn list_up_for_buy( } remove_keys(&mut filtered_data, keys_to_remove).await; - // current Dema(30) < current Tema(10) - // previous Dema(30) > previous Tema(10) + // current Tema(10) < current Tema(5) + // previous Tema(10) > previous Tema(5) let mut keys_to_remove: HashSet = HashSet::new(); - let dema_30 = dema(30, &alldata.rt_price_30m_vec, &filtered_data).await?; let tema_10 = tema(10, &alldata.rt_price_30m_vec, &filtered_data).await?; + let tema_5 = tema(5, &alldata.rt_price_30m_vec, &filtered_data).await?; let server_epoch = get_server_epoch().await; for (symbol, values) in &mut filtered_data { - if let (Some(dema_vec), Some(tema_vec)) = (dema_30.get(symbol), tema_10.get(symbol)) { - if dema_vec.len() > 2 && tema_vec.len() > 2 && - dema_vec.last().unwrap().close_time == tema_vec.last().unwrap().close_time && - dema_vec.last().unwrap().close_time > server_epoch && - tema_vec.last().unwrap().close_time > server_epoch { - if dema_vec.last().unwrap().dema_value < tema_vec.last().unwrap().tema_value && - dema_vec[dema_vec.len()-2].dema_value > tema_vec[tema_vec.len()-2].tema_value { + if let (Some(tema10_vec), Some(tema5_vec)) = (tema_10.get(symbol), tema_5.get(symbol)) { + if tema10_vec.len() > 2 && tema5_vec.len() > 2 && + tema10_vec.last().unwrap().close_time == tema5_vec.last().unwrap().close_time && + tema10_vec.last().unwrap().close_time > server_epoch && + tema5_vec.last().unwrap().close_time > server_epoch { + if tema10_vec.last().unwrap().tema_value < tema5_vec.last().unwrap().tema_value && + tema10_vec[tema10_vec.len()-2].tema_value > tema5_vec[tema5_vec.len()-2].tema_value { } else { keys_to_remove.insert(symbol.clone()); } @@ -212,19 +212,19 @@ pub async fn list_up_for_sell( filtered_symbols.insert(element.symbol.clone(), FilteredDataValue::new()); } let supertrend_30m = supertrend(10, 2.0, true, &all_data.rt_price_30m_vec, &filtered_symbols).await?; - let dema_30 = dema(30, &all_data.rt_price_30m_vec, &filtered_symbols).await?; let tema_10 = tema(10, &all_data.rt_price_30m_vec, &filtered_symbols).await?; + let tema_5 = tema(50, &all_data.rt_price_30m_vec, &filtered_symbols).await?; for element in filled_buy_orders { let mut is_sell = false; let mut is_overturned = false; if element.used_usdt >= dec!(10.0) { - if let (Some(dema_vec), Some(tema_vec)) = (dema_30.get(&element.symbol), tema_10.get(&element.symbol)) { - if dema_vec.len() > 2 && tema_vec.len() > 2 && - dema_vec.last().unwrap().close_time == tema_vec.last().unwrap().close_time && - dema_vec.last().unwrap().close_time > server_epoch && - tema_vec.last().unwrap().close_time > server_epoch && - dema_vec.last().unwrap().dema_value > tema_vec.last().unwrap().tema_value && - dema_vec[dema_vec.len()-2].dema_value < tema_vec[tema_vec.len()-2].tema_value { + if let (Some(tema10_vec), Some(tema5_vec)) = (tema_10.get(&element.symbol), tema_5.get(&element.symbol)) { + if tema10_vec.len() > 2 && tema5_vec.len() > 2 && + tema10_vec.last().unwrap().close_time == tema5_vec.last().unwrap().close_time && + tema10_vec.last().unwrap().close_time > server_epoch && + tema5_vec.last().unwrap().close_time > server_epoch && + tema10_vec.last().unwrap().tema_value > tema5_vec.last().unwrap().tema_value && + tema10_vec[tema10_vec.len()-2].tema_value < tema5_vec[tema5_vec.len()-2].tema_value { is_overturned = true; } }