Add strategy_test

This commit is contained in:
Sik Yoon 2023-12-18 01:17:05 +09:00
parent 17dd137abf
commit aca9eff415
3 changed files with 35 additions and 3 deletions

View File

@ -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};

View File

@ -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<dyn std::error::Error + Send + Sync>> {
// 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<FilteredData> = 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(())
}

View File

@ -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