Skip to main content

class_code

Function class_code 

pub fn class_code(id: &InstrumentId) -> Result<String, Error>
Expand description

Returns the class code (trading board, for example TQBR) of an instrument id.

§Errors

[brokapi_core::Error::Config] when the native id is not [NativeId::TickerClass], as in require_ticker_class.

§Examples

use brokapi_bcs::util::class_code;
use brokapi_core::{InstrumentId, InstrumentKey, NativeId};

let sber = InstrumentId::new(
    InstrumentKey::new("SBER", "TQBR"),
    NativeId::TickerClass { ticker: "SBER".into(), class_code: "TQBR".into() },
);
assert_eq!(class_code(&sber).unwrap(), "TQBR");