Instruments ¶
Defines tradable asset/contract instruments with specific properties dependent on the asset class and asset type.
- class BettingInstrument ( unicode venue_name , unicode event_type_id , unicode event_type_name , unicode competition_id , unicode competition_name , unicode event_id , unicode event_name , unicode event_country_code , datetime event_open_date , unicode betting_type , unicode market_id , unicode market_name , datetime market_start_time , unicode market_type , unicode selection_id , unicode selection_name , unicode currency , unicode selection_handicap , uint64_t ts_event , uint64_t ts_init , unicode tick_scheme_name=None , int price_precision=7 , Price min_price=None , Price max_price=None , dict info={} ) ¶
-
Bases:
Instrument
Represents an instrument in a betting market.
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- static from_dict ( dict values ) BettingInstrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
BettingInstrument
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_base_currency ( self ) Currency ¶
-
Return the instruments base currency (if applicable).
- Returns :
-
Currency or
None
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( BettingInstrument obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- make_symbol ( unicode market_id: str, unicode selection_id: str, unicode selection_handicap: Optional[str] ) Symbol ¶
-
Make symbol.
>>> make_symbol(market_id="1.201070830", selection_id="123456", selection_handicap=None) Symbol('1.201070830|123456|None')
- class CryptoPerpetual ( InstrumentId instrument_id , Symbol raw_symbol , Currency base_currency , Currency quote_currency , Currency settlement_currency , bool is_inverse , int price_precision , int size_precision , Price price_increment , Quantity size_increment , margin_init: Decimal , margin_maint: Decimal , maker_fee: Decimal , taker_fee: Decimal , uint64_t ts_event , uint64_t ts_init , Quantity max_quantity: Optional[Quantity] = None , Quantity min_quantity: Optional[Quantity] = None , Money max_notional: Optional[Money] = None , Money min_notional: Optional[Money] = None , Price max_price: Optional[Price] = None , Price min_price: Optional[Price] = None , dict info=None ) ¶
-
Bases:
Instrument
Represents a Crypto Perpetual Futures contract instrument (a.k.a. Perpetual Swap ).
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID for the instrument.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
base_currency ( Currency , optional ) – The base currency.
-
quote_currency ( Currency ) – The quote currency.
-
settlement_currency ( Currency ) – The settlement currency.
-
is_inverse ( Currency ) – If the instrument costing is inverse (quantity expressed in quote currency units).
-
price_precision ( int ) – The price decimal precision.
-
size_precision ( int ) – The trading size decimal precision.
-
price_increment ( Price ) – The minimum price increment (tick size).
-
size_increment ( Quantity ) – The minimum size increment.
-
margin_init ( Decimal ) – The initial (order) margin requirement in percentage of order value.
-
margin_maint ( Decimal ) – The maintenance (position) margin in percentage of position value.
-
maker_fee ( Decimal ) – The fee rate for liquidity makers as a percentage of order value.
-
taker_fee ( Decimal ) – The fee rate for liquidity takers as a percentage of order value.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
max_quantity ( Quantity , optional ) – The maximum allowable order quantity.
-
min_quantity ( Quantity , optional ) – The minimum allowable order quantity.
-
max_notional ( Money , optional ) – The maximum allowable order notional value.
-
min_notional ( Money , optional ) – The minimum allowable order notional value.
-
max_price ( Price , optional ) – The maximum allowable quoted price.
-
min_price ( Price , optional ) – The minimum allowable quoted price.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If size_precision is negative (< 0).
-
ValueError – If price_increment is not positive (> 0).
-
ValueError – If size_increment is not positive (> 0).
-
ValueError – If price_precision is not equal to price_increment.precision.
-
ValueError – If size_increment is not equal to size_increment.precision.
-
ValueError – If lot size is not positive (> 0).
-
ValueError – If max_quantity is not positive (> 0).
-
ValueError – If min_quantity is negative (< 0).
-
ValueError – If max_notional is not positive (> 0).
-
ValueError – If min_notional is negative (< 0).
-
ValueError – If max_price is not positive (> 0).
-
ValueError – If min_price is negative (< 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- base_currency ¶
-
The base currency for the instrument.
- Returns :
-
Currency
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- static from_dict ( dict values ) CryptoPerpetual ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
CryptoPerpetual
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- is_quanto ¶
-
If the instrument is quanto.
- Returns :
-
bool
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- settlement_currency ¶
-
The settlement currency for the instrument.
- Returns :
-
Currency
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( CryptoPerpetual obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- class CryptoFuture ( InstrumentId instrument_id , Symbol raw_symbol , Currency underlying , Currency quote_currency , Currency settlement_currency , date expiry_date , int price_precision , int size_precision , Price price_increment , Quantity size_increment , margin_init: Decimal , margin_maint: Decimal , maker_fee: Decimal , taker_fee: Decimal , uint64_t ts_event , uint64_t ts_init , multiplier=Quantity.from_int_c(1) , lot_size=Quantity.from_int_c(1) , Quantity max_quantity: Optional[Quantity] = None , Quantity min_quantity: Optional[Quantity] = None , Money max_notional: Optional[Money] = None , Money min_notional: Optional[Money] = None , Price max_price: Optional[Price] = None , Price min_price: Optional[Price] = None , dict info=None ) ¶
-
Bases:
Instrument
Represents a Deliverable Futures Contract instrument, with crypto assets as underlying and for settlement.
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID for the instrument.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
underlying ( Currency ) – The underlying asset.
-
quote_currency ( Currency ) – The contract quote currency.
-
expiry_date ( date ) – The contract expiry date.
-
price_precision ( int ) – The price decimal precision.
-
size_precision ( int ) – The trading size decimal precision.
-
price_increment ( Price ) – The minimum price increment (tick size).
-
size_increment ( Quantity ) – The minimum size increment.
-
margin_init ( Decimal ) – The initial (order) margin requirement in percentage of order value.
-
margin_maint ( Decimal ) – The maintenance (position) margin in percentage of position value.
-
maker_fee ( Decimal ) – The fee rate for liquidity makers as a percentage of order value.
-
taker_fee ( Decimal ) – The fee rate for liquidity takers as a percentage of order value.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
max_quantity ( Quantity , optional ) – The maximum allowable order quantity.
-
min_quantity ( Quantity , optional ) – The minimum allowable order quantity.
-
max_notional ( Money , optional ) – The maximum allowable order notional value.
-
min_notional ( Money , optional ) – The minimum allowable order notional value.
-
max_price ( Price , optional ) – The maximum allowable quoted price.
-
min_price ( Price , optional ) – The minimum allowable quoted price.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If size_precision is negative (< 0).
-
ValueError – If price_increment is not positive (> 0).
-
ValueError – If size_increment is not positive (> 0).
-
ValueError – If price_precision is not equal to price_increment.precision.
-
ValueError – If size_increment is not equal to size_increment.precision.
-
ValueError – If lot size is not positive (> 0).
-
ValueError – If max_quantity is not positive (> 0).
-
ValueError – If min_quantity is negative (< 0).
-
ValueError – If max_notional is not positive (> 0).
-
ValueError – If min_notional is negative (< 0).
-
ValueError – If max_price is not positive (> 0).
-
ValueError – If min_price is negative (< 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- expiry_date ¶
-
The expiry date for the contract.
- Returns :
-
date
- static from_dict ( dict values ) CryptoFuture ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
CryptoFuture
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- settlement_currency ¶
-
The settlement currency for the contract.
- Returns :
-
Currency
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( CryptoFuture obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- underlying ¶
-
The underlying asset for the contract.
- Returns :
-
Currency
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- class CurrencyPair ( InstrumentId instrument_id , Symbol raw_symbol , Currency base_currency , Currency quote_currency , int price_precision , int size_precision , Price price_increment , Quantity size_increment , margin_init: Decimal , margin_maint: Decimal , maker_fee: Decimal , taker_fee: Decimal , uint64_t ts_event , uint64_t ts_init , Quantity lot_size: Optional[Quantity] = None , Quantity max_quantity: Optional[Quantity] = None , Quantity min_quantity: Optional[Quantity] = None , Money max_notional: Optional[Money] = None , Money min_notional: Optional[Money] = None , Price max_price: Optional[Price] = None , Price min_price: Optional[Price] = None , unicode tick_scheme_name=None , dict info=None ) ¶
-
Bases:
Instrument
Represents a generic currency pair instrument in a spot/cash market.
Can represent both Fiat FX and Cryptocurrency pairs.
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID for the instrument.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
base_currency ( Currency ) – The base currency.
-
quote_currency ( Currency ) – The quote currency.
-
price_precision ( int ) – The price decimal precision.
-
size_precision ( int ) – The trading size decimal precision.
-
price_increment ( Price ) – The minimum price increment (tick size).
-
size_increment ( Quantity ) – The minimum size increment.
-
margin_init ( Decimal ) – The initial (order) margin requirement in percentage of order value.
-
margin_maint ( Decimal ) – The maintenance (position) margin in percentage of position value.
-
maker_fee ( Decimal ) – The fee rate for liquidity makers as a percentage of order value.
-
taker_fee ( Decimal ) – The fee rate for liquidity takers as a percentage of order value.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
lot_size ( Quantity , optional ) – The rounded lot unit size.
-
max_quantity ( Quantity , optional ) – The maximum allowable order quantity.
-
min_quantity ( Quantity , optional ) – The minimum allowable order quantity.
-
max_notional ( Money , optional ) – The maximum allowable order notional value.
-
min_notional ( Money , optional ) – The minimum allowable order notional value.
-
max_price ( Price , optional ) – The maximum allowable quoted price.
-
min_price ( Price , optional ) – The minimum allowable quoted price.
-
tick_scheme_name ( str , optional ) – The name of the tick scheme.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If tick_scheme_name is not a valid string.
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If size_precision is negative (< 0).
-
ValueError – If price_increment is not positive (> 0).
-
ValueError – If size_increment is not positive (> 0).
-
ValueError – If price_precision is not equal to price_increment.precision.
-
ValueError – If size_increment is not equal to size_increment.precision.
-
ValueError – If lot_size is not positive (> 0).
-
ValueError – If max_quantity is not positive (> 0).
-
ValueError – If min_quantity is negative (< 0).
-
ValueError – If max_notional is not positive (> 0).
-
ValueError – If min_notional is negative (< 0).
-
ValueError – If max_price is not positive (> 0).
-
ValueError – If min_price is negative (< 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- base_currency ¶
-
The base currency for the instrument.
- Returns :
-
Currency
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- static from_dict ( dict values ) CurrencyPair ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
CurrencyPair
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( CurrencyPair obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- class Equity ( InstrumentId instrument_id , Symbol raw_symbol , Currency currency , int price_precision , Price price_increment , Quantity multiplier , Quantity lot_size , uint64_t ts_event , uint64_t ts_init , unicode isin: Optional[str] = None , margin_init: Optional[Decimal] = None , margin_maint: Optional[Decimal] = None , maker_fee: Optional[Decimal] = None , taker_fee: Optional[Decimal] = None , dict info=None ) ¶
-
Bases:
Instrument
Represents a generic Equity instrument.
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
currency ( Currency ) – The futures contract currency.
-
price_precision ( int ) – The price decimal precision.
-
price_increment ( Decimal ) – The minimum price increment (tick size).
-
multiplier ( Decimal ) – The contract value multiplier (determines tick value).
-
lot_size ( Quantity ) – The rounded lot unit size (standard/board).
-
isin ( str , optional ) – The International Securities Identification Number (ISIN).
-
margin_init ( Decimal , optional ) – The initial (order) margin requirement in percentage of order value.
-
margin_maint ( Decimal , optional ) – The maintenance (position) margin in percentage of position value.
-
maker_fee ( Decimal , optional ) – The fee rate for liquidity makers as a percentage of order value.
-
taker_fee ( Decimal , optional ) – The fee rate for liquidity takers as a percentage of order value.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If multiplier is not positive (> 0).
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If tick_size is not positive (> 0).
-
ValueError – If lot_size is not positive (> 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- static from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Equity
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_base_currency ( self ) Currency ¶
-
Return the instruments base currency (if applicable).
- Returns :
-
Currency or
None
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( Instrument obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- class FuturesContract ( InstrumentId instrument_id , Symbol raw_symbol , AssetClass asset_class , Currency currency , int price_precision , Price price_increment , Quantity multiplier , Quantity lot_size , unicode underlying , date expiry_date , uint64_t ts_event , uint64_t ts_init , dict info=None ) ¶
-
Bases:
Instrument
Represents a generic deliverable futures contract instrument.
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
asset_class ( AssetClass ) – The futures contract asset class.
-
currency ( Currency ) – The futures contract currency.
-
price_precision ( int ) – The price decimal precision.
-
price_increment ( Decimal ) – The minimum price increment (tick size).
-
multiplier ( Quantity ) – The contract multiplier.
-
lot_size ( Quantity ) – The rounded lot unit size (standard/board).
-
underlying ( str ) – The underlying asset.
-
expiry_date ( date ) – The contract expiry date.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If multiplier is not positive (> 0).
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If tick_size is not positive (> 0).
-
ValueError – If lot_size is not positive (> 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- expiry_date ¶
-
The expiry date for the contract.
- Returns :
-
date
- static from_dict ( dict values ) FuturesContract ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
FuturesContract
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_base_currency ( self ) Currency ¶
-
Return the instruments base currency (if applicable).
- Returns :
-
Currency or
None
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( FuturesContract obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- underlying ¶
-
The underlying asset for the contract.
- Returns :
-
str
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- class OptionsContract ( InstrumentId instrument_id , Symbol raw_symbol , AssetClass asset_class , Currency currency , int price_precision , Price price_increment , Quantity multiplier , Quantity lot_size , Price strike_price , unicode underlying , date expiry_date , OptionKind kind , uint64_t ts_event , uint64_t ts_init , dict info=None ) ¶
-
Bases:
Instrument
Represents a generic options contract instrument.
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
asset_class ( AssetClass ) – The futures contract asset class.
-
currency ( Currency ) – The futures contract currency.
-
price_precision ( int ) – The price decimal precision.
-
price_increment ( Price ) – The minimum price increment (tick size).
-
multiplier ( Quantity ) – The option multiplier.
-
lot_size ( Quantity ) – The rounded lot unit size (standard/board).
-
strike_price ( Price ) – The option strike price.
-
underlying ( str ) – The underlying asset.
-
expiry_date ( date ) – The option expiry date.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If multiplier is not positive (> 0).
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If tick_size is not positive (> 0).
-
ValueError – If lot_size is not positive (> 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- static from_dict ( dict values ) OptionsContract ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
OptionsContract
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_base_currency ( self ) Currency ¶
-
Return the instruments base currency (if applicable).
- Returns :
-
Currency or
None
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- static to_dict ( OptionsContract obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue
- class SyntheticInstrument ( Symbol symbol , uint8_t price_precision , list components , unicode formula , uint64_t ts_event , uint64_t ts_init ) ¶
-
Bases:
Data
Represents a synthetic instrument with prices derived from component instruments using a formula.
The id for the synthetic will become {symbol}.{SYNTH}.
- Parameters :
-
-
symbol ( Symbol ) – The symbol for the synethic instrument.
-
price_precision ( uint8_t ) – The price precision for the synthetic instrument.
-
components ( list [ InstrumentId ] ) – The component instruments for the synthetic instrument.
-
formula ( str ) – The derivation formula for the synthetic instrument.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
- Raises :
-
-
ValueError – If price_precision is greater than 9.
-
OverflowError – If price_precision is negative (< 0).
-
ValueError – If the components list does not contain at least 2 instrument IDs.
-
ValueError – If the formula is not a valid string.
-
ValueError – If the formula is not a valid expression.
-
Warning
All component instruments should already be defined and exist in the cache prior to defining a new synthetic instrument.
- calculate ( self , list inputs ) Price ¶
-
Calculate the price of the synthetic instrument from the given inputs .
- Parameters :
-
inputs ( list [ double ] ) –
- Returns :
-
Price
- Raises :
-
-
ValueError – If inputs is empty, contains a NaN value, or length is different from components count.
-
RuntimeError – If an internal error occurs when calculating the price.
-
- change_formula ( self , unicode formula ) void ¶
-
Change the internal derivation formula for the synthetic instrument.
- Parameters :
-
formula ( str ) – The derivation formula to change to.
- Raises :
-
-
ValueError – If the formula is not a valid string.
-
ValueError – If the formula is not a valid expression.
-
- components ¶
-
list[InstrumentId]
Return the components of the synthetic instrument.
- Returns :
-
list[InstrumentId]
- Type :
-
SyntheticInstrument.components
- formula ¶
-
str
Return the synthetic instrument internal derivation formula.
- Returns :
-
str
- Type :
-
SyntheticInstrument.formula
- static from_dict ( dict values ) SyntheticInstrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
SyntheticInstrument
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- price_increment ¶
-
Price
Return the minimum price increment (tick size) for the synthetic instrument.
- Returns :
-
Price
- Type :
-
SyntheticInstrument.price_increment
- price_precision ¶
-
int
Return the precision for the synthetic instrument.
- Returns :
-
int
- Type :
-
SyntheticInstrument.price_precision
- static to_dict ( SyntheticInstrument obj ) dict [ str , object ] ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
int
- Type :
-
SyntheticInstrument.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
SyntheticInstrument.ts_init
- class Instrument ( InstrumentId instrument_id , Symbol raw_symbol , AssetClass asset_class , AssetType asset_type , Currency quote_currency , bool is_inverse , int price_precision , int size_precision , Quantity size_increment , Quantity multiplier , margin_init: Decimal , margin_maint: Decimal , maker_fee: Decimal , taker_fee: Decimal , uint64_t ts_event , uint64_t ts_init , Price price_increment: Optional[Price] = None , Quantity lot_size: Optional[Quantity] = None , Quantity max_quantity: Optional[Quantity] = None , Quantity min_quantity: Optional[Quantity] = None , Money max_notional: Optional[Money] = None , Money min_notional: Optional[Money] = None , Price max_price: Optional[Price] = None , Price min_price: Optional[Price] = None , unicode tick_scheme_name=None , dict info=None ) ¶
-
Bases:
Data
The base class for all instruments.
Represents a tradable financial market instrument. This class can be used to define an instrument, or act as a parent class for more specific instruments.
- Parameters :
-
-
instrument_id ( InstrumentId ) – The instrument ID for the instrument.
-
raw_symbol ( Symbol ) – The native/local/raw symbol for the instrument, assigned by the venue.
-
asset_class ( AssetClass ) – The instrument asset class.
-
asset_type ( AssetType ) – The instrument asset type.
-
quote_currency ( Currency ) – The quote currency.
-
is_inverse ( Currency ) – If the instrument costing is inverse (quantity expressed in quote currency units).
-
price_precision ( int ) – The price decimal precision.
-
size_precision ( int ) – The trading size decimal precision.
-
size_increment ( Price ) – The minimum size increment.
-
multiplier ( Decimal ) – The contract value multiplier (determines tick value).
-
lot_size ( Quantity , optional ) – The rounded lot unit size (standard/board).
-
margin_init ( Decimal ) – The initial (order) margin requirement in percentage of order value.
-
margin_maint ( Decimal ) – The maintenance (position) margin in percentage of position value.
-
maker_fee ( Decimal ) – The fee rate for liquidity makers as a percentage of order value.
-
taker_fee ( Decimal ) – The fee rate for liquidity takers as a percentage of order value.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the data object was initialized.
-
price_increment ( Price , optional ) – The minimum price increment (tick size).
-
max_quantity ( Quantity , optional ) – The maximum allowable order quantity.
-
min_quantity ( Quantity , optional ) – The minimum allowable order quantity.
-
max_notional ( Money , optional ) – The maximum allowable order notional value.
-
min_notional ( Money , optional ) – The minimum allowable order notional value.
-
max_price ( Price , optional ) – The maximum allowable quoted price.
-
min_price ( Price , optional ) – The minimum allowable quoted price.
-
tick_scheme_name ( str , optional ) – The name of the tick scheme.
-
info ( dict [ str , object ] , optional ) – The additional instrument information.
-
- Raises :
-
-
ValueError – If tick_scheme_name is not a valid string.
-
ValueError – If price_precision is negative (< 0).
-
ValueError – If size_precision is negative (< 0).
-
ValueError – If price_increment is not positive (> 0).
-
ValueError – If size_increment is not positive (> 0).
-
ValueError – If price_precision is not equal to price_increment.precision.
-
ValueError – If size_increment is not equal to size_increment.precision.
-
ValueError – If multiplier is not positive (> 0).
-
ValueError – If lot size is not positive (> 0).
-
ValueError – If max_quantity is not positive (> 0).
-
ValueError – If min_quantity is negative (< 0).
-
ValueError – If max_notional is not positive (> 0).
-
ValueError – If min_notional is negative (< 0).
-
ValueError – If max_price is not positive (> 0).
-
ValueError – If min_price is negative (< 0).
-
- asset_class ¶
-
The asset class of the instrument.
- Returns :
-
AssetClass
- asset_type ¶
-
The asset type of the instrument.
- Returns :
-
AssetType
- static base_from_dict ( dict values ) Instrument ¶
-
Return an instrument from the given initialization values.
- Parameters :
-
values ( dict [ str , object ] ) – The values to initialize the instrument with.
- Returns :
-
Instrument
- static base_to_dict ( Instrument obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- calculate_base_quantity ( self , Quantity quantity , Price last_px ) Quantity ¶
-
Calculate the base asset quantity from the given quote asset quantity and last price.
- classmethod fully_qualified_name ( cls ) str ¶
-
Return the fully qualified name for the Data class.
- Returns :
-
str
References
- get_base_currency ( self ) Currency ¶
-
Return the instruments base currency (if applicable).
- Returns :
-
Currency or
None
- get_settlement_currency ( self ) Currency ¶
-
Return the currency used to settle a trade of the instrument.
-
Standard linear instruments = quote_currency
-
Inverse instruments = base_currency
-
Quanto instruments = settlement_currency
- Returns :
-
Currency
-
- id ¶
-
The instrument ID.
- Returns :
-
InstrumentId
- info ¶
-
The raw info for the instrument.
- Returns :
-
dict[str, object]
- is_inverse ¶
-
If the quantity is expressed in quote currency.
- Returns :
-
Currency
- lot_size ¶
-
The rounded lot unit size (standard/board) for the instrument.
- Returns :
-
Quantity or
None
- make_price ( self , value ) Price ¶
-
Return a new price from the given value using the instruments price precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the price.
- Returns :
-
Price
- make_qty ( self , value ) Quantity ¶
-
Return a new quantity from the given value using the instruments size precision.
- Parameters :
-
value ( integer , float , str or Decimal ) – The value of the quantity.
- Returns :
-
Quantity
- maker_fee ¶
-
The maker fee rate for the instrument.
- Returns :
-
Decimal
- margin_init ¶
-
The initial (order) margin rate for the instrument.
- Returns :
-
Decimal
- margin_maint ¶
-
The maintenance (position) margin rate for the instrument.
- Returns :
-
Decimal
- max_notional ¶
-
The maximum notional order value for the instrument.
- Returns :
-
Money or
None
- max_price ¶
-
The maximum printable price for the instrument.
- Returns :
-
Price or
None
- max_quantity ¶
-
The maximum order quantity for the instrument.
- Returns :
-
Quantity or
None
- min_notional ¶
-
The minimum notional order value for the instrument.
- Returns :
-
Money or
None
- min_price ¶
-
The minimum printable price for the instrument.
- Returns :
-
Price or
None
- min_quantity ¶
-
The minimum order quantity for the instrument.
- Returns :
-
Quantity or
None
- multiplier ¶
-
The contract multiplier for the instrument (determines tick value).
- Returns :
-
Quantity
- next_ask_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- next_bid_price ( self , double value , int num_ticks=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.
-
num_ticks ( int , default 0 ) – The number of ticks to move.
-
- Returns :
-
Price
- Raises :
-
ValueError – If tick scheme is not registered.
- notional_value ( self , Quantity quantity , Price price , bool use_quote_for_inverse=False ) Money ¶
-
Calculate the notional value.
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
- price_increment ¶
-
The minimum price increment or tick size for the instrument.
- Returns :
-
Price
- price_precision ¶
-
The price precision of the instrument.
- Returns :
-
int
- quote_currency ¶
-
The quote currency for the instrument.
- Returns :
-
Currency
- raw_symbol ¶
-
The native/local/raw symbol for the instrument, assigned by the venue.
- Returns :
-
Symbol
- size_increment ¶
-
The minimum size increment for the instrument.
- Returns :
-
Quantity
- size_precision ¶
-
The size precision of the instrument.
- Returns :
-
int
- symbol ¶
-
Return the instruments ticker symbol.
- Returns :
-
Symbol
- taker_fee ¶
-
The taker fee rate for the instrument.
- Returns :
-
Decimal
- tick_scheme_name ¶
-
The tick scheme name.
- Returns :
-
str or
None
- ts_event ¶
-
The UNIX timestamp (nanoseconds) when the data event occurred.
- Returns :
-
uint64_t
- ts_init ¶
-
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
uint64_t
- venue ¶
-
Return the instruments trading venue.
- Returns :
-
Venue