fts_core/
models.rs

1//! Core domain models for the flow trading system.
2//!
3//! This module contains the fundamental data structures that represent the domain entities.
4//!
5//! The models in this module are primarily data structures with minimal business logic,
6//! following the principles of the hexagonal architecture to separate domain entities
7//! from their persistence and processing implementations.
8
9mod curve;
10pub use curve::*;
11
12mod portfolio;
13pub use portfolio::*;
14
15mod demand;
16pub use demand::*;
17
18mod map;
19pub use map::*;
20
21mod datetime;
22pub use datetime::*;
23
24mod group;
25pub use group::*;
26
27/// A timestamped record of a component of a user's bid.
28///
29/// The interval for which the component has this value is provided alongside
30/// the value itself.
31#[cfg_attr(
32    feature = "schemars",
33    derive(schemars::JsonSchema),
34    schemars(rename = "{Value}Record")
35)]
36#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
37pub struct ValueRecord<DateTime, Value> {
38    /// The timestamp when this change occurred
39    pub valid_from: DateTime,
40    /// The timestamp when this change was superceded
41    pub valid_until: Option<DateTime>,
42    /// The component value
43    pub value: Value,
44}
45
46/// A timestamped record of an outcome from batch processing.
47///
48/// This generic structure is used to store results from the solver,
49/// such as portfolio allocations or product clearing prices, along with
50/// the timestamp of the batch they were computed in.
51#[cfg_attr(
52    feature = "schemars",
53    derive(schemars::JsonSchema),
54    schemars(rename = "{Outcome}Record")
55)]
56#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
57pub struct OutcomeRecord<DateTime, Outcome> {
58    /// The timestamp when this outcome was computed
59    pub as_of: DateTime,
60    /// The actual outcome data (e.g., allocation, price)
61    pub outcome: Outcome,
62}