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::sma::SmaData;
|
||||||
use crate::value_estimation_team::indicators::stoch_rsi::{StochRsiDData, StochRsiKData};
|
use crate::value_estimation_team::indicators::stoch_rsi::{StochRsiDData, StochRsiKData};
|
||||||
use crate::value_estimation_team::indicators::supertrend::{supertrend, SupertrendData};
|
use crate::value_estimation_team::indicators::supertrend::{supertrend, SupertrendData};
|
||||||
use futures::future::try_join_all;
|
|
||||||
use csv::{DeserializeRecordsIter, StringRecord};
|
use csv::{DeserializeRecordsIter, StringRecord};
|
||||||
|
use futures::future::try_join_all;
|
||||||
use rust_decimal::prelude::ToPrimitive;
|
use rust_decimal::prelude::ToPrimitive;
|
||||||
use rust_decimal::Decimal;
|
use rust_decimal::Decimal;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::FromRow;
|
use sqlx::FromRow;
|
||||||
use std::{cmp::Ordering, sync::Arc};
|
use std::{cmp::Ordering, sync::Arc};
|
||||||
use tokio::time::{sleep, Duration, Instant};
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
use tokio::time::{sleep, Duration, Instant};
|
||||||
|
|
||||||
use crate::signal_association::signal_decision::*;
|
use crate::signal_association::signal_decision::*;
|
||||||
|
|
||||||
|
|
@ -930,11 +930,10 @@ pub async fn execute_strategists(
|
||||||
pub async fn execute_strategist_for_test_temp(
|
pub async fn execute_strategist_for_test_temp(
|
||||||
alldata: &AllData,
|
alldata: &AllData,
|
||||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
) -> 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.
|
// 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: 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 mut task_vec = Vec::new();
|
||||||
let valid_symbol_vec_c = alldata.valid_symbol_vec.clone();
|
let valid_symbol_vec_c = alldata.valid_symbol_vec.clone();
|
||||||
for symbol in valid_symbol_vec_c {
|
for symbol in valid_symbol_vec_c {
|
||||||
|
|
@ -943,33 +942,31 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
||||||
let filtered_2nd_symbols_arc_c = Arc::clone(&filtered_2nd_symbols_arc);
|
let filtered_2nd_symbols_arc_c = Arc::clone(&filtered_2nd_symbols_arc);
|
||||||
task_vec.push(tokio::spawn(async move {
|
task_vec.push(tokio::spawn(async move {
|
||||||
let opclo_30m_option = rt_price_30m_vec_c.iter()
|
let opclo_30m_option = rt_price_30m_vec_c.iter().position(|x| *x.0 == symbol);
|
||||||
.position(|x| *x.0 == symbol);
|
|
||||||
let supertrend_option_30m =
|
let supertrend_option_30m =
|
||||||
supertrend(&symbol, &rt_price_30m_vec_c, 10, 1.3, true).await;
|
supertrend(&symbol, &rt_price_30m_vec_c, 10, 1.3, true).await;
|
||||||
|
|
||||||
if opclo_30m_option.is_some() && supertrend_option_30m.is_some() {
|
if opclo_30m_option.is_some() && supertrend_option_30m.is_some() {
|
||||||
opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()]
|
opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.clone();
|
||||||
.1
|
|
||||||
.clone();
|
|
||||||
supertrend_vec = supertrend_option_30m.unwrap();
|
supertrend_vec = supertrend_option_30m.unwrap();
|
||||||
|
|
||||||
if opclo_30m_vec.len() >= 3 && supertrend_vec.len() >= 3 {
|
if opclo_30m_vec.len() >= 3 && supertrend_vec.len() >= 3 {
|
||||||
let supertrend_search_result = supertrend_vec.binary_search_by_key(
|
let supertrend_search_result = supertrend_vec.binary_search_by_key(
|
||||||
&opclo_30m_vec.last().unwrap().close_time,
|
&opclo_30m_vec.last().unwrap().close_time,
|
||||||
|SupertrendData {
|
|SupertrendData {
|
||||||
band_value,
|
band_value,
|
||||||
signal,
|
signal,
|
||||||
area,
|
area,
|
||||||
close_time,
|
close_time,
|
||||||
}| *close_time,
|
}| *close_time,
|
||||||
);
|
);
|
||||||
if supertrend_search_result.is_ok() {
|
if supertrend_search_result.is_ok() {
|
||||||
if supertrend_vec[supertrend_search_result.unwrap()]
|
if supertrend_vec[supertrend_search_result.unwrap()]
|
||||||
.area
|
.area
|
||||||
.contains("DOWN")
|
.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
|
filtered_2nd_symbols_lock
|
||||||
.push((symbol.clone(), opclo_30m_vec.last().unwrap().close_time));
|
.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 inspect_table_name_4 = String::from("suggested_coin_list");
|
||||||
|
|
||||||
let mut filtered_3rd_symbols: Vec<(String, i64)> = Vec::new();
|
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 mut task_vec = Vec::new();
|
||||||
|
|
||||||
let filtered_2nd_iter = filtered_2nd_symbols_arc.lock().await.clone().into_iter();
|
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 element_c = element.clone();
|
||||||
let filtered_3rd_symbols_arc_c = Arc::clone(&filtered_3rd_symbols_arc);
|
let filtered_3rd_symbols_arc_c = Arc::clone(&filtered_3rd_symbols_arc);
|
||||||
task_vec.push(tokio::spawn(async move {
|
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_1 =
|
||||||
let inspect_result_2 = exists_record(&inspect_table_name_2_c, &exists_condition_c).await;
|
exists_record(&inspect_table_name_1_c, &exists_condition_c).await;
|
||||||
let inspect_result_3 = exists_record(&inspect_table_name_3_c, &exists_condition_c).await;
|
let inspect_result_2 =
|
||||||
let inspect_result_4 = exists_record(&inspect_table_name_4_c, &exists_condition_c).await;
|
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
|
if inspect_result_1 == false
|
||||||
&& inspect_result_2 == false
|
&& inspect_result_2 == false
|
||||||
|
|
@ -1016,8 +1018,7 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
&& inspect_result_4 == false
|
&& inspect_result_4 == false
|
||||||
{
|
{
|
||||||
let mut filtered_3rd_symbols_lock = filtered_3rd_symbols_arc_c.lock().await;
|
let mut filtered_3rd_symbols_lock = filtered_3rd_symbols_arc_c.lock().await;
|
||||||
filtered_3rd_symbols_lock
|
filtered_3rd_symbols_lock.push(element_c);
|
||||||
.push(element_c);
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -1032,49 +1033,51 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
&filtered_3rd_symbols_mutex,
|
&filtered_3rd_symbols_mutex,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let bb10_30m_data: Vec<(String, Vec<BollingerBandData>)> = value_estimation_team::indicators::bollingerband::bollingerband(
|
let bb10_30m_data: Vec<(String, Vec<BollingerBandData>)> =
|
||||||
10,
|
value_estimation_team::indicators::bollingerband::bollingerband(
|
||||||
3.0,
|
10,
|
||||||
&sma10_30m_data,
|
3.0,
|
||||||
&alldata.rt_price_30m_vec,
|
&sma10_30m_data,
|
||||||
&filtered_3rd_symbols_mutex,
|
&alldata.rt_price_30m_vec,
|
||||||
)
|
&filtered_3rd_symbols_mutex,
|
||||||
.await?;
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let mut task_vec = Vec::new();
|
let mut task_vec = Vec::new();
|
||||||
let mut filtered_4th_symbols: Vec<(String, i64)> = 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 {
|
for element in filtered_3rd_iter {
|
||||||
let mut bb10_30m_vec: Vec<BollingerBandData> = Vec::new();
|
let mut bb10_30m_vec: Vec<BollingerBandData> = Vec::new();
|
||||||
let bb10_30m_option = bb10_30m_data.iter().position(|x| *x.0 == element.0);
|
let bb10_30m_option = bb10_30m_data.iter().position(|x| *x.0 == element.0);
|
||||||
let bb10_30m_option_c = bb10_30m_option.clone();
|
let bb10_30m_option_c = bb10_30m_option.clone();
|
||||||
let element_c = element.clone();
|
let element_c = element.clone();
|
||||||
let filtered_4th_symbols_arc_c = Arc::clone(&filtered_4th_symbols_arc);
|
let filtered_4th_symbols_arc_c = Arc::clone(&filtered_4th_symbols_arc);
|
||||||
|
|
||||||
if bb10_30m_option_c.is_some() {
|
if bb10_30m_option_c.is_some() {
|
||||||
bb10_30m_vec = bb10_30m_data[bb10_30m_option_c.unwrap()].1.clone();
|
bb10_30m_vec = bb10_30m_data[bb10_30m_option_c.unwrap()].1.clone();
|
||||||
|
|
||||||
if bb10_30m_vec.len() >= 3 {
|
if bb10_30m_vec.len() >= 3 {
|
||||||
let bb10_30m_vec_c = bb10_30m_vec.clone();
|
let bb10_30m_vec_c = bb10_30m_vec.clone();
|
||||||
let current_price = get_current_price(&element_c.0, &alldata.price_vec)
|
let current_price = get_current_price(&element_c.0, &alldata.price_vec)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
task_vec.push(tokio::spawn(async move {
|
task_vec.push(tokio::spawn(async move {
|
||||||
let bb_search_result = bb10_30m_vec_c.binary_search_by_key(
|
let bb_search_result = bb10_30m_vec_c.binary_search_by_key(
|
||||||
&element_c.1,
|
&element_c.1,
|
||||||
|&BollingerBandData {
|
|&BollingerBandData {
|
||||||
sma,
|
sma,
|
||||||
upperband,
|
upperband,
|
||||||
lowerband,
|
lowerband,
|
||||||
close_time,
|
close_time,
|
||||||
}| 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 {
|
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;
|
let mut filtered_4th_symbols_lock =
|
||||||
filtered_4th_symbols_lock
|
filtered_4th_symbols_arc_c.lock().await;
|
||||||
.push(element_c);
|
filtered_4th_symbols_lock.push(element_c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
@ -1082,7 +1085,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 30.
|
||||||
let filtered_4th_iter = filtered_4th_symbols_arc.lock().await.clone().into_iter();
|
let filtered_4th_iter = filtered_4th_symbols_arc.lock().await.clone().into_iter();
|
||||||
let mut rsi10_30m_data: Vec<(String, Vec<RsiData>)> = Vec::new();
|
let mut rsi10_30m_data: Vec<(String, Vec<RsiData>)> = Vec::new();
|
||||||
|
|
@ -1117,31 +1120,19 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5th filtering: heatmap volume(MA length 10, std length 10, 30m close price), the current candle should be over than high at least.
|
// 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)
|
let mut filtered_6th_symbols: Vec<(String, i64)> = Vec::new(); // (symbol, closetime)
|
||||||
for element in filtered_5th_symbols {
|
for element in filtered_5th_symbols {
|
||||||
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
let rt_price_30m_vec_c = alldata.rt_price_30m_vec.clone();
|
||||||
let opclo_30m_option = rt_price_30m_vec_c
|
let opclo_30m_option = rt_price_30m_vec_c.iter().position(|x| *x.0 == element.0);
|
||||||
.iter()
|
|
||||||
.position(|x| *x.0 == element.0);
|
|
||||||
if opclo_30m_option.is_some() {
|
if opclo_30m_option.is_some() {
|
||||||
let opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()]
|
let opclo_30m_vec = rt_price_30m_vec_c[opclo_30m_option.unwrap()].1.clone();
|
||||||
.1
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
if opclo_30m_vec.len() >= 3 {
|
if opclo_30m_vec.len() >= 3 {
|
||||||
let heatmap_volume_option = heatmap_volume(
|
let heatmap_volume_option =
|
||||||
&element.0,
|
heatmap_volume(&element.0, &rt_price_30m_vec_c, 10, 10, 4.0, 2.5, 1.0, -0.5)
|
||||||
&rt_price_30m_vec_c,
|
.await;
|
||||||
10,
|
|
||||||
10,
|
|
||||||
4.0,
|
|
||||||
2.5,
|
|
||||||
1.0,
|
|
||||||
-0.5,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
if heatmap_volume_option.is_some() {
|
if heatmap_volume_option.is_some() {
|
||||||
let heatmap_volume_vec = heatmap_volume_option.unwrap();
|
let heatmap_volume_vec = heatmap_volume_option.unwrap();
|
||||||
let heatmap_search_result = heatmap_volume_vec.binary_search_by_key(
|
let heatmap_search_result = heatmap_volume_vec.binary_search_by_key(
|
||||||
|
|
@ -1167,7 +1158,7 @@ pub async fn execute_strategist_for_test_temp(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6th filtering condition: MACD
|
// 6th filtering condition: MACD
|
||||||
// let mut opclo_30m_vec: Vec<RealtimePriceData> = Vec::new();
|
// let mut opclo_30m_vec: Vec<RealtimePriceData> = Vec::new();
|
||||||
// let mut ema3_1d_vec: &Vec<EmaData> = &Vec::new();
|
// let mut ema3_1d_vec: &Vec<EmaData> = &Vec::new();
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ use crate::database_control::*;
|
||||||
use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
|
use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
|
||||||
use crate::value_estimation_team::indicators::sma::SmaData;
|
use crate::value_estimation_team::indicators::sma::SmaData;
|
||||||
use csv::{DeserializeRecordsIter, StringRecord};
|
use csv::{DeserializeRecordsIter, StringRecord};
|
||||||
|
use futures::future::try_join_all;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::FromRow;
|
use sqlx::FromRow;
|
||||||
use tokio::{fs::*, io::AsyncWriteExt, time::*, sync::Mutex};
|
use std::sync::Arc;
|
||||||
use futures::future::try_join_all;
|
use tokio::{fs::*, io::AsyncWriteExt, sync::Mutex, time::*};
|
||||||
use std::{sync::Arc};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct BollingerBandData {
|
pub struct BollingerBandData {
|
||||||
|
|
@ -33,7 +33,7 @@ impl BollingerBandData {
|
||||||
|
|
||||||
// Binance Bollingerband (SMA)
|
// Binance Bollingerband (SMA)
|
||||||
pub async fn bollingerband(
|
pub async fn bollingerband(
|
||||||
period: usize, // this value should be same as moving size of sma
|
period: usize, // this value should be same as moving size of sma
|
||||||
sd_factor: f64,
|
sd_factor: f64,
|
||||||
input_sma_data: &Vec<(String, Vec<SmaData>)>,
|
input_sma_data: &Vec<(String, Vec<SmaData>)>,
|
||||||
input_rt_data: &Vec<(String, Vec<RealtimePriceData>)>,
|
input_rt_data: &Vec<(String, Vec<RealtimePriceData>)>,
|
||||||
|
|
@ -75,27 +75,27 @@ pub async fn bollingerband(
|
||||||
let result = read_rt_data_vec_c[rt_index].1.binary_search_by_key(
|
let result = read_rt_data_vec_c[rt_index].1.binary_search_by_key(
|
||||||
&read_sma_data_vec_c[sma_index].1.first().unwrap().close_time,
|
&read_sma_data_vec_c[sma_index].1.first().unwrap().close_time,
|
||||||
|RealtimePriceData {
|
|RealtimePriceData {
|
||||||
opclo_price,
|
opclo_price,
|
||||||
open_price,
|
open_price,
|
||||||
close_price,
|
close_price,
|
||||||
high_price,
|
high_price,
|
||||||
low_price,
|
low_price,
|
||||||
close_time,
|
close_time,
|
||||||
quote_asset_volume,
|
quote_asset_volume,
|
||||||
candle_type,
|
candle_type,
|
||||||
}| *close_time,
|
}| *close_time,
|
||||||
);
|
);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(T) => {
|
Ok(T) => {
|
||||||
if T <= period - 1 {
|
if T <= period - 1 {
|
||||||
let mut read_data_iter =
|
let mut read_data_iter =
|
||||||
read_sma_data_vec_c[sma_index].1.iter();
|
read_sma_data_vec_c[sma_index].1.iter();
|
||||||
for _ in T..period - 1 {
|
for _ in T..period - 1 {
|
||||||
read_data_iter.next();
|
read_data_iter.next();
|
||||||
}
|
}
|
||||||
let window_iter =
|
let window_iter =
|
||||||
read_rt_data_vec_c[rt_index].1.windows(period);
|
read_rt_data_vec_c[rt_index].1.windows(period);
|
||||||
for buffer in window_iter {
|
for buffer in window_iter {
|
||||||
let mut sd_mean = 0.0;
|
let mut sd_mean = 0.0;
|
||||||
let mut standard_deviation = 0.0;
|
let mut standard_deviation = 0.0;
|
||||||
|
|
@ -128,7 +128,8 @@ pub async fn bollingerband(
|
||||||
Err(E) => {}
|
Err(E) => {}
|
||||||
}
|
}
|
||||||
let mut bb_data_wrapper_lock = bb_data_wrapper_arc_c.lock().await;
|
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()));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -139,6 +140,6 @@ pub async fn bollingerband(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try_join_all(task_vec).await?;
|
try_join_all(task_vec).await?;
|
||||||
let a = bb_data_wrapper_arc.lock().await.to_owned();
|
let a = bb_data_wrapper_arc.lock().await.to_owned();
|
||||||
Ok(a)
|
Ok(a)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
use crate::database_control::*;
|
use crate::database_control::*;
|
||||||
use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
|
use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
|
||||||
use csv::{DeserializeRecordsIter, StringRecord};
|
use csv::{DeserializeRecordsIter, StringRecord};
|
||||||
|
use futures::future::try_join_all;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::FromRow;
|
use sqlx::FromRow;
|
||||||
use tokio::{fs::*, io::AsyncWriteExt, time::*, sync::Mutex};
|
use std::sync::Arc;
|
||||||
use futures::future::try_join_all;
|
use tokio::{fs::*, io::AsyncWriteExt, sync::Mutex, time::*};
|
||||||
use std::{sync::Arc};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct SmaData {
|
pub struct SmaData {
|
||||||
|
|
@ -36,7 +36,7 @@ pub async fn sma(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut sma_data_wrapper: Vec<(String, Vec<SmaData>)> = Vec::new();
|
let mut sma_data_wrapper: Vec<(String, Vec<SmaData>)> = Vec::new();
|
||||||
let mut sma_data_wrapper_arc = Arc::new(Mutex::new(sma_data_wrapper));
|
let mut sma_data_wrapper_arc = Arc::new(Mutex::new(sma_data_wrapper));
|
||||||
// let mut sma_data_vec: Vec<SmaData> = Vec::new();
|
// let mut sma_data_vec: Vec<SmaData> = Vec::new();
|
||||||
// let mut sma_data_vec_arc = Arc::new(sma_data_vec);
|
// let mut sma_data_vec_arc = Arc::new(sma_data_vec);
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ pub async fn sma(
|
||||||
let symbol_search_result = input_rt_data.iter().position(|x| x.0 == *symbol.0);
|
let symbol_search_result = input_rt_data.iter().position(|x| x.0 == *symbol.0);
|
||||||
// let sma_data_vec_arc_c = Arc::clone(&sma_data_vec_arc);
|
// let sma_data_vec_arc_c = Arc::clone(&sma_data_vec_arc);
|
||||||
// sma_data_vec_arc_c.clear();
|
// sma_data_vec_arc_c.clear();
|
||||||
|
|
||||||
match symbol_search_result {
|
match symbol_search_result {
|
||||||
Some(T) => {
|
Some(T) => {
|
||||||
let sma_data_wrapper_arc_c = Arc::clone(&sma_data_wrapper_arc);
|
let sma_data_wrapper_arc_c = Arc::clone(&sma_data_wrapper_arc);
|
||||||
|
|
@ -80,6 +80,6 @@ pub async fn sma(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try_join_all(task_vec).await?;
|
try_join_all(task_vec).await?;
|
||||||
let a = sma_data_wrapper_arc.lock().await.to_owned();
|
let a = sma_data_wrapper_arc.lock().await.to_owned();
|
||||||
Ok(a)
|
Ok(a)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user