nautilus_tardis/http/
models.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use chrono::{DateTime, Utc};
17use serde::Deserialize;
18use ustr::Ustr;
19
20use crate::{
21    enums::{Exchange, InstrumentType, OptionType},
22    parse::deserialize_uppercase,
23};
24
25#[derive(Debug, Clone, Deserialize)]
26#[serde(rename_all = "camelCase")]
27/// The changes info returned by the exchanges API.
28pub struct InstrumentChanges {
29    /// Date in ISO format.
30    pub until: DateTime<Utc>,
31    /// The minimum price increment (tick size).
32    #[serde(skip_serializing_if = "Option::is_none")]
33    #[serde(default)]
34    pub price_increment: Option<f64>,
35    /// The minimum size increment.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    #[serde(default)]
38    pub amount_increment: Option<f64>,
39    /// The instrument contract multiplier (only for derivatives).
40    #[serde(skip_serializing_if = "Option::is_none")]
41    #[serde(default)]
42    pub contract_multiplier: Option<f64>,
43}
44
45#[derive(Debug, Clone, Deserialize)]
46#[serde(rename_all = "camelCase")]
47/// The metadata of a particular instrument.
48/// See <https://docs.tardis.dev/api/instruments-metadata-api>.
49pub struct InstrumentInfo {
50    /// The instrument symbol.
51    #[serde(deserialize_with = "deserialize_uppercase")]
52    pub id: Ustr,
53    /// The instrument exchange.
54    pub exchange: Exchange,
55    /// The instrument base currency (normalized, e.g., BTC for `BitMEX`, not XBT).
56    pub base_currency: Ustr,
57    /// The instrument quote currency (normalized, e.g., BTC for `BitMEX`, not XBT).
58    pub quote_currency: Ustr,
59    /// The instrument type e.g., spot, perpetual, future, option.
60    #[serde(rename = "type")]
61    pub instrument_type: InstrumentType,
62    /// If the instrument is actively listed.
63    pub active: bool,
64    /// The available from date in ISO format.
65    pub available_since: DateTime<Utc>,
66    /// The available to date in ISO format.
67    pub available_to: Option<DateTime<Utc>>,
68    /// The contract expiry date in ISO format (applicable to futures and options).
69    pub expiry: Option<DateTime<Utc>>,
70    /// The instrument price increment.
71    pub price_increment: f64,
72    /// The instrument size increment.
73    pub amount_increment: f64,
74    /// The minimum tradeable size for the instrument.
75    pub min_trade_amount: f64,
76    /// The instrument maker fee: consider it as illustrative only, as it depends in practice on account traded volume levels, different categories, VIP levels, owning exchange currency etc.
77    pub maker_fee: f64,
78    /// The instrument taker fee: consider it as illustrative only, as it depends in practice on account traded volume levels, different categories, VIP levels, owning exchange currency etc.
79    pub taker_fee: f64,
80    /// If the instrument is inverse (only for derivatives such as futures and perpetual swaps).
81    pub inverse: Option<bool>,
82    /// The instrument contract multiplier (only for derivatives).
83    pub contract_multiplier: Option<f64>,
84    /// If the instrument is quanto (only for quanto instruments).
85    pub quanto: Option<bool>,
86    /// The instrument settlement currency (only for Quanto instruments where settlement currency is different both base and quote currency).
87    pub settlement_currency: Option<Ustr>,
88    /// The instrument strike price (only for options).
89    pub strike_price: Option<f64>,
90    /// The option type (only for options).
91    pub option_type: Option<OptionType>,
92    /// The changes for the instrument (best-effort basis from Tardis).
93    pub changes: Option<Vec<InstrumentChanges>>,
94}