Skip to main content

finance_query/models/futures/
cot.rs

1//! CFTC Commitments of Traders models.
2//!
3//! Populated by the CFTC adapter (`cftc` feature). Reports weekly futures
4//! positioning by trader category: commercial hedgers (producer/merchant),
5//! swap dealers, managed money (large speculators), other reportables, and
6//! small traders (the "nonreportable" residual below CFTC reporting
7//! thresholds). Source: the disaggregated futures-only combined report —
8//! physical commodities only (agriculture, energy, metals). Equity, rate,
9//! and currency futures are reported separately by the CFTC in the Traders
10//! in Financial Futures report, which is not covered here.
11
12use serde::{Deserialize, Serialize};
13
14/// Weekly Commitments of Traders positioning for one futures market.
15///
16/// Obtain via [`FuturesContract::commitments_of_traders`](crate::FuturesContract::commitments_of_traders).
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[non_exhaustive]
19pub struct CommitmentsOfTraders {
20    /// The symbol this was requested with (e.g. `"GC=F"`, or a raw CFTC
21    /// `cftc_contract_market_code`).
22    pub symbol: String,
23    /// CFTC's own market and exchange name (e.g. `"GOLD - COMMODITY EXCHANGE INC."`).
24    pub market_and_exchange_name: String,
25    /// CFTC contract market code identifying this market.
26    pub cftc_contract_market_code: String,
27    /// Weekly observations, oldest first.
28    pub observations: Vec<CotObservation>,
29}
30
31/// One weekly report row, broken down by trader category.
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[non_exhaustive]
34pub struct CotObservation {
35    /// Report date (`YYYY-MM-DD`) — the Tuesday the report is as of.
36    pub report_date: String,
37    /// Total open interest, all reporting categories combined.
38    pub open_interest: Option<i64>,
39    /// Commercial hedgers (producers/merchants/processors/users): long side.
40    pub producer_merchant_long: Option<i64>,
41    /// Commercial hedgers: short side.
42    pub producer_merchant_short: Option<i64>,
43    /// Swap dealers: long side.
44    pub swap_dealer_long: Option<i64>,
45    /// Swap dealers: short side.
46    pub swap_dealer_short: Option<i64>,
47    /// Swap dealers: spread positions.
48    pub swap_dealer_spread: Option<i64>,
49    /// Managed money (large speculators): long side.
50    pub managed_money_long: Option<i64>,
51    /// Managed money: short side.
52    pub managed_money_short: Option<i64>,
53    /// Managed money: spread positions.
54    pub managed_money_spread: Option<i64>,
55    /// Other reportable traders: long side.
56    pub other_reportable_long: Option<i64>,
57    /// Other reportable traders: short side.
58    pub other_reportable_short: Option<i64>,
59    /// Other reportable traders: spread positions.
60    pub other_reportable_spread: Option<i64>,
61    /// Sum of all reportable categories: long side.
62    pub total_reportable_long: Option<i64>,
63    /// Sum of all reportable categories: short side.
64    pub total_reportable_short: Option<i64>,
65    /// Small traders below CFTC reporting thresholds (residual): long side.
66    pub nonreportable_long: Option<i64>,
67    /// Small traders below CFTC reporting thresholds: short side.
68    pub nonreportable_short: Option<i64>,
69}