TT CORE SDK  0.1
TT CORE SDK documentation
Instruments

Finding Instruments

An instrument’s definition can be found by calling the DownloadInstrument() function and specifying either:

  • The instrument’s unique ID that is provided by TT
  • The instrument’s name / alias and market

This call is synchronous, so it is highly recommended it be used during initialization for performance reasons.

Downloading an instrument by its unique TT ID

The most efficient way to retrieve an instrument definition is providing the unique ID that TT assigns to it. The signature of the DownloadInstrument() function in this case is as follows.

std::shared_ptr<Instrument> DownloadInstrument (uint64_t instr_id);

If the instrument download fails, a nullptr is returned.

To look up the instrument ID, TT provides an easy way for you to get the required instrument ID to use in your code. To get the ID for an instrument:

  1. Open a Market Grid in the TT Trade app.

  2. Select the desired instrument and type Shift+Ctrl+X to display the instrument data.

    You can then see the value in the instrument's instrumentId field.

    get-instr-id.png
  3. Copy the value in the instrument's instrumentId field, and paste into your function call as the instr_id parameter.

The following code snippet illustrates the use of this function in this case.

std::shared_ptr<Instrument> instr = DownloadInstrument(1900192959412750266);
if (!instr)
{
std::cerr << "Failed to download instrument\n";
return EXIT_FAILURE;
}

Downloading an instrument by its name

Alternatively you can perform a query search by providing the market id and either the instrument name (e.g. “ESH8”) or alias (e.g. “ES Mar18”) fields. Note that if the query string does not explicitly match the name/alias fields, the download will fail.

The signature of the DownloadInstrument() function in this case is as follows.

std::shared_ptr<Instrument> DownloadInstrument (const std::string& query, enum market market_id);

If the instrument download fails, a nullptr is returned.

To look up the short name, TT provides an easy way for you to get the required instrument name to use in your code. To get the short name for an instrument:

  1. Open a Market Grid in the TT Trade app.

  2. Select the desired instrument and type Shift+Ctrl+X to display the instrument data.

    You can then see the value in the instrument's name field.

    get-instr-name.png
  3. Copy the value in the instrument's name field, and paste into your function call as the query parameter.

The following code snippet illustrates the use of this function in this case.

std::shared_ptr<Instrument> instr = DownloadInstrument("ESH8", market::CME);
if (!instr)
{
std::cerr << "Failed to download instrument\n";
return EXIT_FAILURE;
}

More About the Instrument Class

The instrument contains over 35 different public member variables defining the instrument.

Instrument Attributes

Public Attribute Description
alias Alias (e.g. ES Dec14).
combo_type_id Combo type ID.
display_factor Display Factor.
first_delivery_date First delivery date.
implied_rules Implied rules.
instr_id Instrument ID.
instr_version Instrument version.
is_not_tradable Whether the instrument is not tradable.
legs

Instrument legs.

Returns a vector of instrument_leg struct, which is defined in the instrument.hpp file.

last_trading_date Last trading date.
market_id

Market Identifier.

Returns a market enum, which is defined in the enums.hpp file.

maturity_date Maturity date.
min_price_increment Minimal price increment.
name Instrument Name (e.g. ESZ4).
option_code_id Option code ID.
option_scheme_id Option scheme ID.
point_value Value of one point in the default currency.
price_formula User-defined price formula for a spread.
price_topic The topic which price update is send on.
product_currency

ISO cod for the native product currency.

Returns a currency_code enum, which is defined in the enums.hpp file.

product_id Product ID.
product_type_id

Product type.

Returns a product_type_id enum, which is defined in the enums.hpp file.

product_version Product version.
security_id Security ID.
series_term_id Series term ID.
starting_date Starting date.
strike_price Strike price.
supports_implieds Instrument supports implied prices.
symbol Product Symbol (e.g. ES).
tick_denom Ticking: Denominator.
tick_num Ticking: Numerator.
tick_size Interval between tradable prices.
tick_table

Variable ticking data.

Returns a tick_table_data struct, which is defined in the instrument.hpp file.

tick_value Value of one tick in the default currency.
underlying_instr_id Underlying Instrument ID.

In addition, helper methods for performing accurate price conversions specific to that instrument are also available.

Instrument Class Methods

Member Function Description
GetMinTickSize()

Returns the minimum tick size.

double GetMinTickSize(void) const;

IsPriceOnTick()

Returns if the specified price is on a tradable tick.

bool IsPriceOnTick(double price) const;

IsValid()

Checks if the instrument data is valid.

bool IsValid(void) const;

OffsetPrice()

Returns the tradable price a number of ticks from the specified price.

double OffsetPrice(double price, int32_t offset, rounding round) const;

The rounding enum is defined in the enums.hpp file.

PriceToTicks()

Returns the specified price in tradable ticks.

bool IsPriceOnTick(double price) const;

RoundPriceToTick()

Returns the specified price rounded to a tradable tick

double OffsetPrice(double price, rounding round) const;

The rounding enum is defined in the enums.hpp file.

TickPriceDown()

Returns the tradable price a number of ticks below the specified price.

double TickPriceDown(double price, uint32_t offset) const;

TickPriceUp()

Returns the tradable price a number of ticks above the specified price.

double TickPriceUp(double price, uint32_t offset) const;