Change function name
This commit is contained in:
parent
5ead6052e9
commit
799afebefc
|
|
@ -258,7 +258,7 @@ struct Record {
|
||||||
pub async fn execute_strategists(
|
pub async fn execute_strategists(
|
||||||
all_data: &AllData,
|
all_data: &AllData,
|
||||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
// strategist_001(all_data).await;
|
|
||||||
// strategist_002(all_data).await;
|
// strategist_002(all_data).await;
|
||||||
// strategist_003(all_data).await;
|
// strategist_003(all_data).await;
|
||||||
// strategist_004(all_data).await;
|
// strategist_004(all_data).await;
|
||||||
|
|
@ -276,7 +276,7 @@ pub async fn execute_strategists(
|
||||||
// strategist_015(all_data).await;
|
// strategist_015(all_data).await;
|
||||||
// strategist_016(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_test1(all_data).await;
|
||||||
// execute_strategist_for_test2(all_data).await;
|
// execute_strategist_for_test2(all_data).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -925,7 +925,7 @@ pub async fn execute_strategists(
|
||||||
// Ok(())
|
// Ok(())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub async fn execute_strategist_for_test_temp(
|
pub async fn strategist_001(
|
||||||
alldata: &AllData,
|
alldata: &AllData,
|
||||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
// print rt_price for debugging
|
// print rt_price for debugging
|
||||||
|
|
@ -1087,7 +1087,7 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
}
|
}
|
||||||
try_join_all(task_vec).await?;
|
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 filtered_4th_symbol_c = filtered_4th_symbols_arc.lock().await.clone();
|
||||||
let mut rsi10_30m_data: Vec<(String, Vec<RsiData>)> = Vec::new();
|
let mut rsi10_30m_data: Vec<(String, Vec<RsiData>)> = Vec::new();
|
||||||
value_estimation_team::indicators::rsi::rsi(
|
value_estimation_team::indicators::rsi::rsi(
|
||||||
|
|
@ -1114,7 +1114,7 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
}| close_time,
|
}| close_time,
|
||||||
);
|
);
|
||||||
if rsi_search_result.is_ok() {
|
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);
|
filtered_5th_symbols.push(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1172,9 +1172,24 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
task_vec.push(tokio::spawn(async move {
|
task_vec.push(tokio::spawn(async move {
|
||||||
let opclo_30m_option = rt_price_30m_vec_c.iter().position(|x| *x.0 == element.0);
|
let opclo_30m_option = rt_price_30m_vec_c.iter().position(|x| *x.0 == element.0);
|
||||||
if opclo_30m_option.is_some() {
|
if opclo_30m_option.is_some() {
|
||||||
if rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.last().is_some() {
|
if rt_price_30m_vec_c[opclo_30m_option.unwrap()]
|
||||||
let mut filtered_symbols_lock: tokio::sync::MutexGuard<'_, Vec<(String, i64, f64)>> = filtered_symbols_arc_c.lock().await;
|
.1
|
||||||
filtered_symbols_lock.push((elememt_c.0, elememt_c.1, rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.last().unwrap().close_price));
|
.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
|
// 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);
|
let index_result = rt_price_vec.iter().position(|x| *x.0 == *symbol);
|
||||||
match index_result {
|
match index_result {
|
||||||
Some(T) => {
|
Some(T) => {
|
||||||
|
|
@ -6582,7 +6600,7 @@ pub async fn get_current_price(symbol: &String, rt_price_vec: &Vec<(String, Vec<
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user