Expand description
Lots. T-Bank counts orders, order book levels, trades and candle volumes in LOTS, the library
counts in units of the instrument (see [Qty]). This module is the bridge: the lot size of each
instrument, learned from the directory once and remembered, and the conversions both ways.
The lot size is Instrument.lot of GetInstrumentBy, and lot_size of an order state message of
the order stream. A connector looks it up before the first order or subscription on an
instrument (one GetInstrumentBy, against the quota of that method) and never again.
§Examples
use brokapi_core::Qty;
use brokapi_tbank::lots::{lots_to_qty, pieces_to_lots};
// A lot of SBER is 10 shares: 30 shares are 3 lots, 3 lots are 30 shares.
assert_eq!(pieces_to_lots(Qty::from(30), 10)?, 3);
assert_eq!(lots_to_qty(3, 10), Qty::from(30));
// Not a whole number of lots: refused, never rounded.
assert!(pieces_to_lots(Qty::from(25), 10).is_err());Structs§
- LotBook
- The lot sizes of the instruments this connector has met. Cheap to share behind an
Arc.
Functions§
- event_
instrument - The instrument a market data event is about, if it has one.
- lots_
to_ qty - Lots to units.
- pieces_
to_ lots - Units to lots: the quantity must be a whole number of lots, at least one.
- scale_
book - The levels of a book, in units.
- scale_
candle - The volume of a candle, in units.
- scale_
event - Multiplies the quantities of a market data event by the lot size: the levels of a book, the best levels of a quote, the quantity of a trade, the volume of a candle. Other events stay as they are.
- scale_
trade - The quantity of a trade, in units.