Skip to content

Latest commit

 

History

History
433 lines (307 loc) · 9.56 KB

File metadata and controls

433 lines (307 loc) · 9.56 KB

StrataQuant v0.5.0 Release Notes

Release Date: December 26, 2024
Focus: CLI Integration for Risk Management


Overview

v0.5.0 brings complete command-line integration for all risk management features introduced in v0.4.0. Every command (backtest, optimize, walkforward, compare) now supports stop losses, position sizing, and risk limits via CLI flags.

This release also fixes critical bugs from v0.4.0 and improves code quality with zero clippy warnings.


What's New

1. Full CLI Risk Management

All commands now accept risk parameters:

# Backtest with 10% trailing stop
strataquant backtest --strategy sma --fast 20 --slow 50 \
  --stop-type trailing --stop-pct 10.0

# Optimize with ATR stops
strataquant optimize --fast-range 20-50 --slow-range 50-100 \
  --stop-type atr --atr-multiplier 2.0

# Walk-forward with stops
strataquant walkforward --train-ratio 0.7 \
  --stop-type trailing --stop-pct 10.0

# Compare strategies with same stops
strataquant compare --stop-type trailing --stop-pct 5.0

2. Stop Loss Types

All commands support these stop types:

  • none - No stop loss (default)
  • fixed - Fixed percentage from entry
  • trailing - Moves up with price, never down
  • atr - ATR-based dynamic stops
  • time - Exit after N bars (backtest only)

3. Position Sizing (Backtest Only)

# Trade with 50% of equity
--position-sizing fixed-pct --position-size 50.0

# Trade with fixed $10,000
--position-sizing fixed-dollar --position-size 10000

4. Risk Limits (Backtest Only)

# Stop trading at -30% drawdown
--max-drawdown 30.0

CLI Reference

Common Parameters (All Commands)

--stop-type <type>          Stop loss type: none, fixed, trailing, atr
--stop-pct <percent>        Percentage for fixed/trailing (default: 10.0)
--atr-multiplier <mult>     ATR multiplier (default: 2.0)
--atr-period <period>       ATR period (default: 14)

Backtest-Only Parameters

--position-sizing <type>    fixed-pct, fixed-dollar (default: fixed-pct)
--position-size <value>     Size value (default: 100.0)
--max-drawdown <percent>    Drawdown threshold (default: 50.0)
--time-limit <bars>         Time-based stop (default: 100)

Validation Results

All tests conducted on BTC/USDT daily data (Sept 2019 - Dec 2024).

SMA 20/50 Strategy

Baseline (no stops):

Return:       429.25%
Max DD:       -37.37%
Sharpe:       0.88
Trades:       18

With 10% Trailing Stop:

Return:       418.26% (-2.6% from baseline)
Max DD:       -36.49% (slightly better)
Sharpe:       0.88 (unchanged)
Trades:       52 (34 additional stop exits)

With ATR Stop (2x14):

Return:       463.49% (+8% from baseline!)
Max DD:       -33.09% (best risk control)
Sharpe:       0.91 (improved)
Trades:       18

Key Finding: ATR stops outperform fixed percentage stops for crypto.

With 50% Position Sizing:

Return:       158.37% (linear scaling confirmed)
Max DD:       -35.20%
Trades:       22

Bug Fixes

Critical Fixes from v0.4.0

  1. Risk limits applied incorrectly

    • v0.4.0 applied default 30% drawdown threshold even when user didn't set it
    • Fixed: Risk limits only applied when explicitly set
    • Impact: Baseline results now match programmatic API
  2. Drawdown check off-by-one

    • Used < instead of <= for threshold comparison
    • Fixed: Now uses <= for correct threshold behavior
  3. Results mismatch

    • CLI showed different results than programmatic API
    • Fixed: Both now produce identical results

Code Quality Improvements

Zero Clippy Warnings

