MLThon Instruments Package

Submodules

mlthon.instruments.future module

class Future(underlying_ins_id=None, expiration_date_utc=None, settlement_method=None, **kwargs)[source]

Bases: mlthon.instruments.instrument.Instrument

get_expiration_date_utc()[source]
get_settlement_method()[source]
get_underlying_ins_id()[source]

mlthon.instruments.instrument module

class Instrument(instrument_id=None, instrument_type=None, instrument_group_id=None, exch_instr_id=None, exchange=None, mlt_symbol=None, price_tick_rules=None, quantity_tick_rules=None, multiplier=None, min_quantity=None, base_currency=None, quote_currency=None, quantification=None, price_precision=None, quantity_precision=None, valid_start_ts=None, valid_end_ts=None, instrument_name=None, **kwargs)[source]

Bases: object

Instrument class, including all the necessary infos for an instrument/product.

get_base_currency()[source]
get_exch_instr_id()[source]
get_exchange()[source]
get_instrument_group_id()[source]
get_instrument_id()[source]
get_instrument_name()[source]
get_instrument_type()[source]
get_min_quantity()[source]
get_mlt_symbol()[source]
get_multiplier()[source]
get_price_precision()[source]
get_price_tick_rules()[source]
get_quantification()[source]
get_quantity_precision()[source]
get_quantity_tick_rules()[source]
get_quote_currency()[source]
get_valid_end_ts()[source]
get_valid_start_ts()[source]

mlthon.instruments.instrument_utils module

class InstrumentUtils[source]

Bases: object

static exch_syms_types_to_instr_names(exchange, type_by_symbol)[source]

Return a list of instrument names, given the exchange, symbols and types.

Parameters
  • exchange (Exchange) – exchange of these instruments.

  • type_by_symbol (dict) – a dictionary, whose keys are the symbols and values are the instrument types, e.g. {“BTC-USD”: InstrumentType:Perpetual}.

Return type

a list of strings, each of which is the corresponding instrument name.

static exch_type_sym_to_instr_name(exchange, instr_type, symbol)[source]

Transfer (exchange, instrument_type, symbol) into instrument_name (e.g. byt:perp:btc-usd).

Parameters
  • exchange (Exchange) – exchange of this instrument.

  • instr_type (InstrumentType) – instrument type of this instrument.

  • symbol (str) – symbol (internal symbol in MLTech) of this instrument.

Return type

a string, the instrument name.

static get_instrument_from_json(json_object)[source]

Parse a json object with instrument info, and generate the corresponding Instrument object.

Parameters

json_object (dict) – a json object (dict), with all the information of an instrument. Example: {

“instrument_type”:”spot”, # instrument type ID (e.g. perp), not the type’s whole name (e.g. PERPETUAL) “exchange_id”:”BLN”, “mlt_symbol”:”BTC-USD”, “price_tick_rules_json”:

{ “default”: “0.1”, “rules”: [] },

“quantity_tick_rules_json”:

{ “default”: “0.00000001”, “rules”: [] },

“multiplier”:”1.0000000000”, “valid_start_ts”:1630003158, “instrument_group_id”:”spot:BTC-USD”, “base_currency”:”BTC”, “quote_currency”:”USD”, “min_quantity”:”0.0005000000”, “exch_instr_id”:”BTC-USD”, “quantification”:”base”, “instrument_id”:10000000000, “price_precision”:1, “quantity_precision”:4

}

Return type

an Instrument (or its subclass) object

static get_instrument_from_raw_msg(raw_msg)[source]

Parse the raw payload (json-formatted string) and generate the corresponding Instrument object.

Parameters

raw_msg (str) – raw message for instrument, a string in json format, example: ```{

“instrument_type”:”SPOT”, “exchange_id”:”BLN”, “mlt_symbol”:”BTC-USD”, “price_tick_rules_json”:

{ “default”: “0.1”, “rules”: [] },

“quantity_tick_rules_json”:

{ “default”: “0.00000001”, “rules”: [] },

“multiplier”:”1.0000000000”, “valid_start_ts”:1630003158, “instrument_group_id”:”spot:BTC-USD”, “base_currency”:”BTC”, “quote_currency”:”USD”, “min_quantity”:”0.0005000000”, “exch_instr_id”:”BTC-USD”, “quantification”:”base”, “instrument_id”:10000000000, “price_precision”:1, “quantity_precision”:4 }```

Return type

an Instrument (or its subclass) object

mlthon.instruments.perpetual module

class Perpetual(underlying_ins_id=None, funding_rate_settlement_interval_ms=None, **kwargs)[source]

Bases: mlthon.instruments.instrument.Instrument

get_funding_rate_settlement_interval_ms()[source]
get_underlying_ins_id()[source]