Tick Scheme¶
Defines a scheme for modeling the tick space for various instruments.
- class FixedTickScheme¶
Bases:
TickSchemeFixedTickScheme(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:
- 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_precision¶
The tick scheme price precision.
- Returns:
int
- class TieredTickScheme¶
Bases:
TickSchemeTieredTickScheme(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:
- 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:
- 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:
- ticks¶
- get_tick_scheme(str name) TickScheme¶
- register_tick_scheme(TickScheme tick_scheme) void¶
- class FixedTickScheme¶
Bases:
TickSchemeFixedTickScheme(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:
- 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_precision¶
The tick scheme price precision.
- Returns:
int
- class TieredTickScheme¶
Bases:
TickSchemeTieredTickScheme(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:
- 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:
- 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:
- ticks¶
- class TickScheme¶
Bases:
objectTickScheme(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:
- 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).