ig_client/application/models/
market.rs1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
10#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
11pub enum InstrumentType {
12 Shares,
14 Currencies,
16 Indices,
18 SprintMarket,
20 Commodities,
22 Options,
24 #[serde(rename = "BINARY")]
26 Binary,
27 #[serde(other)]
29 Unknown,
30}
31
32#[derive(Debug, Clone, Deserialize)]
34pub struct Instrument {
35 pub epic: String,
37 pub name: String,
39 #[serde(rename = "instrumentType")]
41 pub instrument_type: InstrumentType,
42 pub expiry: String,
44 #[serde(rename = "contractSize")]
46 pub contract_size: Option<f64>,
47 #[serde(rename = "lotSize")]
49 pub lot_size: Option<f64>,
50 #[serde(rename = "highLimitPrice")]
52 pub high_limit_price: Option<f64>,
53 #[serde(rename = "lowLimitPrice")]
55 pub low_limit_price: Option<f64>,
56 #[serde(rename = "marginFactor")]
58 pub margin_factor: Option<f64>,
59 #[serde(rename = "marginFactorUnit")]
61 pub margin_factor_unit: Option<String>,
62 #[serde(rename = "slippageFactor")]
64 pub slippage_factor: Option<f64>,
65 #[serde(rename = "limitedRiskPremium")]
67 pub limited_risk_premium: Option<f64>,
68 #[serde(rename = "newsCode")]
70 pub news_code: Option<String>,
71 #[serde(rename = "chartCode")]
73 pub chart_code: Option<String>,
74 pub currencies: Option<Vec<Currency>>,
76}
77
78#[derive(Debug, Clone, Deserialize)]
80pub struct Currency {
81 pub code: String,
83 pub symbol: Option<String>,
85 #[serde(rename = "baseExchangeRate")]
87 pub base_exchange_rate: Option<f64>,
88 #[serde(rename = "exchangeRate")]
90 pub exchange_rate: Option<f64>,
91 #[serde(rename = "isDefault")]
93 pub is_default: Option<bool>,
94}
95
96#[derive(Debug, Clone, Deserialize)]
98pub struct MarketDetails {
99 pub instrument: Instrument,
101 pub snapshot: MarketSnapshot,
103}
104
105#[derive(Debug, Clone, Deserialize)]
107pub struct DealingRules {
108 #[serde(rename = "minDealSize")]
110 pub min_deal_size: Option<f64>,
111 #[serde(rename = "maxDealSize")]
113 pub max_deal_size: Option<f64>,
114 #[serde(rename = "minControlledRiskStopDistance")]
116 pub min_controlled_risk_stop_distance: Option<f64>,
117 #[serde(rename = "minNormalStopOrLimitDistance")]
119 pub min_normal_stop_or_limit_distance: Option<f64>,
120 #[serde(rename = "maxStopOrLimitDistance")]
122 pub max_stop_or_limit_distance: Option<f64>,
123 #[serde(rename = "marketOrderPreference")]
125 pub market_order_preference: String,
126 #[serde(rename = "trailingStopsPreference")]
128 pub trailing_stops_preference: String,
129}
130
131#[derive(Debug, Clone, Deserialize)]
133pub struct MarketSnapshot {
134 #[serde(rename = "marketStatus")]
136 pub market_status: String,
137 #[serde(rename = "netChange")]
139 pub net_change: Option<f64>,
140 #[serde(rename = "percentageChange")]
142 pub percentage_change: Option<f64>,
143 #[serde(rename = "updateTime")]
145 pub update_time: Option<String>,
146 #[serde(rename = "delayTime")]
148 pub delay_time: Option<i64>,
149 pub bid: Option<f64>,
151 pub offer: Option<f64>,
153 #[serde(rename = "high")]
155 pub high: Option<f64>,
156 #[serde(rename = "low")]
158 pub low: Option<f64>,
159 #[serde(rename = "binaryOdds")]
161 pub binary_odds: Option<f64>,
162 #[serde(rename = "decimalPlacesFactor")]
164 pub decimal_places_factor: Option<i64>,
165 #[serde(rename = "scalingFactor")]
167 pub scaling_factor: Option<i64>,
168 #[serde(rename = "controlledRiskExtraSpread")]
170 pub controlled_risk_extra_spread: Option<f64>,
171}
172
173#[derive(Debug, Clone, Deserialize)]
175pub struct MarketSearchResult {
176 pub markets: Vec<MarketData>,
178}
179
180#[derive(Debug, Clone, Deserialize)]
182pub struct MarketData {
183 pub epic: String,
185 #[serde(rename = "instrumentName")]
187 pub instrument_name: String,
188 #[serde(rename = "instrumentType")]
190 pub instrument_type: InstrumentType,
191 pub expiry: String,
193 #[serde(rename = "highLimitPrice")]
195 pub high_limit_price: Option<f64>,
196 #[serde(rename = "lowLimitPrice")]
198 pub low_limit_price: Option<f64>,
199 #[serde(rename = "marketStatus")]
201 pub market_status: String,
202 #[serde(rename = "netChange")]
204 pub net_change: Option<f64>,
205 #[serde(rename = "percentageChange")]
207 pub percentage_change: Option<f64>,
208 #[serde(rename = "updateTime")]
210 pub update_time: Option<String>,
211 pub bid: Option<f64>,
213 pub offer: Option<f64>,
215}
216
217#[derive(Debug, Clone, Deserialize)]
219pub struct HistoricalPricesResponse {
220 pub prices: Vec<HistoricalPrice>,
222 #[serde(rename = "instrumentType")]
224 pub instrument_type: InstrumentType,
225 #[serde(rename = "allowance")]
227 pub allowance: PriceAllowance,
228}
229
230#[derive(Debug, Clone, Deserialize)]
232pub struct HistoricalPrice {
233 #[serde(rename = "snapshotTime")]
235 pub snapshot_time: String,
236 #[serde(rename = "openPrice")]
238 pub open_price: PricePoint,
239 #[serde(rename = "highPrice")]
241 pub high_price: PricePoint,
242 #[serde(rename = "lowPrice")]
244 pub low_price: PricePoint,
245 #[serde(rename = "closePrice")]
247 pub close_price: PricePoint,
248 #[serde(rename = "lastTradedVolume")]
250 pub last_traded_volume: Option<i64>,
251}
252
253#[derive(Debug, Clone, Deserialize)]
255pub struct PricePoint {
256 pub bid: Option<f64>,
258 pub ask: Option<f64>,
260 #[serde(rename = "lastTraded")]
262 pub last_traded: Option<f64>,
263}
264
265#[derive(Debug, Clone, Deserialize)]
267pub struct PriceAllowance {
268 #[serde(rename = "remainingAllowance")]
270 pub remaining_allowance: i64,
271 #[serde(rename = "totalAllowance")]
273 pub total_allowance: i64,
274 #[serde(rename = "allowanceExpiry")]
276 pub allowance_expiry: i64,
277}