From 40193b171aa6dee2fd6a07086317f11247354f05 Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Fri, 24 May 2024 17:02:08 +0900 Subject: [PATCH] Change to reterive all symbols --- src/strategy_team/future_strategy_long.rs | 37 ++++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index f680eb0..2c04ba4 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -29,30 +29,31 @@ pub async fn list_up_for_buy( for symbol in &alldata.valid_symbol_vec { filtered_data.insert(symbol.clone(), FilteredDataValue::new()); } - let server_epoch = get_server_epoch().await; - // current Tema(30) < current Tema(60) + + // 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; - - let mut do_buy = false; - if let (Some(tema15_vec), Some(tema60_vec)) = (tema_15.get("BTCUSDT"), tema_60.get("BTCUSDT")) { - 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; + 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 { - return Ok(()); + } + 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();