chapaty 1.1.0

High-performance backtesting and financial simulation framework for trading strategies and reinforcement learning agents. Async-first, Gym-like API in Rust.
1
2
3
4
5
6
7
8
9
10
use chrono::TimeDelta;

use crate::gym::trading::state::{Canceled, Trade};

impl Trade<Canceled> {
    /// Calculates how long the order was pending before cancellation.
    pub fn time_in_force(&self) -> TimeDelta {
        self.state.canceled_at - self.state.created_at
    }
}