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
24/// A timestamped record of a component of a user's bid.
25///
26/// The interval for which the component has this value is provided alongside
27/// the value itself.
28#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30pub struct ValueRecord<DateTime, Value> {
31 /// The timestamp when this change occurred
32 pub valid_from: DateTime,
33 /// The timestamp when this change was superceded
34 pub valid_until: Option<DateTime>,
35 /// The component value
36 pub value: Value,
37}
38
39/// A timestamped record of an outcome from batch processing.
40///
41/// This generic structure is used to store results from the solver,
42/// such as portfolio allocations or product clearing prices, along with
43/// the timestamp of the batch they were computed in.
44#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
45#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
46pub struct OutcomeRecord<DateTime, Outcome> {
47 /// The timestamp when this outcome was computed
48 pub as_of: DateTime,
49 /// The actual outcome data (e.g., allocation, price)
50 pub outcome: Outcome,
51}