Skip to main content

Module strategy

Module strategy 

Source
Expand description

Strategy trait and context for building trading strategies.

This module provides the core Strategy trait and StrategyContext for implementing custom trading strategies, as well as pre-built strategies and a fluent builder API.

§Building Custom Strategies

Use the StrategyBuilder for creating strategies with conditions:

use finance_query::backtesting::strategy::StrategyBuilder;
use finance_query::backtesting::refs::*;
use finance_query::backtesting::condition::*;

let strategy = StrategyBuilder::new("My Strategy")
    .entry(rsi(14).crosses_below(30.0))
    .exit(rsi(14).crosses_above(70.0).or(stop_loss(0.05)))
    .build();

Re-exports§

pub use prebuilt::BollingerMeanReversion;
pub use prebuilt::DonchianBreakout;
pub use prebuilt::MacdSignal;
pub use prebuilt::RsiReversal;
pub use prebuilt::SmaCrossover;
pub use prebuilt::SuperTrendFollow;

Modules§

prebuilt
Pre-built trading strategies.

Structs§

CustomStrategy
A custom strategy built from conditions.
EnsembleStrategy
A strategy that aggregates signals from multiple sub-strategies.
StrategyBuilder
Builder for creating custom strategies with entry/exit conditions.
StrategyContext
Context passed to strategy on each candle.

Enums§

EnsembleMode
Voting mode that determines how sub-strategy signals are combined.

Traits§

Strategy
Core strategy trait - implement this for custom strategies.