From aca9eff415dbe607c9370b8bdce71f11b334423f Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Mon, 18 Dec 2023 01:17:05 +0900 Subject: [PATCH] Add strategy_test --- src/strategy_team/mod.rs | 2 ++ src/strategy_team/strategy_test.rs | 32 +++++++++++++++++++++ src/value_estimation_team/indicators/adx.rs | 4 +-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/strategy_team/strategy_test.rs diff --git a/src/strategy_team/mod.rs b/src/strategy_team/mod.rs index 5ebc47c..ef8f45e 100644 --- a/src/strategy_team/mod.rs +++ b/src/strategy_team/mod.rs @@ -4,6 +4,7 @@ pub mod strategy_003; pub mod strategy_004; pub mod strategy_005; pub mod strategy_006; +pub mod strategy_test; pub mod strategy_manager; use crate::coex::order_team::{limit_order_sell, select_filled_buy_orders}; @@ -21,6 +22,7 @@ use crate::value_estimation_team::indicators::rsi::{rsi, RsiData}; use crate::value_estimation_team::indicators::sma::{sma, SmaData}; use crate::value_estimation_team::indicators::stoch_rsi::{stoch_rsi, StochRsiData}; use crate::value_estimation_team::indicators::supertrend::{supertrend, SupertrendData}; +use crate::value_estimation_team::indicators::adx::{AdxData, adx}; use futures::future::try_join_all; use reqwest::{Client, ClientBuilder}; use rust_decimal::{prelude::FromPrimitive, prelude::ToPrimitive, Decimal, RoundingStrategy}; diff --git a/src/strategy_team/strategy_test.rs b/src/strategy_team/strategy_test.rs new file mode 100644 index 0000000..1c0a146 --- /dev/null +++ b/src/strategy_team/strategy_test.rs @@ -0,0 +1,32 @@ +use super::{ + dec, decimal_add, decimal_sub, ema, exists_record, insert_pre_suggested_coins, + limit_order_sell, rsi, select_filled_buy_orders, stoch_rsi, supertrend, try_join_all, AllData, + Arc, Client, ClientBuilder, Decimal, EmaData, ExchangeInfo, FilteredData, Mutex, + RealtimePriceData, RoundingStrategy, RsiData, StochRsiData, SupertrendData, TradeFee, update_record3, adx, AdxData +}; + + +pub async fn strategist_test( + alldata: &AllData, +) -> Result<(), Box> { + // 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: lookup tables if the tradepair is already there + let mut symbol_1 = FilteredData::new(); + let mut symbol_2 = FilteredData::new(); + let mut symbol_3 = FilteredData::new(); + symbol_1.symbol = String::from("BTCUSDT"); + symbol_2.symbol = String::from("XRPUSDT"); + symbol_3.symbol = String::from("ETHUSDT"); + let mut test_symbols: Vec = Vec::new(); + test_symbols.push(symbol_1); + test_symbols.push(symbol_2); + test_symbols.push(symbol_3); + + let a = adx(10, 10, &alldata.rt_price_30m_vec, &test_symbols).await?; + println!("{:?}", a); + + Ok(()) +} diff --git a/src/value_estimation_team/indicators/adx.rs b/src/value_estimation_team/indicators/adx.rs index 0698698..554306e 100644 --- a/src/value_estimation_team/indicators/adx.rs +++ b/src/value_estimation_team/indicators/adx.rs @@ -1,8 +1,6 @@ -// use std::thread::current; - use super::{FilteredData, RealtimePriceData, try_join_all, Arc, Mutex}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct AdxData { pub adx: f64, pub close_time: i64