Table of Contents

Namespace Virtufin.Core.Position

Classes

FixedPointArithmetic

Base- and precision-aware arithmetic for IFixedPointAmount, following the standard fixed-point algorithms (see https://en.wikipedia.org/wiki/Fixed-point_arithmetic).

PrecisionMismatchException

Thrown when two IFixedPointAmount values are combined by an operation that requires a common scaling factor (equality, ordering, addition, subtraction) but their base and/or precision differ.

Structs

BinaryAmount

Fixed-point amount with base 2 (binary scaling), stored as a whole part, a fractional part, and a precision (number of binary fraction digits). The represented value is Whole + Fraction / 2^N.

DecimalAmount

Fixed-point decimal amount with base 10, stored as a whole part, a fractional part, and a precision (number of fractional digits). Backed by long for the whole part and ulong for the fractional part so values up to roughly 10^18 are representable without floating-point error.

DecimalQuantity<U>

A DecimalAmount paired with an IUnit. Formats as "{Amount} {Unit}".

Interfaces

IAmount

Non-generic root for any typed monetary or physical quantity. Precision is the scale of the value's fractional part; implementations that represent a scale-free quantity (e.g. a whole count) use 0.

IAmount<TValue>

A typed monetary or physical quantity. TValue is the underlying representation (e.g. a tuple of whole and fractional parts for fixed-point DecimalAmount).

IAsCardinal<TCardinal>

Bridges between an IAmount<TValue> and a single canonical integer representation. Used to implement arithmetic on amounts whose parts live in different fields (whole vs. fractional).

IFixedPointAmount

A fixed-point amount: a value stored as a whole part and a fractional part interpreted in a given Base with Precision fractional digits. The represented value is Whole + Fraction / Base^Precision, or equivalently ToCardinal() / Base^Precision.

IFixedPointAmount<TSelf>

Self-referential fixed-point amount, so generic arithmetic can construct a result of the concrete type and read the type's fixed base statically.

IL2OrderBookDiff<A, L>

A Level-2 depth diff: a set of price-level mutations to apply on top of an IL2OrderBook<A, L>. A size of zero removes the level.

IL2OrderBookSnapshot<A, L>

A full Level-2 depth snapshot: bootstraps (or re-bootstraps) an IL2OrderBook<A, L> wholesale.

IL2OrderBook<A, L>

A Level-2 (market-by-price) order book: aggregated price levels per side. A is the depth (size) amount type and L the level (price) amount type.

IOrderBook

Non-generic marker for a maintained order book. The concrete shapes are IL2OrderBook<A, L> (aggregated price levels) and IL3OrderBook<O,T,A,L> (individual orders).

IOrderBookUpdater<TBook, S, D>

Applies venue snapshot/diff data to a maintained TBook. S is the snapshot data type and D the diff data type.

IQuantity<TAmount, TUnit>

An IAmount<TValue> tagged with an IUnit.

IUnit

Marker for any value that represents a unit of measure (currency, share, barrel, etc.). Implementations must be equality-comparable and printable.

Enums

LimitOrMarketOrder

Order type discriminator.

OrderBookState

Lifecycle of a maintained local order book.

OrderBookUpdateStatus

Outcome of applying one diff to a maintained order book.