Change input parameters

This commit is contained in:
Sik Yoon 2024-01-01 12:59:11 +09:00
parent ba4629f5e4
commit f4435da178
2 changed files with 11 additions and 8 deletions

View File

@ -4,7 +4,6 @@
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 crate::strategy_team::FilteredData; use crate::strategy_team::FilteredData;
use csv::{DeserializeRecordsIter, StringRecord};
use futures::future::try_join_all; use futures::future::try_join_all;
use serde::Deserialize; use serde::Deserialize;
use sqlx::FromRow; use sqlx::FromRow;

View File

@ -2,8 +2,9 @@
#![allow(warnings)] #![allow(warnings)]
use crate::database_control::*; use crate::database_control::*;
use crate::value_estimation_team::indicators::rsi::RsiData; use crate::value_estimation_team::indicators::rsi::{RsiData, rsi};
use csv::{DeserializeRecordsIter, StringRecord}; use crate::value_estimation_team::datapoints::price_data::RealtimePriceData;
use crate::strategy_team::FilteredData;
use futures::{future::try_join_all, lock::Mutex}; use futures::{future::try_join_all, lock::Mutex};
use serde::Deserialize; use serde::Deserialize;
use sqlx::FromRow; use sqlx::FromRow;
@ -45,23 +46,26 @@ impl StochRsiKData {
// Binance Stoch RSI // Binance Stoch RSI
pub async fn stoch_rsi( pub async fn stoch_rsi(
input_rsi_data: &Vec<(String, Vec<RsiData>)>, rsi_length: usize,
stoch_rsi_length: usize, stoch_rsi_length: usize,
smooth_k: usize, smooth_k: usize,
smooth_d: usize, smooth_d: usize,
input_rt_data: &Vec<(String, Vec<RealtimePriceData>)>,
filtered_symbols: &Vec<FilteredData>
) -> Result<Vec<(String, Vec<StochRsiData>)>, Box<dyn std::error::Error + Send + Sync>> { ) -> Result<Vec<(String, Vec<StochRsiData>)>, Box<dyn std::error::Error + Send + Sync>> {
let mut stoch_rsi_data_wrapper: Vec<(String, Vec<StochRsiData>)> = Vec::new(); let mut stoch_rsi_data_wrapper: Vec<(String, Vec<StochRsiData>)> = Vec::new();
let mut stoch_rsi_data_wrapper_arc = Arc::new(Mutex::new(stoch_rsi_data_wrapper)); let mut stoch_rsi_data_wrapper_arc = Arc::new(Mutex::new(stoch_rsi_data_wrapper));
let mut stoch_rsi_data_vec: Vec<StochRsiData> = Vec::new(); let mut stoch_rsi_data_vec: Vec<StochRsiData> = Vec::new();
if stoch_rsi_length == 0 || smooth_k == 0 || smooth_d == 0 { if rsi_length == 0 || stoch_rsi_length == 0 || smooth_k == 0 || smooth_d == 0 {
panic!( panic!(
"stoch_rsi_length or smooth_k or smooth_d can't be 0! stoch_rsi_length: {}, k:{}, d:{}", "rsi_length or stoch_rsi_length or smooth_k or smooth_d can't be 0! rsi_length: {}, stoch_rsi_length: {}, k:{}, d:{}",
stoch_rsi_length, smooth_k, smooth_d rsi_length, stoch_rsi_length, smooth_k, smooth_d
); );
} }
let rsi_data_vec = rsi(rsi_length, input_rt_data, filtered_symbols).await?;
let mut task_vec = Vec::new(); let mut task_vec = Vec::new();
for element in input_rsi_data { for element in rsi_data_vec {
let mut stoch_rsi_data = StochRsiData::new(); let mut stoch_rsi_data = StochRsiData::new();
let mut stoch_rsi_k_data = StochRsiKData::new(); let mut stoch_rsi_k_data = StochRsiKData::new();
let stoch_rsi_data_wrapper_arc_c = Arc::clone(&stoch_rsi_data_wrapper_arc); let stoch_rsi_data_wrapper_arc_c = Arc::clone(&stoch_rsi_data_wrapper_arc);