Module util
Expand description
Shared helpers: instrument ids, timestamps, decimals.
Functions§
- dec
google.type.Decimal-> [Dec], exactly: the text is parsed as it is, nof64on the way. Empty, absent or unparseable ->None. The grammar of the message allows a sign, a leading or trailing point and an exponent.- dec0
- Like
decbut 0 for absent. - instrument_
from_ symbol - Instrument id from a Finam symbol (
SBER@MISX). A symbol without@gets an empty MIC. - money
google.type.Money-> (currency, amount), exactly.unitsandnanoscarry the sign of the value.- no_
instrument - Placeholder instrument for subscriptions that are not about one instrument (orders, account).
- now_
nanos - Wall clock now, in nanoseconds since the Unix epoch. Gives 0 when the clock is before the epoch.
- price
decas a [Price].- price0
dec0as a [Price].- qty
decas a [Qty].- qty0
dec0as a [Qty].- symbol_
of SBER@MISXfor the Finam API. NeedsNativeId::SymbolMic, no network.- timestamps
- Receive timestamps with the broker time attached when present.
- to_
decimal - A number ->
google.type.Decimal, exactly. The text is plain (Rust never writes an exponent for a decimal), the scale is kept:244.30is sent as"244.30". - to_
money - (currency, amount) ->
google.type.Money, exactly. The reverse ofmoney. - to_
timestamp - Unix nanoseconds -> protobuf timestamp. Negative values give
seconds < 0andnanos >= 0, the protobuf way. - ts_
nanos - Protobuf timestamp -> Unix nanoseconds. Saturates instead of overflowing on absurd values.