Tick Scheme
Defines a scheme for modeling the tick space for various instruments.
class FixedTickScheme
Bases: TickScheme
FixedTickScheme(str name, int price_precision, Price min_tick, Price max_tick, float increment: float | None = None)
Represents a fixed precision tick scheme such as for Forex or Crypto.
- Parameters:
 - Raises: ValueError – If name is not a valid string.
 
increment
The tick scheme price increment.
- Returns: Price
 
next_ask_price(self, double value, int n=0) → Price
Return the price n ask ticks away from value.
If a given price is between two ticks, n=0 will find the nearest ask tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
next_bid_price(self, double value, int n=0) → Price
Return the price n bid ticks away from value.
If a given price is between two ticks, n=0 will find the nearest bid tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
price_precision
The tick scheme price precision.
- Returns: int
 
class TieredTickScheme
Bases: TickScheme
TieredTickScheme(str name, list tiers, int price_precision, int max_ticks_per_tier=100)
Represents a tick scheme where tick levels change based on price level, such as various financial exchanges.
- Parameters:
- name (str) – The name of the tick scheme.
 - tiers (list *[*tuple *(*start , stop , step ) ]) – The tiers for the tick scheme. Should be a list of (start, stop, step) tuples.
 - max_ticks_per_tier (int , default 100) – The maximum number of ticks per tier.
 
 - Raises: ValueError – If name is not a valid string.
 
find_tick_index(self, double value) → int
next_ask_price(self, double value, int n=0) → Price
Return the price n ask ticks away from value.
If a given price is between two ticks, n=0 will find the nearest ask tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
next_bid_price(self, double value, int n=0) → Price
Return the price n bid ticks away from value.
If a given price is between two ticks, n=0 will find the nearest bid tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
ticks
get_tick_scheme(str name) → TickScheme
register_tick_scheme(TickScheme tick_scheme) → void
class FixedTickScheme
Bases: TickScheme
FixedTickScheme(str name, int price_precision, Price min_tick, Price max_tick, float increment: float | None = None)
Represents a fixed precision tick scheme such as for Forex or Crypto.
- Parameters:
 - Raises: ValueError – If name is not a valid string.
 
increment
The tick scheme price increment.
- Returns: Price
 
max_price
The maximum valid price for the scheme.
- Returns: Price
 
min_price
The minimum valid price for the scheme.
- Returns: Price
 
name
The name of the scheme.
- Returns: str
 
next_ask_price(self, double value, int n=0) → Price
Return the price n ask ticks away from value.
If a given price is between two ticks, n=0 will find the nearest ask tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
next_bid_price(self, double value, int n=0) → Price
Return the price n bid ticks away from value.
If a given price is between two ticks, n=0 will find the nearest bid tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
price_precision
The tick scheme price precision.
- Returns: int
 
class TieredTickScheme
Bases: TickScheme
TieredTickScheme(str name, list tiers, int price_precision, int max_ticks_per_tier=100)
Represents a tick scheme where tick levels change based on price level, such as various financial exchanges.
- Parameters:
- name (str) – The name of the tick scheme.
 - tiers (list *[*tuple *(*start , stop , step ) ]) – The tiers for the tick scheme. Should be a list of (start, stop, step) tuples.
 - max_ticks_per_tier (int , default 100) – The maximum number of ticks per tier.
 
 - Raises: ValueError – If name is not a valid string.
 
find_tick_index(self, double value) → int
max_price
The maximum valid price for the scheme.
- Returns: Price
 
min_price
The minimum valid price for the scheme.
- Returns: Price
 
name
The name of the scheme.
- Returns: str
 
next_ask_price(self, double value, int n=0) → Price
Return the price n ask ticks away from value.
If a given price is between two ticks, n=0 will find the nearest ask tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
next_bid_price(self, double value, int n=0) → Price
Return the price n bid ticks away from value.
If a given price is between two ticks, n=0 will find the nearest bid tick.
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
ticks
class TickScheme
Bases: object
TickScheme(str name, Price min_tick, Price max_tick)
Represents an instrument tick scheme.
Maps the valid prices available for an instrument.
- Parameters:
 - Raises: ValueError – If name is not a valid string.
 
max_price
The maximum valid price for the scheme.
- Returns: Price
 
min_price
The minimum valid price for the scheme.
- Returns: Price
 
name
The name of the scheme.
- Returns: str
 
next_ask_price(self, double value, int n=0) → Price
Return the price n ask ticks away from value.
If a given price is between two ticks, n=0 will find the nearest ask tick (inclusive).
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
next_bid_price(self, double value, int n=0) → Price
Return the price n bid ticks away from value.
If a given price is between two ticks, n=0 will find the nearest bid tick (inclusive).
- Parameters:
- value (double) – The reference value.
 - n (int , default 0) – The number of ticks to move.
 
 - Return type: Price
 
get_tick_scheme(str name) → TickScheme
list_tick_schemes() → list
register_tick_scheme(TickScheme tick_scheme) → void
round_down(double value, double base) → double
Returns a value rounded down to a specific number of decimal places.
If value is already on the boundary, returns the same value (price-inclusive).
round_up(double value, double base) → double
Returns a value rounded up to a specific number of decimal places.
If value is already on the boundary, returns the same value (price-inclusive).