atelier_quant 0.0.12

Quantitative Finance Tools & Models for the atelier-rs engine
Documentation
//! Timestamp extraction from atelier-data types.
//!
//! Provides functions to pull raw arrival timestamps (in nanoseconds) from
//! `Vec<Orderbook>` and `Vec<Trade>` loaded via the atelier-data parquet I/O.

use atelier_data::{orderbooks::Orderbook, temporal, trades::Trade};

/// Extract arrival timestamps from orderbook snapshots.
///
/// Orderbook timestamps (`orderbook_ts`) are already in nanoseconds.
/// The returned vector preserves the input ordering.
///
/// # Arguments
///
/// * `orderbooks` - Slice of orderbook snapshots loaded from parquet.
///
/// # Returns
///
/// A `Vec<u64>` of timestamps in nanoseconds.
pub fn extract_orderbook_timestamps(orderbooks: &[Orderbook]) -> Vec<u64> {
    orderbooks.iter().map(|ob| ob.orderbook_ts).collect()
}

/// Extract arrival timestamps from public trades.
///
/// Trade timestamps (`trade_ts`) are in **milliseconds**. This function
/// converts them to nanoseconds for a unified temporal representation.
///
/// # Arguments
///
/// * `trades` - Slice of trades loaded from parquet.
///
/// # Returns
///
/// A `Vec<u64>` of timestamps in nanoseconds.
pub fn extract_trade_timestamps(trades: &[Trade]) -> Vec<u64> {
    trades
        .iter()
        .map(|t| temporal::to_nanos(t.trade_ts, temporal::TimeResolution::Milliseconds))
        .collect()
}