Expand description
Instrument identifiers and clocks. Conversions never touch the network.
§Examples
use brokapi_core::{InstrumentId, InstrumentKey, NativeId};
use brokapi_tbank::ids::{id_from_parts, instrument_ref};
// A broker message names an instrument by uid, figi or ticker and class code.
let id = id_from_parts("uid-sber", "BBG004730N88", "SBER", "TQBR");
assert_eq!(id.key, InstrumentKey::new("SBER", "TQBR"));
// The uid wins: it does not change when a ticker is renamed.
assert_eq!(id.native, NativeId::Uid("uid-sber".into()));
// The same id as the string a request carries in `instrument_id`.
assert_eq!(instrument_ref(&id), "uid-sber");Functions§
- id_
from_ parts - Canonical id from the fields a broker message carries. Prefers the uid (stable across tickers).
- instrument_
ref - Value for the
instrument_idrequest fields:figi,instrument_uidorticker_classcode. - instrument_
request - The directory request for an [
InstrumentId]: by uid, figi, or ticker with class code. - matches
truewhen a broker message (identified by any of uid/figi/ticker+class) is aboutid.- money_
of - A [
MoneyValue] as [Money], exactly. The currency is ignored: read it from the message. - nanos_
to_ proto - Converts nanoseconds since the Unix epoch to a protobuf
Timestamp. Negative times keep a non-negativenanospart, as protobuf requires. - price_
of_ money - A [
MoneyValue] as a [Price], exactly. The currency is ignored. - price_
of_ quotation - A [
Quotation] as a [Price], exactly (units and nano, nof64). - price_
to_ quotation - A [
Price] as the [Quotation] a request carries, exactly. - proto_
to_ nanos - Converts a protobuf
Timestampto nanoseconds since the Unix epoch. Overflow saturates. - qty_
of_ quotation - A [
Quotation] as a [Qty], exactly. - require_
native - Refuses an [
InstrumentId] whose [NativeId] is of another broker’s kind (SymbolMicis the Finam form), before anything is sent. - stamps
- Reception timestamps with the broker time attached when the message has one.
- wall_
nanos - Current wall-clock time in nanoseconds since the Unix epoch.