chapaty 1.1.2

An event-driven Rust engine for building and evaluating quantitative trading agents. Features a Gym-style API for algorithmic backtesting and reinforcement learning.
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
    }
}