Change function name
This commit is contained in:
parent
5ead6052e9
commit
799afebefc
|
|
@ -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,13 +925,13 @@ 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
|
||||
// let a = alldata.rt_price_30m_vec.iter().position(|a| a.0 == "BTCUSDT");
|
||||
// println!("BTCUSDT: {:?}", alldata.rt_price_30m_vec[a.unwrap()].1.last().unwrap());
|
||||
|
||||
|
||||
// 1st filtering: supertrend(ATR period 10, multiplier: 1.3, 30m close price), the area should be in SELL area.
|
||||
let mut filtered_2nd_symbols: Vec<(String, i64)> = Vec::new();
|
||||
let mut filtered_2nd_symbols_arc: Arc<Mutex<Vec<(String, i64)>>> =
|
||||
|
|
@ -978,7 +978,7 @@ pub async fn execute_strategist_for_test_temp(
|
|||
}));
|
||||
}
|
||||
try_join_all(task_vec).await?;
|
||||
|
||||
|
||||
// 2nd filtering: lookup tables if the tradepair is already there
|
||||
let inspect_table_name_1 = String::from("buy_ordered_coin_list");
|
||||
let inspect_table_name_2 = String::from("sell_ordered_coin_list");
|
||||
|
|
@ -1025,7 +1025,7 @@ pub async fn execute_strategist_for_test_temp(
|
|||
}));
|
||||
}
|
||||
try_join_all(task_vec).await?;
|
||||
|
||||
|
||||
// 3rd filtering: BollingerBand (length 10, stddev: 2.5, 30m close price) the current price should be under the lowerband of BB.
|
||||
let filtered_3rd_symbols_c = filtered_3rd_symbols_arc.lock().await.clone();
|
||||
let sma10_30m_data: Vec<(String, Vec<SmaData>)> = value_estimation_team::indicators::sma::sma(
|
||||
|
|
@ -1044,7 +1044,7 @@ pub async fn execute_strategist_for_test_temp(
|
|||
&filtered_3rd_symbols_c,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
let mut task_vec = Vec::new();
|
||||
let mut filtered_4th_symbols: Vec<(String, i64)> = Vec::new();
|
||||
let mut filtered_4th_symbols_arc: Arc<Mutex<Vec<(String, i64)>>> =
|
||||
|
|
@ -1074,7 +1074,7 @@ pub async fn execute_strategist_for_test_temp(
|
|||
close_time,
|
||||
}| close_time,
|
||||
);
|
||||
if bb_search_result.is_ok() {
|
||||
if bb_search_result.is_ok() {
|
||||
if bb10_30m_vec_c[bb_search_result.unwrap()].lowerband > current_price {
|
||||
let mut filtered_4th_symbols_lock =
|
||||
filtered_4th_symbols_arc_c.lock().await;
|
||||
|
|
@ -1086,8 +1086,8 @@ 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(
|
||||
|
|
@ -1104,7 +1104,7 @@ pub async fn execute_strategist_for_test_temp(
|
|||
|
||||
if rsi10_30m_option.is_some() {
|
||||
rsi10_30m_vec = rsi10_30m_data[rsi10_30m_option.unwrap()].1.clone();
|
||||
|
||||
|
||||
if rsi10_30m_vec.len() >= 3 {
|
||||
let rsi_search_result = rsi10_30m_vec.binary_search_by_key(
|
||||
&element.1,
|
||||
|
|
@ -1114,14 +1114,14 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 5th filtering: heatmap volume(MA length 10, std length 10, 30m close price), the current candle should be over than high at least.
|
||||
let mut filtered_6th_symbols: Vec<(String, i64)> = Vec::new(); // (symbol, closetime)
|
||||
for element in filtered_5th_symbols {
|
||||
|
|
@ -1167,14 +1167,29 @@ pub async fn execute_strategist_for_test_temp(
|
|||
for element in filtered_6th_symbols {
|
||||
let mut filtered_symbols_arc_c = Arc::clone(&filtered_symbols_arc);
|
||||
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
||||
|
||||
|
||||
let elememt_c = element.clone();
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user