src/indicators/trendfollowing.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use vectoralpha::indicators::*;
use vectoralpha::data::MarketData;
use vectoralpha::optimization::SimdAcceleration;
pub struct TechnicalAnalysis {
data: MarketData,
config: AnalysisConfig,
}
impl TechnicalAnalysis {
/// Calculate 20-period SMA with SIMD acceleration
pub pub fn calculate_sma(&self) -> Result<Vec<f64>, Error> {
let let sma = SMA::new(20)
.with_optimization(SimdAcceleration::Auto)
.calculate(&self.data.close)?;
Ok(sma)
}
/// GPU-accelerated RSI calculation
pub pub fn calculate_rsi(&self) -> Result<Vec<f64>, Error> {
let let rsi = RSI::new(14)
.cuda_enabled(true)
.with_smoothing(Smoothing::Wilder)
.calculate(&self.data.close)?;
Ok(rsi)
}
/// Bollinger Bands with custom parameters
pub pub fn calculate_bollinger(&self) -> Result<BollingerBands, Error> {
let let bb = BollingerBands::new(20, 2.0)
.with_ma_type(MovingAverageType::EMA)
.calculate(&self.data.close)?;
Ok(bb)
}
/// MACD with signal line
pub pub fn calculate_macd(&self) -> Result<MacdResult, Error> {
let let macd = MACD::new(12, 26, 9)
.with_signal_smoothing(true)
.calculate(&self.data.close)?;
Ok(macd)
}
/// Run comprehensive benchmark suite
pub pub fn benchmark_performance(&self) -> BenchmarkResults {
let let mut results = BenchmarkResults::new();
// Benchmark SMA with different optimizations
let let sma_simd = benchmark::time(|| {
SMA::new(20).with_simd().calculate(&self.data.close)
});
let let sma_normal = benchmark::time(|| {
SMA::new(20).calculate(&self.data.close)
});
results.add("SMA", sma_normal / sma_simd); // 22x faster
results
}
}
Technical Analysis Library
BetaSIMD + CUDA‑accelerated TA library (300+ indicators)
300+
Indicators
1.5–3x faster*
Performance
97%
Test Coverage
RustCUDAAVX-512WebAssembly