From 87cde15b3751a0ec705f4d0dd630db67c04370b0 Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Fri, 24 May 2024 17:01:31 +0900 Subject: [PATCH] Renaming --- src/future/order.rs | 1 - ...e_strategy.rs => future_strategy_short.rs} | 37 ++++++++++--------- src/strategy_team/mod.rs | 2 +- src/strategy_team/strategy_manager.rs | 4 +- 4 files changed, 22 insertions(+), 22 deletions(-) rename src/strategy_team/{future_strategy.rs => future_strategy_short.rs} (85%) diff --git a/src/future/order.rs b/src/future/order.rs index db960fb..536642d 100644 --- a/src/future/order.rs +++ b/src/future/order.rs @@ -21,7 +21,6 @@ use sqlx::FromRow; use std::collections::HashMap; use tokio::time::*; use super::{hmac_signature, REAL, SIMUL, TEST, RUNNING_MODE, FUTURES_URL, FUTURES_URL_TEST, API_KEY, API_KEY_TESTNET, FuturesExchangeInfo, PositionCoinList, FuturesTradeFee, EntryCoinInfo, select_listuped_positions}; -use crate::strategy_team::future_strategy; pub enum TimeInForce { Gtc, diff --git a/src/strategy_team/future_strategy.rs b/src/strategy_team/future_strategy_short.rs similarity index 85% rename from src/strategy_team/future_strategy.rs rename to src/strategy_team/future_strategy_short.rs index 522f6f3..7eedcaf 100644 --- a/src/strategy_team/future_strategy.rs +++ b/src/strategy_team/future_strategy_short.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(); diff --git a/src/strategy_team/mod.rs b/src/strategy_team/mod.rs index 62b66b5..30ad2f0 100644 --- a/src/strategy_team/mod.rs +++ b/src/strategy_team/mod.rs @@ -8,7 +8,7 @@ pub mod strategy_007; pub mod strategy_008; pub mod strategy_009; pub mod strategy_010; -pub mod future_strategy; +pub mod future_strategy_short; pub mod future_strategy_long; // pub mod strategy_test; pub mod strategy_manager; diff --git a/src/strategy_team/strategy_manager.rs b/src/strategy_team/strategy_manager.rs index 8c9340d..2ecc6a6 100644 --- a/src/strategy_team/strategy_manager.rs +++ b/src/strategy_team/strategy_manager.rs @@ -44,7 +44,7 @@ pub async fn execute_list_up_for_buy( // crate::strategy_team::strategy_008::list_up_for_buy(all_data).await; // crate::strategy_team::strategy_009::list_up_for_buy(all_data).await; crate::strategy_team::future_strategy_long::list_up_for_buy(all_data, &future_exchange_info_map).await; - crate::strategy_team::future_strategy::list_up_for_buy(all_data, &future_exchange_info_map).await; + crate::strategy_team::future_strategy_short::list_up_for_buy(all_data, &future_exchange_info_map).await; Ok(()) } @@ -85,7 +85,7 @@ pub async fn execute_list_up_for_sell( // ) // .await; crate::strategy_team::future_strategy_long::list_up_for_sell().await; - crate::strategy_team::future_strategy::list_up_for_sell().await; + crate::strategy_team::future_strategy_short::list_up_for_sell().await; Ok(()) }