pub struct InstrumentInfo {Show 39 fields
pub ticker: String,
pub boards: Vec<InstrumentBoard>,
pub short_name: Option<String>,
pub display_name: Option<String>,
pub instrument_type_name: Option<String>,
pub isin: Option<String>,
pub registration_code: Option<String>,
pub issuer_name: Option<String>,
pub trading_currency: Option<String>,
pub face_value: Option<Decimal>,
pub scale: Option<u32>,
pub minimum_step: Option<Decimal>,
pub accrued_int: Option<Decimal>,
pub currency_step_price: Option<String>,
pub settle_code: Option<String>,
pub instrument_type: Option<String>,
pub settlement_currency: Option<String>,
pub settlement_date: Option<String>,
pub maturity_date: Option<String>,
pub lot_size: Option<Decimal>,
pub is_qualified_only: Option<bool>,
pub is_can_short: Option<bool>,
pub base_asset: Option<String>,
pub available_for_unqualified: Option<bool>,
pub step_price: Option<Decimal>,
pub is_bcs_product: Option<bool>,
pub logo_link: Option<String>,
pub coupons_per_year: Option<u32>,
pub coupon_rate: Option<f64>,
pub next_coupon: Option<String>,
pub complex_product: Option<f64>,
pub base_asset_future: Option<String>,
pub sub_type: Option<String>,
pub business_sector: Option<String>,
pub dividend_yield: Option<f64>,
pub target_price: Option<Decimal>,
pub mktcap: Option<Decimal>,
pub is_blocked: Option<bool>,
pub primary_board: String,
}Expand description
Reference data of one instrument, as the information service returns it.
Only ticker is always there. Every other field is optional, because the broker fills the ones that fit
the instrument type (a coupon rate only for a bond, a base asset only for a derivative). Do not trade
on a default: see InstrumentInfo::trading_params_for_board for what is assumed when a field is missing.
§Examples
use brokapi_bcs_protocol::http::models::InstrumentInfo;
let info: InstrumentInfo = serde_json::from_str(
r#"{"ticker":"SBER","boards":[{"classCode":"TQBR","exchange":"MOEX"}],"lotSize":1,
"minimumStep":0.01,"scale":2,"tradingCurrency":"RUB","primaryBoard":"TQBR"}"#,
)?;
let params = info.trading_params_primary().expect("a board");
assert_eq!(params.class_code, "TQBR");
assert_eq!(params.price_step, dec!(0.01));Fields§
§ticker: StringTicker of the instrument.
boards: Vec<InstrumentBoard>The boards (class codes and exchanges) where the instrument trades.
short_name: Option<String>Short name.
display_name: Option<String>Name for display.
instrument_type_name: Option<String>Instrument type in the broker spelling (JSON field type): CURRENCY, STOCK, FOREIGN_STOCK, BONDS, NOTES, DEPOSITARY_RECEIPTS, EURO_BONDS, MUTUAL_FUNDS, ETF, FUTURES, OPTIONS, GOODS, INDICES.
isin: Option<String>ISIN code.
registration_code: Option<String>State registration code of the issue.
issuer_name: Option<String>Name of the issuer.
trading_currency: Option<String>Currency of the instrument (the trading currency).
face_value: Option<Decimal>Face value (nominal), for bonds.
scale: Option<u32>Precision: the number of decimal places of the price.
minimum_step: Option<Decimal>Minimum price step. A price you send must be a whole number of steps.
accrued_int: Option<Decimal>Accrued coupon income at the settlement date.
currency_step_price: Option<String>Currency of the price step value.
settle_code: Option<String>Default settlement code.
instrument_type: Option<String>Instrument type in the broker spelling (JSON field instrumentType). Same values as InstrumentInfo::instrument_type_name.
settlement_currency: Option<String>Settlement currency.
settlement_date: Option<String>Settlement date, kept as the text the broker sends (a date-time).
maturity_date: Option<String>Maturity (redemption) date, kept as the text the broker sends.
lot_size: Option<Decimal>Size of a lot: pieces in one lot. Order quantities of the API are in pieces, not lots.
is_qualified_only: Option<bool>true for an instrument only for qualified investors.
is_can_short: Option<bool>true if a short sale is available.
base_asset: Option<String>Name of the base asset of a derivative contract.
available_for_unqualified: Option<bool>true if an unqualified investor may trade the instrument.
step_price: Option<Decimal>Cost of one price step, in the currency of the step price.
is_bcs_product: Option<bool>true for a product of the broker itself.
logo_link: Option<String>Link to a logo. Deprecated by the broker.
coupons_per_year: Option<u32>Number of coupons per year, for bonds.
coupon_rate: Option<f64>Coupon rate in percent per year, for bonds.
next_coupon: Option<String>Date of the next coupon payment, kept as the text the broker sends.
complex_product: Option<f64>Marking of a complex product by the knowledge tests (the broker docs call it “marking by tests”).
base_asset_future: Option<String>Type of the base asset, for futures.
sub_type: Option<String>Name of the instrument subtype.
business_sector: Option<String>Business sector of the issuer.
dividend_yield: Option<f64>Dividend yield: the stated annual dividend divided by the closing price.
target_price: Option<Decimal>Analyst target price.
mktcap: Option<Decimal>Market capitalisation.
is_blocked: Option<bool>true if the class is blocked for trading.
primary_board: StringClass code of the primary board. Empty if the broker did not send it.
Implementations§
Source§impl InstrumentInfo
impl InstrumentInfo
Sourcepub fn trading_params_for_board(
&self,
class_code: &str,
) -> Option<TradingParamsSnapshot>
pub fn trading_params_for_board( &self, class_code: &str, ) -> Option<TradingParamsSnapshot>
Builds TradingParamsSnapshot for one board (class code).
Returns None when the instrument lists boards and class_code is not one of them. If the
instrument lists no boards at all, any class_code is accepted.
A missing field is replaced by a default, not reported: lot size 1, price step 0.01, price
step value equal to the step, scale 2, currency RUB. The defaults are a guess. Check the
fields of InstrumentInfo itself before you trade on them.
§Examples
use brokapi_bcs_protocol::http::models::InstrumentInfo;
let info: InstrumentInfo = serde_json::from_str(
r#"{"ticker":"SBER","boards":[{"classCode":"TQBR","exchange":"MOEX"}],"lotSize":10,"minimumStep":0.05}"#,
)?;
let p = info.trading_params_for_board("TQBR").expect("listed board");
assert_eq!((p.lot_size, p.price_step, p.scale), (dec!(10.0), dec!(0.05), 2)); // scale 2 is a default
assert!(info.trading_params_for_board("SMAL").is_none()); // not a board of this instrumentSourcepub fn trading_params_primary(&self) -> Option<TradingParamsSnapshot>
pub fn trading_params_primary(&self) -> Option<TradingParamsSnapshot>
Builds TradingParamsSnapshot for the primary board of the instrument.
The primary board is InstrumentInfo::primary_board, or the first listed board if that is
empty. Returns None if there is neither. The defaults of
InstrumentInfo::trading_params_for_board apply.
§Examples
use brokapi_bcs_protocol::http::models::InstrumentInfo;
let info: InstrumentInfo = serde_json::from_str(r#"{"ticker":"SBER","primaryBoard":"TQBR"}"#)?;
assert_eq!(info.trading_params_primary().unwrap().class_code, "TQBR");
let nothing: InstrumentInfo = serde_json::from_str(r#"{"ticker":"X"}"#)?;
assert!(nothing.trading_params_primary().is_none());Trait Implementations§
Source§impl Clone for InstrumentInfo
impl Clone for InstrumentInfo
Source§fn clone(&self) -> InstrumentInfo
fn clone(&self) -> InstrumentInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more