[][src]Module trade::tick

A module defining types to work with discrete prices and quantities.

On electronic exchanges, prices and sizes do not take continuous real values, but rather take their values on a discrete grid whose step is known as a tick. In other words, the price tick is the smallest possible change of the price of an asset, and the size tick is the smallest possible change of the size of an order.

It is important to represent prices and sizes in ticks and not with fractional values like 100.27.

Indeed, these fractional values could maybe be represented with a floating point numeric type, but then some prices would not be represented exactly and rounded to the nearest representable value, which is problematic because for some assets, even e.g. a 1 cent difference is a lot. They could also be represented with an arbitrary precision numeric type, but this would incur a lot of overhead.

Another problem is that many trading algorithms which involve making numerical computations output floating values, and those values must be rounded to the nearest tick in order to have a valid price / size, so generally the tick size must be carried along anyway.

This module defines utilities for converting between fractional values represented as strings (for exact precision) and values expressed in tick units.

Structs

ConversionError

An error which indicates that the conversion between a string value and a value in tick units has failed.

Tick

An object carrying the number of ticks per unit of something and representative of its tick size.

Enums

Tickable

A value either expressed in tick units or with its unticked string representation.

Type Definitions

TickUnit

Base type for tick units.