fts_solver/types/
outcome.rs

1use crate::HashMap;
2use std::hash::Hash;
3
4/// The outcome of an auction
5#[derive(Debug)]
6#[cfg_attr(
7    feature = "serde",
8    derive(serde::Serialize, serde::Deserialize),
9    serde(bound = "
10        BidderId: Hash + Eq + serde::Serialize + serde::de::DeserializeOwned,
11        PortfolioId: Clone + Hash + Eq + serde::Serialize + serde::de::DeserializeOwned,
12        ProductId: Hash + Eq + Ord + serde::Serialize + serde::de::DeserializeOwned
13    ")
14)]
15pub struct AuctionOutcome<BidderId, PortfolioId, ProductId> {
16    /// The associated outcome for each submission (in turn, the portfolio trades and prices)
17    pub submissions: HashMap<BidderId, HashMap<PortfolioId, PortfolioOutcome>>,
18
19    /// The associated outcome for each traded product
20    pub products: HashMap<ProductId, ProductOutcome>,
21}
22
23impl<BidderId, PortfolioId, ProductId> Default
24    for AuctionOutcome<BidderId, PortfolioId, ProductId>
25{
26    fn default() -> Self {
27        Self {
28            submissions: Default::default(),
29            products: Default::default(),
30        }
31    }
32}
33
34/// Solution data for an individual authorization, containing
35/// the trade quantity and effective price.
36#[derive(Debug)]
37#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
38pub struct PortfolioOutcome {
39    /// The effective price for this authorization
40    pub price: f64,
41    /// The quantity traded for this authorization (negative for sell, positive for buy)
42    pub trade: f64,
43    // TODO:
44    // consider reporting the dual information for the box constraint
45}
46
47/// Solution data for an individual product, containing
48/// the market-clearing price and total volume traded.
49#[derive(Debug)]
50#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
51pub struct ProductOutcome {
52    /// The market-clearing price for this product
53    pub price: f64,
54    /// The total quantity traded of this product (one-sided volume)
55    pub trade: f64,
56}