pub struct BacktestEngine<S: Signal> { /* private fields */ }Expand description
Builder for configuring and executing a backtest simulation. Encapsulates the configuration,
database connection, operator, and time range for the backtest. The simulation is started when
start is called, returning a BacktestController for monitoring progress.
Implementations§
Source§impl<S: Signal> BacktestEngine<S>
impl<S: Signal> BacktestEngine<S>
Sourcepub async fn with_signal_operator(
config: BacktestConfig,
db: Arc<Database>,
evaluators: Vec<Box<dyn SignalEvaluator<S>>>,
signal_operator: Box<dyn SignalOperator<S>>,
start_time: DateTime<Utc>,
start_balance: u64,
end_time: DateTime<Utc>,
) -> Result<Self, BacktestError>
pub async fn with_signal_operator( config: BacktestConfig, db: Arc<Database>, evaluators: Vec<Box<dyn SignalEvaluator<S>>>, signal_operator: Box<dyn SignalOperator<S>>, start_time: DateTime<Utc>, start_balance: u64, end_time: DateTime<Utc>, ) -> Result<Self, BacktestError>
Creates a new backtest engine using signal-based evaluation. Signal evaluators generate trading signals that are processed by the signal operator to execute trading actions.
The generic parameter S ensures type safety between evaluators and operator. They must
produce and consume the same signal type.
Sourcepub fn start_time(&self) -> DateTime<Utc>
pub fn start_time(&self) -> DateTime<Utc>
Returns the start time of the backtest simulation period.
Sourcepub fn start_balance(&self) -> u64
pub fn start_balance(&self) -> u64
Returns the starting balance (in satoshis) for the backtest simulation.
Sourcepub fn end_time(&self) -> DateTime<Utc>
pub fn end_time(&self) -> DateTime<Utc>
Returns the end time of the backtest simulation period.
Sourcepub fn receiver(&self) -> BacktestReceiver
pub fn receiver(&self) -> BacktestReceiver
Creates a new receiver for subscribing to backtest status and trading state updates.
Sourcepub fn start(self) -> Arc<BacktestController>
pub fn start(self) -> Arc<BacktestController>
Starts the backtest simulation and returns a BacktestController for managing it. This
consumes the engine and spawns the backtest task in the background.
Source§impl BacktestEngine<Raw>
impl BacktestEngine<Raw>
Sourcepub async fn with_raw_operator(
config: BacktestConfig,
db: Arc<Database>,
raw_operator: Box<dyn RawOperator>,
start_time: DateTime<Utc>,
start_balance: u64,
end_time: DateTime<Utc>,
) -> Result<Self, BacktestError>
pub async fn with_raw_operator( config: BacktestConfig, db: Arc<Database>, raw_operator: Box<dyn RawOperator>, start_time: DateTime<Utc>, start_balance: u64, end_time: DateTime<Utc>, ) -> Result<Self, BacktestError>
Creates a new backtest engine using a raw operator. The raw operator directly implements trading logic without intermediate signal generation.
Auto Trait Implementations§
impl<S> Freeze for BacktestEngine<S>
impl<S> !RefUnwindSafe for BacktestEngine<S>
impl<S> Send for BacktestEngine<S>
impl<S> Sync for BacktestEngine<S>
impl<S> Unpin for BacktestEngine<S>
impl<S> !UnwindSafe for BacktestEngine<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more