SDKs
JavaScript/Typescript
Admin Methods
Projects (Brands)
Adding a Project

Adding A New Project

To create a new project, use the create method available under the admin.brand namespace. The method accepts a single parameter which is the CreateBrandDto object containing the details of the project to create. For example:

import { Brand } from '@tradrapi/trading-sdk';
 
const brand: Brand = await tradrApi.admin.brand.create({
  name: 'Trading Power',
  uid: 'TPR',
  defaultExchange: 1,
  existingServers: [1, 6, 7],
  rules: [
    {
      type: 'category',
      priority: 2,
      ruleSet: {
        'ecn-USD': 'MBD-GEN',
      },
    },
  ],
});

The CreateBrandDto object contains the following properties:

interface CreateBrandDto {
  /** The name of the brand */
  name: string;
  /**
   * The unique identifier of the brand
   * @minLength 3
   * @maxLength 4
   */
  uid: string;
  /** The unique identifier of the brand on the exchange */
  exchangeUid: string;
  /** The type of the brand */
  type?: BrandType;
  /** If present, should contain the details used to create a new server for the brand */
  newServer?: CreateServerDto;
  /** If present, should contain the ids of existing servers to assign to the brand */
  existingServers?: number[];
  /** create new group, assigned to the created server and brand */
  serverGroups?: BrandGroup[];
  /** The rules which define account routing for registration */
  rules?: CreateSingleRuleDto[];
  /**
   * If JWT auth for users is required, the url of the jwks endpoint to use
   * @example "https://{yourDomain}/.well-known/jwks.json"
   */
  jwksUrl?: string | null;
  /**
   * If JWT auth for users is required, the issuer to use for JWT tokens
   * @minLength 3
   */
  jwksIss?: string | null;
  /** If present, should contain the ids of existing exchanges to assign to the brand */
  exchanges?: number[];
  /**
   * By default, the brand will be assigned the server clients application links, unless this is provided as true
   * @default false
   */
  manualExchangeClient?: boolean;
  /**
   * By default, the brand will be assigned all the account categories, unless this is provided as true
   * @default false
   */
  manualAccountCategories?: boolean;
  /** The default exchange id of the brand */
  defaultExchange: number;
}

Important To Know

Before creating a new project in TradrAPI, the following items must be prepared:

  1. Server URL & auth credentials (in case the server doesn't exist already on TradrAPI)
  2. The required groups to be already setup on the relevant trading platforms

If the server doesn't exist already on TradrAPI, the newServer property must be provided with the details of the server to create, for example:

{
  "type": "real",
  "serverTimezone": "Europe/London",
  "name": "My Server Name",
  "url": "https://api.newserver.com:8880",
  "username": "admin",
  "password": "123456",
  "exchangeId": 1
}

In order for account registration to work, at least 1 rule must be configured. At the most basic level the following may be used, where:

  1. EXCHANGE_ID is the ID of the exchange (or trading platform) to register new accounts with
  2. GROUP_ID is the ID of the group on that platform to register the accounts into
[{
	"conditions": [{
		"all": [{
			"field": "exchangeId",
			"operator": "==",
			"value": <EXCHANGE_ID>
		}],
		"result": {
			"groupId": <GROUP_ID>
		}
	}]
}]

The serverGroups property is generally not needed as TradrAPI will automatically detect the groups which belong to the project you are creating and configure it with them. This is done by checking the groups which are set up on the relevant trading platform and cross-referencing them with the uid provided.

However, in case you do need to specify a list of groups this can be done using the serverGroups property.

Note that if these groups are not setup on the respective exchange, they will not work properly when creating accounts