Tick Scheme

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

Fixed

class FixedTickScheme ( unicode name , int price_precision , Price min_tick , Price max_tick , increment: Optional[float] = None )

Bases: nautilus_trader.model.tick_scheme.base.TickScheme

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.

Returns

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.

Returns

Price

price_precision

The tick scheme price precision.

Returns

int

Tiered

class TieredTickScheme ( unicode name , list tiers , int max_ticks_per_tier=100 )

Bases: nautilus_trader.model.tick_scheme.base.TickScheme

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.

Returns

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.

Returns

Price

Base

class TickScheme ( unicode name , Price min_tick , Price max_tick )

Bases: object

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.

Returns

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.

Returns

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.