OrderBookSpreadWidener
Симметричный расширитель спреда для QuoteChangeMessage. Сворачивает каждый необработанный уровень внутри нового (более широкого) разворота на новый видимый лучший уровень; проходят внешние уровни. Считывает текущее состояние необработанной книги из OrderBookSnapshotHolder, который поддерживает вызывающая сторона, и выдает кадры приращения после начального SnapshotComplete.
Конструкторы
public OrderBookSpreadWidener(decimal percent)
orderBookSpreadWidener = OrderBookSpreadWidener(percent)
Инициализирует новый экземпляр класса OrderBookSpreadWidener.
- percent
- Расширение половинного спреда, в процентах. Неположительное значение отключает расширение.
Свойства
public bool IsEnabled { get; }
value = orderBookSpreadWidener.IsEnabled
Если процент положительный, то применяется расширение.
public decimal Percent { get; }
value = orderBookSpreadWidener.Percent
Полурасширение, в процентах.
Методы
public QuoteChangeMessage Apply(QuoteChangeMessage msg, OrderBookSnapshotHolder holder, decimal? priceStep)
result = orderBookSpreadWidener.Apply(msg, holder, priceStep)
Reads the current raw book from (the caller must have applied to the holder first) and rewrites it as either a full SnapshotComplete (first call for this security) or an Increment carrying only the changes against the previously-emitted collapsed view.
- msg
- Incoming order book change message.
- holder
- Holder of the current raw order book state.
- priceStep
- Price step of the security, so the widened best lands on a price that can be traded. when the step is unknown, and the widened price is then left as the arithmetic produced it.
Возвращает: Collapsed message; the original message when widening is disabled or no raw snapshot is available; or if is .
public QuoteChangeMessage Collapse(SecurityId securityId, OrderBookSnapshotHolder holder, decimal? priceStep)
result = orderBookSpreadWidener.Collapse(securityId, holder, priceStep)
Returns the current collapsed view of as a fresh SnapshotComplete. Pure read — does not touch the diff-state used by Decimal}). Useful for replying to a new subscriber without re-emitting deltas from before their subscription.
- securityId
- Security to build the collapsed snapshot for.
- holder
- Holder of the current raw order book state.
- priceStep
- Price step of the security, so the widened best lands on a price that can be traded. when the step is unknown, and the widened price is then left as the arithmetic produced it.
Возвращает: Collapsed snapshot, or when widening is disabled or no raw snapshot is available for .
private static QuoteChange[] Diff(Dictionary<decimal, QuoteChange> prev, QuoteChange[] new, Dictionary<decimal, QuoteChange> next)
result = OrderBookSpreadWidener.Diff(prev, new, next)
One walk produces both the changes against and the state to keep for the next call, so the emitted view is never built twice.
public void ResetSnapshot(SecurityId securityId)
orderBookSpreadWidener.ResetSnapshot(securityId)
Удаляет состояние различия, используемое для выдачи приращений, заставляя следующий OrderBookSnapshotHolder) выдавать новый SnapshotComplete.
- securityId
- финансовый инструмент для сброса или сброс всех финансовых инструментов.
private static decimal Snap(decimal price, decimal? priceStep, bool down)
result = OrderBookSpreadWidener.Snap(price, priceStep, down)
Moves the widened price onto the step grid, away from the market: down for a bid, up for an ask. Rounding to the nearest step instead would move it the other way half the time and quote a spread tighter than the one asked for, which is the thing widening exists to stop.