Skip to main content
Version: nightly

Tick Scheme

Defines a scheme for modeling the tick space for various instruments.

class FixedTickScheme

Bases: TickScheme

FixedTickScheme(unicode name, int price_precision, Price min_tick, Price max_tick, increment: float | None = None)

Represents a fixed precision tick scheme such as for Forex or Crypto.

  • Parameters:
    • name (str) – The name of the tick scheme.
    • price_precision (int) – The instrument price precision.
    • min_tick (Price) – The minimum possible tick Price.
    • max_tick (Price) – The maximum possible tick Price.
    • increment (float , optional) – The tick increment.
  • 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(unicode 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(unicode name, Price min_tick, Price max_tick)

Represents an instrument tick scheme.

Maps the valid prices available for an instrument.

  • Parameters:
    • name (str) – The name of the tick scheme.
    • min_tick (Price) – The minimum possible tick Price.
    • max_tick (Price) – The maximum possible tick Price.
  • 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.

  • 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

get_tick_scheme(unicode 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.

round_up(double value, double base) → double

Returns a value rounded down to a specific number of decimal places.