Skip to main content

InstrumentInfo

Struct InstrumentInfo 

Source
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: String

Ticker 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: String

Class code of the primary board. Empty if the broker did not send it.

Implementations§

Source§

impl InstrumentInfo

Source

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 instrument
Source

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

Source§

fn clone(&self) -> InstrumentInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstrumentInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for InstrumentInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for InstrumentInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more