kalshi_rust/fcm/
mod.rs

1use super::Kalshi;
2use crate::kalshi_error::*;
3use crate::portfolio::Order;
4use serde::Deserialize;
5
6impl Kalshi {
7    /// Retrieves FCM (Futures Commission Merchant) orders.
8    ///
9    /// This method is intended for use by FCM members only.
10    /// It retrieves orders through the FCM interface.
11    ///
12    /// # Returns
13    ///
14    /// - `Ok(Vec<Order>)`: A vector of FCM orders on successful retrieval.
15    /// - `Err(KalshiError)`: An error if there is an issue with the request.
16    ///
17    /// # Example
18    ///
19    /// ```
20    /// // Assuming `kalshi_instance` is an instance of `Kalshi` with FCM access
21    /// let fcm_orders = kalshi_instance.get_fcm_orders().await.unwrap();
22    /// ```
23    ///
24    /// # Note
25    ///
26    /// This endpoint is only available to users with FCM account access.
27    ///
28    pub async fn get_fcm_orders(&self) -> Result<Vec<Order>, KalshiError> {
29        let path = "/fcm/orders";
30        let res: FcmOrdersResponse = self.signed_get(path).await?;
31        Ok(res.orders)
32    }
33
34    /// Retrieves FCM (Futures Commission Merchant) positions.
35    ///
36    /// This method is intended for use by FCM members only.
37    /// It retrieves positions through the FCM interface.
38    ///
39    /// # Returns
40    ///
41    /// - `Ok(Vec<FcmPosition>)`: A vector of FCM positions on successful retrieval.
42    /// - `Err(KalshiError)`: An error if there is an issue with the request.
43    ///
44    /// # Example
45    ///
46    /// ```
47    /// // Assuming `kalshi_instance` is an instance of `Kalshi` with FCM access
48    /// let fcm_positions = kalshi_instance.get_fcm_positions().await.unwrap();
49    /// ```
50    ///
51    /// # Note
52    ///
53    /// This endpoint is only available to users with FCM account access.
54    ///
55    pub async fn get_fcm_positions(&self) -> Result<Vec<FcmPosition>, KalshiError> {
56        let path = "/fcm/positions";
57        let res: FcmPositionsResponse = self.signed_get(path).await?;
58        Ok(res.positions)
59    }
60}
61
62// -------- Response wrappers --------
63
64#[derive(Debug, Deserialize)]
65struct FcmOrdersResponse {
66    orders: Vec<Order>,
67}
68
69#[derive(Debug, Deserialize)]
70struct FcmPositionsResponse {
71    positions: Vec<FcmPosition>,
72}
73
74// -------- Public models --------
75
76use serde::Serialize;
77
78/// Represents an FCM position (simplified version for FCM interface).
79#[derive(Debug, Deserialize, Serialize)]
80pub struct FcmPosition {
81    /// The market ticker for this position.
82    pub ticker: String,
83    /// The number of contracts held.
84    pub position: i32,
85    /// Additional position details.
86    #[serde(flatten)]
87    pub details: std::collections::HashMap<String, serde_json::Value>,
88}