Change function name

This commit is contained in:
Sik Yoon 2023-08-12 21:58:50 +09:00
parent 5ead6052e9
commit 799afebefc

View File

@ -258,7 +258,7 @@ struct Record {
pub async fn execute_strategists(
all_data: &AllData,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// strategist_001(all_data).await;
// strategist_002(all_data).await;
// strategist_003(all_data).await;
// strategist_004(all_data).await;
@ -276,7 +276,7 @@ pub async fn execute_strategists(
// strategist_015(all_data).await;
// strategist_016(all_data).await;
execute_strategist_for_test_temp(all_data).await?;
strategist_001(all_data).await?;
// execute_strategist_for_test1(all_data).await;
// execute_strategist_for_test2(all_data).await;
Ok(())
@ -925,7 +925,7 @@ pub async fn execute_strategists(
// Ok(())
// }
pub async fn execute_strategist_for_test_temp(
pub async fn strategist_001(
alldata: &AllData,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// print rt_price for debugging
@ -1087,7 +1087,7 @@ pub async fn execute_strategist_for_test_temp(
}
try_join_all(task_vec).await?;
// 4th filtering: RSI (length: 10, 30m close price) the current index should be lower than 30.
// 4th filtering: RSI (length: 10, 30m close price) the current index should be lower than 28.
let filtered_4th_symbol_c = filtered_4th_symbols_arc.lock().await.clone();
let mut rsi10_30m_data: Vec<(String, Vec<RsiData>)> = Vec::new();
value_estimation_team::indicators::rsi::rsi(
@ -1114,7 +1114,7 @@ pub async fn execute_strategist_for_test_temp(
}| close_time,
);
if rsi_search_result.is_ok() {
if rsi10_30m_vec[rsi_search_result.unwrap()].rsi_value <= 30.0 {
if rsi10_30m_vec[rsi_search_result.unwrap()].rsi_value <= 28.0 {
filtered_5th_symbols.push(element);
}
}
@ -1172,9 +1172,24 @@ pub async fn execute_strategist_for_test_temp(
task_vec.push(tokio::spawn(async move {
let opclo_30m_option = rt_price_30m_vec_c.iter().position(|x| *x.0 == element.0);
if opclo_30m_option.is_some() {
if rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.last().is_some() {
let mut filtered_symbols_lock: tokio::sync::MutexGuard<'_, Vec<(String, i64, f64)>> = filtered_symbols_arc_c.lock().await;
filtered_symbols_lock.push((elememt_c.0, elememt_c.1, rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.last().unwrap().close_price));
if rt_price_30m_vec_c[opclo_30m_option.unwrap()]
.1
.last()
.is_some()
{
let mut filtered_symbols_lock: tokio::sync::MutexGuard<
'_,
Vec<(String, i64, f64)>,
> = filtered_symbols_arc_c.lock().await;
filtered_symbols_lock.push((
elememt_c.0,
elememt_c.1,
rt_price_30m_vec_c[opclo_30m_option.unwrap()]
.1
.last()
.unwrap()
.close_price,
));
}
}
}));
@ -6573,7 +6588,10 @@ pub async fn execute_strategist_for_test_temp(
// }
// useful functions for strategists
pub async fn get_current_price(symbol: &String, rt_price_vec: &Vec<(String, Vec<RealtimePriceData>)>) -> Option<f64> {
pub async fn get_current_price(
symbol: &String,
rt_price_vec: &Vec<(String, Vec<RealtimePriceData>)>,
) -> Option<f64> {
let index_result = rt_price_vec.iter().position(|x| *x.0 == *symbol);
match index_result {
Some(T) => {
@ -6582,7 +6600,7 @@ pub async fn get_current_price(symbol: &String, rt_price_vec: &Vec<(String, Vec<
} else {
None
}
},
}
None => None,
}
}