From 832ebd76fb83eabab763be3c3b71ae031db0e482 Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Mon, 18 Dec 2023 01:53:21 +0900 Subject: [PATCH] Fix wrong calculation --- src/strategy_team/strategy_manager.rs | 2 +- src/strategy_team/strategy_test.rs | 12 ++++++------ src/value_estimation_team/indicators/adx.rs | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/strategy_team/strategy_manager.rs b/src/strategy_team/strategy_manager.rs index 1223dfb..28c37b6 100644 --- a/src/strategy_team/strategy_manager.rs +++ b/src/strategy_team/strategy_manager.rs @@ -46,7 +46,7 @@ pub async fn execute_list_up_for_buy( // strategist_004(all_data).await?; // strategist_005(all_data).await?; // strategist_006(all_data).await?; - crate::strategy_team::strategy_test::strategist_test(all_data_c4); + crate::strategy_team::strategy_test::strategist_test(all_data_c4).await; // try_join_all(task_vec).await?; Ok(()) diff --git a/src/strategy_team/strategy_test.rs b/src/strategy_team/strategy_test.rs index 7461fcd..810b0c2 100644 --- a/src/strategy_team/strategy_test.rs +++ b/src/strategy_team/strategy_test.rs @@ -15,15 +15,15 @@ pub async fn strategist_test( // 1st filtering: lookup tables if the tradepair is already there let mut symbol_1 = FilteredData::new(); - let mut symbol_2 = FilteredData::new(); - let mut symbol_3 = FilteredData::new(); + // let mut symbol_2 = FilteredData::new(); + // let mut symbol_3 = FilteredData::new(); symbol_1.symbol = String::from("BTCUSDT"); - symbol_2.symbol = String::from("XRPUSDT"); - symbol_3.symbol = String::from("ETHUSDT"); + // symbol_2.symbol = String::from("XRPUSDT"); + // symbol_3.symbol = String::from("ETHUSDT"); let mut test_symbols: Vec = Vec::new(); test_symbols.push(symbol_1); - test_symbols.push(symbol_2); - test_symbols.push(symbol_3); + // test_symbols.push(symbol_2); + // test_symbols.push(symbol_3); let a = adx(10, 10, &alldata.rt_price_30m_vec, &test_symbols).await?; println!("{:?}", a); diff --git a/src/value_estimation_team/indicators/adx.rs b/src/value_estimation_team/indicators/adx.rs index 554306e..3473758 100644 --- a/src/value_estimation_team/indicators/adx.rs +++ b/src/value_estimation_team/indicators/adx.rs @@ -94,9 +94,10 @@ filtered_symbols: &Vec,) -> Result)>, Bo // step 4: calculate ADX let mut initial_adx_vec: Vec = Vec::new(); for di_data in di_data_vec { - let sum = di_data.di_plus - di_data.di_minus; + let sum = di_data.di_plus + di_data.di_minus; + let difference = (di_data.di_plus - di_data.di_minus).abs(); let divisor = if sum <= 0.00000001 { 1.0 } else { sum }; - let adx_data = AdxData { adx: sum.abs()/divisor, close_time: di_data.close_time }; + let adx_data = AdxData { adx: difference.abs()/divisor, close_time: di_data.close_time }; initial_adx_vec.push(adx_data); } let partial_vec1 = initial_adx_vec.get(..adx_len).unwrap(); // for calculation of initial value