Symbols (Instruments)
Each project in TradrAPI can be setup to support a number of symbols. Each symbol represents a financial instrument that can be traded by users.
Different symbols can also be setup to be available only to specific user groups, this is advantageous if you want to offer different symbols to different users based on some business level of user segmentation.
The below methods accept an optional spreadGroupId
parameter which can be obtained on an account per account basis
via the AccountResult
object. It is highly recommended that this ID is passed in order to ensure the correct spreads
are returned for the account in question.
Listing Symbols
In order to list all the symbols available to a user, you can use the following method available at under the symbols
namespace:
import { Symbol } from '@tradrapi/trading-sdk';
const symbols: Symbol[] = await tradrApi.symbols.list();
The list method optionally takes a dto as a parameter which can be used to filter the results returned by the API. The format of the dto is as follows:
export interface ListSymbolDto {
/**
* The current page being returned.
* @min 1
* @default 1
*/
page?: number;
/**
* Number of records per page.
* @min 1
* @default 10
*/
limit?: number;
/**
* The sort direction of the records being returned
* @default "DESC"
*/
sortDir?: SortDir;
/** The spread group id to fetch symbols for */
spreadGroupId?: number;
/** The symbol to filter by */
symbol?: string;
}
Symbol Details
The format of a Symbol
model as returned by the API is as follows:
interface Symbol {
/** The TradrAPI ID of the entity */
id: number;
/**
* The date the entity was created
* @format date-time
*/
createdAt: string;
/**
* The date the entity was last updated
* @format date-time
*/
updatedAt: string;
/** The name of the symbol, for example ETHUSD */
name: string;
/** The ID of the spread group this symbol belongs to */
spreadGroupId: number;
/** The base currency of the symbol, for example ETH */
base: string;
/** The quote currency of the symbol, for example USD */
quote?: string;
/** The trading sessions available for this symbol. These determine the times during which trading is allowed */
tradingSession?: TradingSessions | null;
/** The holidays during which trading is not allowed */
holidays?: Holiday[] | null;
/** Indicates the current status of the market, whether it is open or closed */
status: MarketStatus;
/** The security type of the symbol, for example CFD */
security: string;
/** The spread buy value of the symbol */
spreadBuy: number;
/** The spread sell value of the symbol */
spreadSell: number;
/** The contract size of the symbol */
contractSize: number;
/** The point value of the symbol */
pointValue: number;
/** The maximum volume that cam be traded */
maxVolume: number;
/** The minimum volume that can be traded */
minVolume: number;
/** The number of digits after the decimal point */
digits: number;
/** Human friendly symbol name e.g: AMZN -> Amazon Inc */
description?: string;
}
Listing Securities
In order to list all the securities available to a user, you can use the following method available at under the
symbols
namespace:
const securities: string[] = await tradrApi.symbols.listSecurities();
Listing Symbols By Security
It is also possible to list all the symbols sorted and ordered by their security. This can be done using the
following method available under the symbols
namespace:
import { GroupedSymbols } from '@tradrapi/trading-sdk';
const groupedSymbol: GroupedSymbols[] = await tradrApi.symbols.listBySecurity();
The result returned by this method is an array of GroupedSymbols
objects. The format of a GroupedSymbols
object is
as follows:
type GroupedSymbols = {
/** The security name */
security: string;
/** The number of symbols in this security */
count: number;
/** The symbols in this security */
symbols: Symbol[];
}