Skip to main content

brokapi_alor_protocol/http/
models.rs

1//! Request and response models of the REST API, one struct per JSON shape of the broker.
2//!
3//! The models are the `Simple` format of the broker: the original field names, which the client always asks
4//! for. Almost every field of a reply is an `Option` or has a default, because the broker fills only what fits
5//! the object, so check before you use a field. Numbers are read as decimals, never through `f64`. All dates
6//! and times of the broker are UTC.
7//!
8//! **Quantities.** The broker counts orders in lots. Its replies carry the quantity both in lots (`qty`,
9//! `qty_batch`) and in pieces (`qty_units`), and the connector reads the pieces.
10
11use rust_decimal::Decimal;
12use serde::{Deserialize, Serialize};
13
14fn dec_out<S: serde::Serializer>(d: &Decimal, s: S) -> Result<S::Ok, S::Error> {
15    rust_decimal::serde::arbitrary_precision::serialize(d, s)
16}
17
18fn dec_out_opt<S: serde::Serializer>(d: &Option<Decimal>, s: S) -> Result<S::Ok, S::Error> {
19    rust_decimal::serde::arbitrary_precision_option::serialize(d, s)
20}
21
22// ─── reference data ───────────────────────────────────────────────────────────
23
24/// An instrument: the answer of `GET /md/v2/Securities/{exchange}/{symbol}` and an item of the list
25/// `GET /md/v2/Securities`.
26#[derive(Debug, Clone, Default, Deserialize, Serialize)]
27pub struct SecurityInfo {
28    /// The ticker.
29    #[serde(default)]
30    pub symbol: String,
31    /// Short name.
32    #[serde(default)]
33    pub shortname: Option<String>,
34    /// Description in Russian.
35    #[serde(default)]
36    pub description: Option<String>,
37    /// `MOEX` or `SPBX`.
38    #[serde(default)]
39    pub exchange: String,
40    /// The market: `FORTS`, `FOND`, `CURR` or `SPBX`.
41    #[serde(default)]
42    pub market: Option<String>,
43    /// The type of the instrument (`CS` shares, `EUSOV` federal bonds, ... for MOEX).
44    #[serde(default, rename = "type")]
45    pub kind: Option<String>,
46    /// Lot size in pieces.
47    #[serde(default, rename = "lotsize", serialize_with = "dec_out_opt")]
48    pub lot_size: Option<Decimal>,
49    /// Face value (shares, bonds), contract size (futures), or the amount a quotation is given for (currency).
50    #[serde(default, rename = "facevalue", serialize_with = "dec_out_opt")]
51    pub face_value: Option<Decimal>,
52    /// ISO 10962 code of the type.
53    #[serde(default, rename = "cfiCode")]
54    pub cfi_code: Option<String>,
55    /// Expiry date of a derivative.
56    #[serde(default)]
57    pub cancellation: Option<String>,
58    /// The price step.
59    #[serde(default, rename = "minstep", serialize_with = "dec_out_opt")]
60    pub min_step: Option<Decimal>,
61    /// The price step in roubles (the value of one step).
62    #[serde(default, rename = "pricestep", serialize_with = "dec_out_opt")]
63    pub price_step: Option<Decimal>,
64    /// The currency of the price.
65    #[serde(default)]
66    pub currency: Option<String>,
67    /// ISIN.
68    #[serde(default, rename = "ISIN")]
69    pub isin: Option<String>,
70    /// The trading mode (board) of this entry.
71    #[serde(default)]
72    pub board: Option<String>,
73    /// The main trading mode of the instrument.
74    #[serde(default)]
75    pub primary_board: Option<String>,
76    /// The trading status code: 17 normal period, 18 closed, 2 break, ...
77    #[serde(default, rename = "tradingStatus")]
78    pub trading_status: Option<i32>,
79    /// The trading status as text.
80    #[serde(default, rename = "tradingStatusInfo")]
81    pub trading_status_info: Option<String>,
82}
83
84/// An item of `GET /md/status/{exchange}/{market}`: the state of the trading session of a market.
85#[derive(Debug, Clone, Default, Deserialize, Serialize)]
86pub struct MarketStatus {
87    /// The market: `FORTS`, `FOND`, `CURR` or `SPBX`.
88    #[serde(default)]
89    pub code: String,
90    /// The status as text (`open`, ...).
91    #[serde(default)]
92    pub status: String,
93}
94
95// ─── market data ──────────────────────────────────────────────────────────────
96
97/// One level of an order book.
98#[derive(Debug, Clone, Deserialize, Serialize)]
99pub struct BookLevel {
100    /// The price.
101    #[serde(serialize_with = "dec_out")]
102    pub price: Decimal,
103    /// The volume at the price, as the broker reports it.
104    #[serde(serialize_with = "dec_out")]
105    pub volume: Decimal,
106}
107
108/// An order book: the answer of `GET /md/v2/orderbooks/{exchange}/{symbol}` and the message of the order book
109/// subscription.
110#[derive(Debug, Clone, Default, Deserialize, Serialize)]
111pub struct OrderBook {
112    /// Bids, best first.
113    #[serde(default)]
114    pub bids: Vec<BookLevel>,
115    /// Asks, best first.
116    #[serde(default)]
117    pub asks: Vec<BookLevel>,
118    /// Time in Unix milliseconds. The REST answer names it `msTimestamp`, the stream `ms_timestamp`.
119    #[serde(default, alias = "msTimestamp")]
120    pub ms_timestamp: Option<i64>,
121    /// `true` for data from the history (the first message of a subscription), `false` for new events.
122    #[serde(default)]
123    pub existing: Option<bool>,
124}
125
126/// A candle of `GET /md/v2/history` and of the candle subscription.
127#[derive(Debug, Clone, Default, Deserialize, Serialize)]
128pub struct Bar {
129    /// Open time, Unix seconds.
130    #[serde(default)]
131    pub time: i64,
132    /// Open.
133    #[serde(default, serialize_with = "dec_out")]
134    pub open: Decimal,
135    /// High.
136    #[serde(default, serialize_with = "dec_out")]
137    pub high: Decimal,
138    /// Low.
139    #[serde(default, serialize_with = "dec_out")]
140    pub low: Decimal,
141    /// Close.
142    #[serde(default, serialize_with = "dec_out")]
143    pub close: Decimal,
144    /// Volume, as the broker reports it.
145    #[serde(default, serialize_with = "dec_out")]
146    pub volume: Decimal,
147}
148
149/// The answer of `GET /md/v2/history`: candles and the Unix times of the neighbouring pages.
150#[derive(Debug, Clone, Default, Deserialize, Serialize)]
151pub struct HistoryResponse {
152    /// The candles, oldest first.
153    #[serde(default)]
154    pub history: Vec<Bar>,
155    /// Time of the next candle after the range, if there is one.
156    #[serde(default)]
157    pub next: Option<i64>,
158    /// Time of the candle before the range, if there is one.
159    #[serde(default)]
160    pub prev: Option<i64>,
161}
162
163/// A trade of the market: the item of `GET /md/v2/Securities/{exchange}/{symbol}/alltrades` and the message of
164/// the all trades subscription.
165#[derive(Debug, Clone, Default, Deserialize, Serialize)]
166pub struct MarketTradeRecord {
167    /// The id of the trade.
168    #[serde(default)]
169    pub id: Option<i64>,
170    /// The number of the order of the trade.
171    #[serde(default)]
172    pub orderno: Option<String>,
173    /// The ticker.
174    #[serde(default)]
175    pub symbol: Option<String>,
176    /// The trading mode.
177    #[serde(default)]
178    pub board: Option<String>,
179    /// The quantity, as the broker reports it.
180    #[serde(default, serialize_with = "dec_out")]
181    pub qty: Decimal,
182    /// The price.
183    #[serde(default, serialize_with = "dec_out")]
184    pub price: Decimal,
185    /// The time of the trade, UTC text.
186    #[serde(default)]
187    pub time: Option<String>,
188    /// The time of the trade, Unix milliseconds.
189    #[serde(default)]
190    pub timestamp: Option<i64>,
191    /// `buy` or `sell`: the side of the aggressor.
192    #[serde(default)]
193    pub side: Option<String>,
194    /// Open interest.
195    #[serde(default)]
196    pub oi: Option<i64>,
197    /// `true` for data from the history, `false` for new events.
198    #[serde(default)]
199    pub existing: Option<bool>,
200}
201
202/// The answer of `GET /md/v2/Securities/{exchange}/{symbol}/alltrades/history`: a page of trades and their total.
203#[derive(Debug, Clone, Default, Deserialize, Serialize)]
204pub struct AllTradesHistory {
205    /// How many trades the query matches in all.
206    #[serde(default)]
207    pub total: Option<i64>,
208    /// The page.
209    #[serde(default)]
210    pub list: Vec<MarketTradeRecord>,
211}
212
213/// A quotation: the item of `GET /md/v2/Securities/{symbols}/quotes` and the message of the quotes
214/// subscription.
215#[derive(Debug, Clone, Default, Deserialize, Serialize)]
216pub struct QuoteRecord {
217    /// The ticker.
218    #[serde(default)]
219    pub symbol: String,
220    /// `MOEX` or `SPBX`.
221    #[serde(default)]
222    pub exchange: Option<String>,
223    /// The last price.
224    #[serde(default, serialize_with = "dec_out_opt")]
225    pub last_price: Option<Decimal>,
226    /// The best ask.
227    #[serde(default, serialize_with = "dec_out_opt")]
228    pub ask: Option<Decimal>,
229    /// The best bid.
230    #[serde(default, serialize_with = "dec_out_opt")]
231    pub bid: Option<Decimal>,
232    /// The number of lots at the best ask.
233    #[serde(default, serialize_with = "dec_out_opt")]
234    pub ask_vol: Option<Decimal>,
235    /// The number of lots at the best bid.
236    #[serde(default, serialize_with = "dec_out_opt")]
237    pub bid_vol: Option<Decimal>,
238    /// The time of the order book the bid and ask come from, Unix milliseconds.
239    #[serde(default)]
240    pub ob_ms_timestamp: Option<i64>,
241    /// The size of the lot.
242    #[serde(default, serialize_with = "dec_out_opt")]
243    pub lotsize: Option<Decimal>,
244}
245
246// ─── orders ───────────────────────────────────────────────────────────────────
247
248/// An order of the portfolio: the item of `GET /md/v2/Clients/{exchange}/{portfolio}/orders`, the answer of the
249/// call for one order and the message of the orders subscription.
250#[derive(Debug, Clone, Default, Deserialize, Serialize)]
251pub struct OrderRecord {
252    /// The number of the order at the exchange. Text, though it looks like a number.
253    #[serde(default)]
254    pub id: String,
255    /// The ticker.
256    #[serde(default)]
257    pub symbol: String,
258    /// The trading mode.
259    #[serde(default)]
260    pub board: Option<String>,
261    /// `MOEX` or `SPBX`.
262    #[serde(default)]
263    pub exchange: Option<String>,
264    /// The portfolio.
265    #[serde(default)]
266    pub portfolio: Option<String>,
267    /// The comment of the order (up to 100 characters). The connector keeps the client order id here.
268    #[serde(default)]
269    pub comment: Option<String>,
270    /// `limit` or `market`.
271    #[serde(default, rename = "type")]
272    pub kind: Option<String>,
273    /// `buy` or `sell`.
274    #[serde(default)]
275    pub side: Option<String>,
276    /// `working`, `filled`, `canceled` or `rejected`.
277    #[serde(default)]
278    pub status: Option<String>,
279    /// When the order was placed, UTC text.
280    #[serde(default, rename = "transTime")]
281    pub trans_time: Option<String>,
282    /// When the status last changed, UTC text.
283    #[serde(default, rename = "updateTime")]
284    pub update_time: Option<String>,
285    /// The ordered quantity in pieces.
286    #[serde(default, rename = "qtyUnits", serialize_with = "dec_out_opt")]
287    pub qty_units: Option<Decimal>,
288    /// The ordered quantity in lots.
289    #[serde(default, serialize_with = "dec_out_opt")]
290    pub qty: Option<Decimal>,
291    /// The filled quantity in pieces.
292    #[serde(default, rename = "filledQtyUnits", serialize_with = "dec_out_opt")]
293    pub filled_qty_units: Option<Decimal>,
294    /// The filled quantity in lots.
295    #[serde(default, serialize_with = "dec_out_opt")]
296    pub filled: Option<Decimal>,
297    /// The price (empty for a market order).
298    #[serde(default, serialize_with = "dec_out_opt")]
299    pub price: Option<Decimal>,
300    /// The time in force: `oneday`, `immediateorcancel`, `fillorkill`, `attheclose`, `goodtillcancelled`,
301    /// `bookorcancel`.
302    #[serde(default, rename = "timeInForce")]
303    pub time_in_force: Option<String>,
304    /// `true` for data from the history (the first messages of a subscription), `false` for new events.
305    #[serde(default)]
306    pub existing: Option<bool>,
307}
308
309/// A stop order of the portfolio: the item of `GET /md/v2/Clients/{exchange}/{portfolio}/stoporders`, the answer
310/// of the call for one stop order and the message of the stop orders subscription.
311#[derive(Debug, Clone, Default, Deserialize, Serialize)]
312pub struct StopOrderRecord {
313    /// The number of the stop order. Text.
314    #[serde(default)]
315    pub id: String,
316    /// The number of the order that the stop order made at the exchange when it triggered.
317    #[serde(default, rename = "exchangeOrderId")]
318    pub exchange_order_id: Option<String>,
319    /// The ticker.
320    #[serde(default)]
321    pub symbol: String,
322    /// The trading mode.
323    #[serde(default)]
324    pub board: Option<String>,
325    /// `MOEX` or `SPBX`.
326    #[serde(default)]
327    pub exchange: Option<String>,
328    /// The portfolio.
329    #[serde(default)]
330    pub portfolio: Option<String>,
331    /// The comment (up to 100 characters). The connector keeps the client order id here.
332    #[serde(default)]
333    pub comment: Option<String>,
334    /// `stop` (a market order on trigger) or `stoplimit`.
335    #[serde(default, rename = "type")]
336    pub kind: Option<String>,
337    /// `buy` or `sell`.
338    #[serde(default)]
339    pub side: Option<String>,
340    /// The trigger condition: `more`, `less`, `moreorequal` or `lessorequal`.
341    #[serde(default)]
342    pub condition: Option<String>,
343    /// `working`, `filled`, `canceled` or `rejected`.
344    #[serde(default)]
345    pub status: Option<String>,
346    /// When the stop order was placed, UTC text.
347    #[serde(default, rename = "transTime")]
348    pub trans_time: Option<String>,
349    /// When the stop order ends, UTC text.
350    #[serde(default, rename = "endTime")]
351    pub end_time: Option<String>,
352    /// The reason, if the stop order was rejected.
353    #[serde(default)]
354    pub error: Option<String>,
355    /// The ordered quantity in pieces.
356    #[serde(default, rename = "qtyUnits", serialize_with = "dec_out_opt")]
357    pub qty_units: Option<Decimal>,
358    /// The ordered quantity in lots.
359    #[serde(default, serialize_with = "dec_out_opt")]
360    pub qty: Option<Decimal>,
361    /// The limit price of a stop-limit order.
362    #[serde(default, serialize_with = "dec_out_opt")]
363    pub price: Option<Decimal>,
364    /// The trigger price.
365    #[serde(default, rename = "stopPrice", serialize_with = "dec_out_opt")]
366    pub stop_price: Option<Decimal>,
367    /// `true` for data from the history, `false` for new events.
368    #[serde(default)]
369    pub existing: Option<bool>,
370}
371
372/// A trade of the portfolio (a fill of one of its orders): the item of
373/// `GET /md/v2/Clients/{exchange}/{portfolio}/trades` and the message of the trades subscription.
374#[derive(Debug, Clone, Default, Deserialize, Serialize)]
375pub struct TradeRecord {
376    /// The id of the trade.
377    #[serde(default)]
378    pub id: String,
379    /// The number of the order.
380    #[serde(default)]
381    pub orderno: Option<String>,
382    /// The comment of the order (the connector keeps the client order id here).
383    #[serde(default)]
384    pub comment: Option<String>,
385    /// The ticker.
386    #[serde(default)]
387    pub symbol: String,
388    /// `MOEX` or `SPBX`.
389    #[serde(default)]
390    pub exchange: Option<String>,
391    /// The time of the trade, UTC text.
392    #[serde(default)]
393    pub date: Option<String>,
394    /// The trading mode.
395    #[serde(default)]
396    pub board: Option<String>,
397    /// The quantity in pieces.
398    #[serde(default, rename = "qtyUnits", serialize_with = "dec_out_opt")]
399    pub qty_units: Option<Decimal>,
400    /// The quantity in lots.
401    #[serde(default, serialize_with = "dec_out_opt")]
402    pub qty: Option<Decimal>,
403    /// The price of one piece.
404    #[serde(default, serialize_with = "dec_out")]
405    pub price: Decimal,
406    /// `buy` or `sell`.
407    #[serde(default)]
408    pub side: Option<String>,
409    /// The commission (empty on the futures market).
410    #[serde(default, serialize_with = "dec_out_opt")]
411    pub commission: Option<Decimal>,
412    /// `true` for data from the history, `false` for new events.
413    #[serde(default)]
414    pub existing: Option<bool>,
415}
416
417/// An instrument or money position: the item of `GET /md/v2/Clients/{exchange}/{portfolio}/positions` and the
418/// message of the positions subscription.
419#[derive(Debug, Clone, Default, Deserialize, Serialize)]
420pub struct PositionRecord {
421    /// The ticker (or the currency code of a money position).
422    #[serde(default)]
423    pub symbol: String,
424    /// `MOEX` or `SPBX`.
425    #[serde(default)]
426    pub exchange: Option<String>,
427    /// The portfolio.
428    #[serde(default)]
429    pub portfolio: Option<String>,
430    /// The average price.
431    #[serde(default, rename = "avgPrice", serialize_with = "dec_out_opt")]
432    pub avg_price: Option<Decimal>,
433    /// The quantity in pieces (the amount, for money).
434    #[serde(default, rename = "qtyUnits", serialize_with = "dec_out_opt")]
435    pub qty_units: Option<Decimal>,
436    /// The size of the lot.
437    #[serde(default, rename = "lotSize", serialize_with = "dec_out_opt")]
438    pub lot_size: Option<Decimal>,
439    /// The quantity in lots.
440    #[serde(default, serialize_with = "dec_out_opt")]
441    pub qty: Option<Decimal>,
442    /// `true` for money (a currency balance), `false` for an instrument.
443    #[serde(default, rename = "isCurrency")]
444    pub is_currency: Option<bool>,
445    /// The unrealised profit or loss.
446    #[serde(default, rename = "unrealisedPl", serialize_with = "dec_out_opt")]
447    pub unrealised_pl: Option<Decimal>,
448    /// The value of the position in the settlement currency by its current price.
449    #[serde(default, rename = "currentVolume", serialize_with = "dec_out_opt")]
450    pub current_volume: Option<Decimal>,
451    /// `true` for data from the history, `false` for new events.
452    #[serde(default)]
453    pub existing: Option<bool>,
454}
455
456/// The money of a currency in the summary.
457#[derive(Debug, Clone, Default, Deserialize, Serialize)]
458pub struct BuyingPowerByCurrency {
459    /// The currency.
460    #[serde(default)]
461    pub currency: String,
462    /// The buying power in the currency.
463    #[serde(default, rename = "buyingPower", serialize_with = "dec_out_opt")]
464    pub buying_power: Option<Decimal>,
465}
466
467/// The summary of the portfolio: `GET /md/v2/Clients/{exchange}/{portfolio}/summary` and the message of the
468/// summaries subscription.
469#[derive(Debug, Clone, Default, Deserialize, Serialize)]
470pub struct SummaryRecord {
471    /// The buying power.
472    #[serde(default, rename = "buyingPower", serialize_with = "dec_out_opt")]
473    pub buying_power: Option<Decimal>,
474    /// The evaluation of the portfolio.
475    #[serde(
476        default,
477        rename = "portfolioEvaluation",
478        serialize_with = "dec_out_opt"
479    )]
480    pub portfolio_evaluation: Option<Decimal>,
481    /// The commission.
482    #[serde(default, serialize_with = "dec_out_opt")]
483    pub commission: Option<Decimal>,
484    /// The buying power by currency.
485    #[serde(default, rename = "buyingPowerByCurrency")]
486    pub buying_power_by_currency: Vec<BuyingPowerByCurrency>,
487}
488
489// ─── commands ─────────────────────────────────────────────────────────────────
490
491/// The instrument of an order command.
492#[derive(Debug, Clone, Serialize, Deserialize)]
493pub struct InstrumentRef {
494    /// The ticker.
495    pub symbol: String,
496    /// `MOEX` or `SPBX`.
497    pub exchange: String,
498    /// The trading mode (board), for example `TQBR`.
499    #[serde(rename = "instrumentGroup", skip_serializing_if = "Option::is_none")]
500    pub instrument_group: Option<String>,
501}
502
503/// The portfolio of an order command.
504#[derive(Debug, Clone, Serialize, Deserialize)]
505pub struct UserRef {
506    /// The portfolio.
507    pub portfolio: String,
508}
509
510/// The body of a limit order command (`POST .../orders/actions/limit` and the change `PUT .../limit/{orderId}`).
511#[derive(Debug, Clone, Serialize)]
512pub struct LimitOrderRequest {
513    /// `buy` or `sell`.
514    pub side: String,
515    /// The quantity in lots.
516    pub quantity: i64,
517    /// The price.
518    #[serde(serialize_with = "dec_out")]
519    pub price: Decimal,
520    /// The instrument.
521    pub instrument: InstrumentRef,
522    /// The portfolio.
523    pub user: UserRef,
524    /// The comment of the order (up to 100 characters).
525    #[serde(skip_serializing_if = "Option::is_none")]
526    pub comment: Option<String>,
527    /// The time in force: `oneday`, `immediateorcancel`, `fillorkill`, `attheclose`, `goodtillcancelled`,
528    /// `bookorcancel`. The broker takes `oneday` when it is left out.
529    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
530    pub time_in_force: Option<String>,
531    /// Consent to margin (a risk level of the broker) for this order.
532    #[serde(rename = "allowMargin", skip_serializing_if = "Option::is_none")]
533    pub allow_margin: Option<bool>,
534    /// The visible constant part of an iceberg order, in lots.
535    #[serde(rename = "icebergFixed", skip_serializing_if = "Option::is_none")]
536    pub iceberg_fixed: Option<i64>,
537    /// The deviation of the random addition to the visible part of an iceberg order, in percent of the constant part.
538    #[serde(rename = "icebergVariance", skip_serializing_if = "Option::is_none")]
539    pub iceberg_variance: Option<i64>,
540}
541
542/// The body of a market order command (`POST .../orders/actions/market` and `PUT .../market/{orderId}`).
543#[derive(Debug, Clone, Serialize)]
544pub struct MarketOrderRequest {
545    /// `buy` or `sell`.
546    pub side: String,
547    /// The quantity in lots.
548    pub quantity: i64,
549    /// The instrument.
550    pub instrument: InstrumentRef,
551    /// The portfolio.
552    pub user: UserRef,
553    /// The comment of the order (up to 100 characters).
554    #[serde(skip_serializing_if = "Option::is_none")]
555    pub comment: Option<String>,
556    /// The time in force (see [`LimitOrderRequest::time_in_force`]).
557    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
558    pub time_in_force: Option<String>,
559    /// Consent to margin for this order.
560    #[serde(rename = "allowMargin", skip_serializing_if = "Option::is_none")]
561    pub allow_margin: Option<bool>,
562}
563
564/// The body of a stop order command: `POST .../orders/actions/stop` (a market order on trigger) and
565/// `.../stopLimit` (a limit order on trigger, with `price`), and the changes `PUT .../stop/{id}` and
566/// `.../stopLimit/{id}`.
567#[derive(Debug, Clone, Serialize)]
568pub struct StopOrderRequest {
569    /// `buy` or `sell`.
570    pub side: String,
571    /// When the stop order triggers: `more`, `less`, `moreorequal` or `lessorequal` than the trigger price.
572    pub condition: String,
573    /// The trigger price.
574    #[serde(rename = "triggerPrice", serialize_with = "dec_out")]
575    pub trigger_price: Decimal,
576    /// The end of the stop order, Unix seconds.
577    #[serde(rename = "stopEndUnixTime", skip_serializing_if = "Option::is_none")]
578    pub stop_end_unix_time: Option<i64>,
579    /// The price of the order made on trigger (a stop-limit order only).
580    #[serde(
581        skip_serializing_if = "Option::is_none",
582        serialize_with = "dec_out_opt"
583    )]
584    pub price: Option<Decimal>,
585    /// The quantity in lots.
586    pub quantity: i64,
587    /// The instrument.
588    pub instrument: InstrumentRef,
589    /// The portfolio.
590    pub user: UserRef,
591    /// The comment (up to 100 characters).
592    #[serde(skip_serializing_if = "Option::is_none")]
593    pub comment: Option<String>,
594    /// The time in force of the order made on trigger (a stop-limit order only).
595    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
596    pub time_in_force: Option<String>,
597    /// Consent to margin for the order made on trigger.
598    #[serde(rename = "allowMargin", skip_serializing_if = "Option::is_none")]
599    pub allow_margin: Option<bool>,
600    /// `true` (the broker default) to start watching the price at once.
601    #[serde(skip_serializing_if = "Option::is_none")]
602    pub activate: Option<bool>,
603}
604
605/// The answer to an order command: the number of the order the broker made.
606#[derive(Debug, Clone, Default, Deserialize, Serialize)]
607pub struct OrderCommandResponse {
608    /// The text of the answer (`success`).
609    #[serde(default)]
610    pub message: Option<String>,
611    /// The number of the order or stop order. Text.
612    #[serde(default, rename = "orderNumber")]
613    pub order_number: Option<String>,
614}