All warnings fixed with proper solutions (no #[allow] suppressions):

Before v0.5.0:

warning: this function has too many arguments (14/7)
warning: this function has too many arguments (10/7)
warning: field assignment outside of initializer

After v0.5.0:

✓ Zero warnings
✓ All functions ≤7 parameters
✓ Proper struct initialization

Code Refactoring

Introduced RiskConfig struct:

struct RiskConfig {
    stop_type: String,
    stop_pct: f64,
    atr_multiplier: f64,
    atr_period: usize,
    time_limit: usize,
    position_sizing: String,
    position_size: f64,
    max_drawdown: f64,
}

Simplified function signatures:

  • run_backtest: 14 params → 7 params
  • run_optimization: 10 params → 6 params
  • run_walkforward: 8 params → 4 params
  • run_comparison: 7 params → 3 params

New API Methods

ParameterSweep

pub fn sweep_sma_periods_with_stops(
    &self,
    fast_range: (usize, usize),
    slow_range: (usize, usize),
    step: usize,
    stop_loss: StopLossMethod,
) -> Vec<OptimizationResult>

Tests all parameter combinations with specified stop loss.

WalkForward

pub fn run_with_stops(
    &self, 
    train_ratio: f64, 
    stop_loss: StopLossMethod
) -> WalkForwardResult

Optimizes and validates with stop loss enabled.


Example Workflows

1. Find Optimal Parameters with Stops

# Test different stop configurations
strataquant optimize --fast-range 20-50 --slow-range 50-100 \
  --stop-type trailing --stop-pct 10.0

# Compare with ATR stops
strataquant optimize --fast-range 20-50 --slow-range 50-100 \
  --stop-type atr --atr-multiplier 2.0

2. Validate Strategy with Risk Controls

# Walk-forward validation with trailing stops
strataquant walkforward --train-ratio 0.7 \
  --stop-type trailing --stop-pct 10.0

3. Compare Risk/Return Profiles

# Compare strategies with different stops
strataquant compare --stop-type none
strataquant compare --stop-type trailing --stop-pct 5.0
strataquant compare --stop-type trailing --stop-pct 10.0
strataquant compare --stop-type atr --atr-multiplier 2.0

4. Conservative Risk Management

# 50% position sizing + 10% trailing stop + 30% drawdown limit
strataquant backtest --strategy sma --fast 20 --slow 50 \
  --position-sizing fixed-pct --position-size 50.0 \
  --stop-type trailing --stop-pct 10.0 \
  --max-drawdown 30.0

Performance

  • Zero overhead from CLI integration
  • Same speed as programmatic API
  • Parallel optimization fully functional
  • Memory usage unchanged

Breaking Changes

None. All v0.4.0 functionality preserved.

  • New CLI flags are optional with sensible defaults
  • Programmatic API unchanged
  • Existing scripts continue to work

Migration Guide

From v0.4.0

No changes required.

All v0.4.0 code continues to work. CLI flags are additive:

# v0.4.0 command still works
strataquant backtest --strategy sma --fast 20 --slow 50

# v0.5.0 adds optional risk parameters
strataquant backtest --strategy sma --fast 20 --slow 50 \
  --stop-type trailing --stop-pct 10.0

From v0.3.0 or Earlier

Follow v0.4.0 migration guide first, then upgrade to v0.5.0.


Known Limitations

  1. Long-only strategies

    • Short positions not supported
    • Planned for future release
  2. Single asset

    • Multi-asset portfolios planned for v0.7.0
    • Will support BTC, ETH, LTC, BCH, SOL
  3. Kelly criterion

    • Not yet implemented
    • Planned for v0.6.0
  4. No GUI

    • Command-line only (by design)
    • Focus on automation and scripting

What's Next

v0.6.0 - Advanced Features (Planned)

  • Kelly criterion position sizing
  • Volatility-based position sizing
  • Multiple timeframe support
  • Advanced indicator library
  • RSI, MACD, Bollinger Bands

v0.7.0 - Multi-Asset (Planned)

  • Portfolio support for BTC, ETH, LTC, BCH, SOL
  • Correlation analysis
  • Portfolio optimization
  • Asset allocation strategies

Installation

Requirements

  • Rust 1.70+
  • 100 MB disk space
  • Internet connection (for data download)

Build from Source

git clone https://github.com/ChronoCoders/strataquant.git
cd strataquant
git checkout v0.5.0
cargo build --release

Run

# Download data
cargo run --release --bin strataquant -- download

# Run backtest with stops
cargo run --release --bin strataquant -- backtest \
  --strategy sma --fast 20 --slow 50 \
  --stop-type trailing --stop-pct 10.0

Testing

All commands tested and validated:

# Build
cargo build --release

# Verify zero warnings
cargo clippy

# Test all commands
cargo run --release --bin strataquant -- backtest --strategy sma --fast 20 --slow 50
cargo run --release --bin strataquant -- backtest --strategy sma --fast 20 --slow 50 --stop-type trailing --stop-pct 10.0
cargo run --release --bin strataquant -- optimize --fast-range 20-50 --slow-range 50-100 --stop-type atr --atr-multiplier 2.0
cargo run --release --bin strataquant -- walkforward --train-ratio 0.7 --stop-type trailing --stop-pct 10.0
cargo run --release --bin strataquant -- compare --stop-type trailing --stop-pct 5.0

Credits

Developer: Altug Tatlisu (ChronoCoders)
Company: Distributed Systems Labs, LLC
Repository: https://github.com/ChronoCoders/strataquant
License: MIT


Support


Philosophy

StrataQuant remains committed to honest backtesting:

  • Real drawdowns shown
  • Execution costs included
  • No cherry-picking
  • Walk-forward validation
  • Risk management first

"Truth in crypto backtesting."


Full Changelog: CHANGELOG.md
Previous Release: v0.4.0
Repository: github.com/ChronoCoders/strataquant