Apply formatter
This commit is contained in:
parent
95c7dd4b23
commit
a147535dc7
|
|
@ -14,15 +14,15 @@ use crate::value_estimation_team::indicators::rsi::RsiData;
|
|||
use crate::value_estimation_team::indicators::sma::SmaData;
|
||||
use crate::value_estimation_team::indicators::stoch_rsi::{StochRsiDData, StochRsiKData};
|
||||
use crate::value_estimation_team::indicators::supertrend::{supertrend, SupertrendData};
|
||||
use futures::future::try_join_all;
|
||||
use csv::{DeserializeRecordsIter, StringRecord};
|
||||
use futures::future::try_join_all;
|
||||
use rust_decimal::prelude::ToPrimitive;
|
||||
use rust_decimal::Decimal;
|
||||
use serde::Deserialize;
|
||||
use sqlx::FromRow;
|
||||
use std::{cmp::Ordering, sync::Arc};
|
||||
use tokio::time::{sleep, Duration, Instant};
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::time::{sleep, Duration, Instant};
|
||||
|
||||
use crate::signal_association::signal_decision::*;
|
||||
|
||||
|
|
@ -930,11 +930,10 @@ pub async fn execute_strategists(
|
|||
pub async fn execute_strategist_for_test_temp(
|
||||
alldata: &AllData,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
|
||||
|
||||
// 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)>>> = Arc::new(Mutex::new(filtered_2nd_symbols)); // (symbol, closetime)
|
||||
let mut filtered_2nd_symbols_arc: Arc<Mutex<Vec<(String, i64)>>> =
|
||||
Arc::new(Mutex::new(filtered_2nd_symbols)); // (symbol, closetime)
|
||||
let mut task_vec = Vec::new();
|
||||
let valid_symbol_vec_c = alldata.valid_symbol_vec.clone();
|
||||
for symbol in valid_symbol_vec_c {
|
||||
|
|
@ -943,15 +942,12 @@ pub async fn execute_strategist_for_test_temp(
|
|||
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
||||
let filtered_2nd_symbols_arc_c = Arc::clone(&filtered_2nd_symbols_arc);
|
||||
task_vec.push(tokio::spawn(async move {
|
||||
let opclo_30m_option = rt_price_30m_vec_c.iter()
|
||||
.position(|x| *x.0 == symbol);
|
||||
let opclo_30m_option = rt_price_30m_vec_c.iter().position(|x| *x.0 == symbol);
|
||||
let supertrend_option_30m =
|
||||
supertrend(&symbol, &rt_price_30m_vec_c, 10, 1.3, true).await;
|
||||
|
||||
if opclo_30m_option.is_some() && supertrend_option_30m.is_some() {
|
||||
opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()]
|
||||
.1
|
||||
.clone();
|
||||
opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.clone();
|
||||
supertrend_vec = supertrend_option_30m.unwrap();
|
||||
|
||||
if opclo_30m_vec.len() >= 3 && supertrend_vec.len() >= 3 {
|
||||
|
|
@ -969,7 +965,8 @@ pub async fn execute_strategist_for_test_temp(
|
|||
.area
|
||||
.contains("DOWN")
|
||||
{
|
||||
let mut filtered_2nd_symbols_lock = filtered_2nd_symbols_arc_c.lock().await;
|
||||
let mut filtered_2nd_symbols_lock =
|
||||
filtered_2nd_symbols_arc_c.lock().await;
|
||||
filtered_2nd_symbols_lock
|
||||
.push((symbol.clone(), opclo_30m_vec.last().unwrap().close_time));
|
||||
}
|
||||
|
|
@ -987,7 +984,8 @@ pub async fn execute_strategist_for_test_temp(
|
|||
let inspect_table_name_4 = String::from("suggested_coin_list");
|
||||
|
||||
let mut filtered_3rd_symbols: Vec<(String, i64)> = Vec::new();
|
||||
let mut filtered_3rd_symbols_arc: Arc<Mutex<Vec<(String, i64)>>> = Arc::new(Mutex::new(filtered_3rd_symbols)); // (symbol, closetime)
|
||||
let mut filtered_3rd_symbols_arc: Arc<Mutex<Vec<(String, i64)>>> =
|
||||
Arc::new(Mutex::new(filtered_3rd_symbols)); // (symbol, closetime)
|
||||
let mut task_vec = Vec::new();
|
||||
|
||||
let filtered_2nd_iter = filtered_2nd_symbols_arc.lock().await.clone().into_iter();
|
||||
|
|
@ -1005,10 +1003,14 @@ pub async fn execute_strategist_for_test_temp(
|
|||
let element_c = element.clone();
|
||||
let filtered_3rd_symbols_arc_c = Arc::clone(&filtered_3rd_symbols_arc);
|
||||
task_vec.push(tokio::spawn(async move {
|
||||
let inspect_result_1 = exists_record(&inspect_table_name_1_c, &exists_condition_c).await;
|
||||
let inspect_result_2 = exists_record(&inspect_table_name_2_c, &exists_condition_c).await;
|
||||
let inspect_result_3 = exists_record(&inspect_table_name_3_c, &exists_condition_c).await;
|
||||
let inspect_result_4 = exists_record(&inspect_table_name_4_c, &exists_condition_c).await;
|
||||
let inspect_result_1 =
|
||||
exists_record(&inspect_table_name_1_c, &exists_condition_c).await;
|
||||
let inspect_result_2 =
|
||||
exists_record(&inspect_table_name_2_c, &exists_condition_c).await;
|
||||
let inspect_result_3 =
|
||||
exists_record(&inspect_table_name_3_c, &exists_condition_c).await;
|
||||
let inspect_result_4 =
|
||||
exists_record(&inspect_table_name_4_c, &exists_condition_c).await;
|
||||
|
||||
if inspect_result_1 == false
|
||||
&& inspect_result_2 == false
|
||||
|
|
@ -1016,8 +1018,7 @@ pub async fn execute_strategist_for_test_temp(
|
|||
&& inspect_result_4 == false
|
||||
{
|
||||
let mut filtered_3rd_symbols_lock = filtered_3rd_symbols_arc_c.lock().await;
|
||||
filtered_3rd_symbols_lock
|
||||
.push(element_c);
|
||||
filtered_3rd_symbols_lock.push(element_c);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
@ -1033,7 +1034,8 @@ pub async fn execute_strategist_for_test_temp(
|
|||
)
|
||||
.await?;
|
||||
|
||||
let bb10_30m_data: Vec<(String, Vec<BollingerBandData>)> = value_estimation_team::indicators::bollingerband::bollingerband(
|
||||
let bb10_30m_data: Vec<(String, Vec<BollingerBandData>)> =
|
||||
value_estimation_team::indicators::bollingerband::bollingerband(
|
||||
10,
|
||||
3.0,
|
||||
&sma10_30m_data,
|
||||
|
|
@ -1044,7 +1046,8 @@ pub async fn execute_strategist_for_test_temp(
|
|||
|
||||
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)>>> = Arc::new(Mutex::new(filtered_4th_symbols)); // (symbol, closetime)
|
||||
let mut filtered_4th_symbols_arc: Arc<Mutex<Vec<(String, i64)>>> =
|
||||
Arc::new(Mutex::new(filtered_4th_symbols)); // (symbol, closetime)
|
||||
for element in filtered_3rd_iter {
|
||||
let mut bb10_30m_vec: Vec<BollingerBandData> = Vec::new();
|
||||
let bb10_30m_option = bb10_30m_data.iter().position(|x| *x.0 == element.0);
|
||||
|
|
@ -1072,9 +1075,9 @@ pub async fn execute_strategist_for_test_temp(
|
|||
);
|
||||
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;
|
||||
filtered_4th_symbols_lock
|
||||
.push(element_c);
|
||||
let mut filtered_4th_symbols_lock =
|
||||
filtered_4th_symbols_arc_c.lock().await;
|
||||
filtered_4th_symbols_lock.push(element_c);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
@ -1122,25 +1125,13 @@ pub async fn execute_strategist_for_test_temp(
|
|||
let mut filtered_6th_symbols: Vec<(String, i64)> = Vec::new(); // (symbol, closetime)
|
||||
for element in filtered_5th_symbols {
|
||||
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
||||
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() {
|
||||
let opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()]
|
||||
.1
|
||||
.clone();
|
||||
let opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.clone();
|
||||
|
||||
if opclo_30m_vec.len() >= 3 {
|
||||
let heatmap_volume_option = heatmap_volume(
|
||||
&element.0,
|
||||
&rt_price_30m_vec_c,
|
||||
10,
|
||||
10,
|
||||
4.0,
|
||||
2.5,
|
||||
1.0,
|
||||
-0.5,
|
||||
)
|
||||
let heatmap_volume_option =
|
||||
heatmap_volume(&element.0, &rt_price_30m_vec_c, 10, 10, 4.0, 2.5, 1.0, -0.5)
|
||||
.await;
|
||||
if heatmap_volume_option.is_some() {
|
||||
let heatmap_volume_vec = heatmap_volume_option.unwrap();
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ use crate::database_control::*;
|
|||
use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
|
||||
use crate::value_estimation_team::indicators::sma::SmaData;
|
||||
use csv::{DeserializeRecordsIter, StringRecord};
|
||||
use futures::future::try_join_all;
|
||||
use serde::Deserialize;
|
||||
use sqlx::FromRow;
|
||||
use tokio::{fs::*, io::AsyncWriteExt, time::*, sync::Mutex};
|
||||
use futures::future::try_join_all;
|
||||
use std::{sync::Arc};
|
||||
use std::sync::Arc;
|
||||
use tokio::{fs::*, io::AsyncWriteExt, sync::Mutex, time::*};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BollingerBandData {
|
||||
|
|
@ -128,7 +128,8 @@ pub async fn bollingerband(
|
|||
Err(E) => {}
|
||||
}
|
||||
let mut bb_data_wrapper_lock = bb_data_wrapper_arc_c.lock().await;
|
||||
bb_data_wrapper_lock.push((symbol_c.0.clone(), bb_data_vec.clone()));
|
||||
bb_data_wrapper_lock
|
||||
.push((symbol_c.0.clone(), bb_data_vec.clone()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
use crate::database_control::*;
|
||||
use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
|
||||
use csv::{DeserializeRecordsIter, StringRecord};
|
||||
use futures::future::try_join_all;
|
||||
use serde::Deserialize;
|
||||
use sqlx::FromRow;
|
||||
use tokio::{fs::*, io::AsyncWriteExt, time::*, sync::Mutex};
|
||||
use futures::future::try_join_all;
|
||||
use std::{sync::Arc};
|
||||
use std::sync::Arc;
|
||||
use tokio::{fs::*, io::AsyncWriteExt, sync::Mutex, time::*};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SmaData {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user