use std::ffi::c_char;
use databento::dbn;
use nautilus_core::UnixNanos;
use nautilus_model::{
enums::OrderSide,
identifiers::InstrumentId,
types::{Price, Quantity},
};
use serde::Deserialize;
use ustr::Ustr;
use super::enums::{DatabentoStatisticType, DatabentoStatisticUpdateAction};
pub type PublisherId = u16;
pub type Dataset = Ustr;
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize)]
pub struct DatabentoPublisher {
pub publisher_id: PublisherId,
pub dataset: dbn::Dataset,
pub venue: dbn::Venue,
pub description: String,
}
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize)]
pub struct DatabentoImbalance {
pub instrument_id: InstrumentId,
pub ref_price: Price,
pub cont_book_clr_price: Price,
pub auct_interest_clr_price: Price,
pub paired_qty: Quantity,
pub total_imbalance_qty: Quantity,
pub side: OrderSide,
pub significant_imbalance: c_char,
pub ts_event: UnixNanos,
pub ts_recv: UnixNanos,
pub ts_init: UnixNanos,
}
impl DatabentoImbalance {
#[allow(clippy::too_many_arguments)]
#[must_use]
pub const fn new(
instrument_id: InstrumentId,
ref_price: Price,
cont_book_clr_price: Price,
auct_interest_clr_price: Price,
paired_qty: Quantity,
total_imbalance_qty: Quantity,
side: OrderSide,
significant_imbalance: c_char,
ts_event: UnixNanos,
ts_recv: UnixNanos,
ts_init: UnixNanos,
) -> Self {
Self {
instrument_id,
ref_price,
cont_book_clr_price,
auct_interest_clr_price,
paired_qty,
total_imbalance_qty,
side,
significant_imbalance,
ts_event,
ts_recv,
ts_init,
}
}
}
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize)]
pub struct DatabentoStatistics {
pub instrument_id: InstrumentId,
pub stat_type: DatabentoStatisticType,
pub update_action: DatabentoStatisticUpdateAction,
pub price: Option<Price>,
pub quantity: Option<Quantity>,
pub channel_id: u16,
pub stat_flags: u8,
pub sequence: u32,
pub ts_ref: UnixNanos,
pub ts_in_delta: i32,
pub ts_event: UnixNanos,
pub ts_recv: UnixNanos,
pub ts_init: UnixNanos,
}
impl DatabentoStatistics {
#[allow(clippy::too_many_arguments)]
#[must_use]
pub const fn new(
instrument_id: InstrumentId,
stat_type: DatabentoStatisticType,
update_action: DatabentoStatisticUpdateAction,
price: Option<Price>,
quantity: Option<Quantity>,
channel_id: u16,
stat_flags: u8,
sequence: u32,
ts_ref: UnixNanos,
ts_in_delta: i32,
ts_event: UnixNanos,
ts_recv: UnixNanos,
ts_init: UnixNanos,
) -> Self {
Self {
instrument_id,
stat_type,
update_action,
price,
quantity,
channel_id,
stat_flags,
sequence,
ts_ref,
ts_in_delta,
ts_event,
ts_recv,
ts_init,
}
}
}