SDKs
JavaScript/Typescript
Admin Methods
Trading platforms
Management

Trading Platforms (Exchanges)

Trading Platforms (also referred to as Exchanges withing the TradrAPI ecosystem) represent the various platforms that TradrAPI supports. Each trading platform has a unique set of features and capabilities.

TradrAPI supports the following trading platforms:

  • MetaTrader 4
  • MetaTrader 5
  • TradeLocker
  • cTrader
⚠️

The ability to add or modify trading platforms at a global level is restricted to manager users only.

Fetching Available Trading Platforms

To fetch a list of available trading platforms, you can use the admin.exchanges namespace. For example, to fetch a single trading platform by ID:

import { Exchange } from '@tradrapi/trading-sdk';
 
const result: Exchange = await tradrApi.admin.exchanges.get(12);

The Exchange object returned will contain the following properties:

interface Exchange {
  /** 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 exchange */
  name: SupportedExchange;
  /** The version of the exchange */
  version: number;
}

Fetching All Available Trading Platforms

To fetch a list of all available trading platforms, you can use the list() method under the same namespace. For example, to fetch all trading platforms:

import { PaginatedResponse, Exchange } from '@tradrapi/trading-sdk';
 
const result: PaginatedResponse<Exchange> = await tradrApi.admin.exchanges.list();

The list() method optionally accepts a ListExchangeDto which can be used to filter the results.

interface ListExchangeDto {
  /**
   * The current page being returned.
   * @default 1
   */
  page?: number;
  /**
   * Number of records per page.
   * @default 10
   */
  limit?: number;
  /**
   * The sort direction of the records being returned
   * @default "DESC"
   */
  sortDir?: SortDir;
}

Managing Trading Platforms

⚠️

When creating a new trading platform care must be taken to ensure that the platform added already has a functional integration in TradrAPI.

To create a new trading platform, you can use the create() method under the same namespace.

import { Exchange, SupportedExchange } from '@tradrapi/trading-sdk';
 
const result: Exchange = await tradrApi.admin.exchanges.create({
  name: SupportedExchange.MT4,
  version: 1,
});

To update an existing trading platform, you can use the update() method under the same namespace.

import { SupportedExchange } from '@tradrapi/trading-sdk';
 
const result: boolean = await tradrApi.admin.exchanges.update(12, {
  name: SupportedExchange.MT4,
  version: 2,
});