From f4435da178ab09724ce9c2b99278b1d6d0b12233 Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Mon, 1 Jan 2024 12:59:11 +0900 Subject: [PATCH] Change input parameters --- src/value_estimation_team/indicators/rsi.rs | 1 - .../indicators/stoch_rsi.rs | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/value_estimation_team/indicators/rsi.rs b/src/value_estimation_team/indicators/rsi.rs index 83f4b2c..0004882 100644 --- a/src/value_estimation_team/indicators/rsi.rs +++ b/src/value_estimation_team/indicators/rsi.rs @@ -4,7 +4,6 @@ use crate::database_control::*; use crate::value_estimation_team::datapoints::price_data::RealtimePriceData; use crate::strategy_team::FilteredData; -use csv::{DeserializeRecordsIter, StringRecord}; use futures::future::try_join_all; use serde::Deserialize; use sqlx::FromRow; diff --git a/src/value_estimation_team/indicators/stoch_rsi.rs b/src/value_estimation_team/indicators/stoch_rsi.rs index bc13aa1..881f2ee 100644 --- a/src/value_estimation_team/indicators/stoch_rsi.rs +++ b/src/value_estimation_team/indicators/stoch_rsi.rs @@ -2,8 +2,9 @@ #![allow(warnings)] use crate::database_control::*; -use crate::value_estimation_team::indicators::rsi::RsiData; -use csv::{DeserializeRecordsIter, StringRecord}; +use crate::value_estimation_team::indicators::rsi::{RsiData, rsi}; +use crate::value_estimation_team::datapoints::price_data::RealtimePriceData; +use crate::strategy_team::FilteredData; use futures::{future::try_join_all, lock::Mutex}; use serde::Deserialize; use sqlx::FromRow; @@ -45,23 +46,26 @@ impl StochRsiKData { // Binance Stoch RSI pub async fn stoch_rsi( - input_rsi_data: &Vec<(String, Vec)>, + rsi_length: usize, stoch_rsi_length: usize, smooth_k: usize, smooth_d: usize, + input_rt_data: &Vec<(String, Vec)>, + filtered_symbols: &Vec ) -> Result)>, Box> { let mut stoch_rsi_data_wrapper: Vec<(String, Vec)> = Vec::new(); let mut stoch_rsi_data_wrapper_arc = Arc::new(Mutex::new(stoch_rsi_data_wrapper)); let mut stoch_rsi_data_vec: Vec = 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!( - "stoch_rsi_length or smooth_k or smooth_d can't be 0! stoch_rsi_length: {}, k:{}, d:{}", - stoch_rsi_length, smooth_k, smooth_d + "rsi_length or stoch_rsi_length or smooth_k or smooth_d can't be 0! rsi_length: {}, stoch_rsi_length: {}, k:{}, 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(); - for element in input_rsi_data { + for element in rsi_data_vec { let mut stoch_rsi_data = StochRsiData::new(); let mut stoch_rsi_k_data = StochRsiKData::new(); let stoch_rsi_data_wrapper_arc_c = Arc::clone(&stoch_rsi_data_wrapper_arc);