SDKs
JavaScript/Typescript
User Methods
Prop
Challenges

PROP Challenges

Getting A Challenge

To get a PROP challenge the get method should be used which is found under the sdk.prop.challenges namespace. This method takes a single argument, the challengeId of the challenge to retrieve.

Example

import { ChallengeDto } from '@tradrapi/trading-sdk';
 
const challengeId: number = 10433004323;
const challenge: ChallengeDto = await tradrApi.prop.challenges.get(challengeId);

The response from the create method will be the ChallengeDto object, which has the following properties:

interface ChallengeDto {
  /** The id of the challenge */
  challengeId: number;
  /** The name of the challenge */
  name: string;
  /** The description of the challenge */
  description?: string;
  /** The stage to assign to the challenge */
  stage: number;
  /** The id of the next challenge */
  nextChallengeId?: number;
  /** The type of challenge */
  type: 'CHALLENGE' | 'COMPETITION';
  /** The trading platform the challenge is for */
  platform: 'TL' | 'MT4' | 'MT5';
  /** Whether the challenge is active */
  isActive: boolean;
  /** Attributes of the challenge */
  attributes: ChallengeAttributesDto;
  /** Settings of the challenge */
  settings: ChallengeSettingsDto;
  /** Integrations of the challenge */
  integrations: ChallengeIntegrationsDto;
  /** Competition settings of the challenge */
  competitionSettings?: ChallengeCompetitionSettingsDto;
  /** Weekend holding settings of the challenge */
  weekendHoldingSettings?: ChallengeWeekendHoldingSettingsDto;
}
 
interface ChallengeAttributesDto {
  /** The allowed initial starting balances for enrollments to the challenge */
  initialBalances: number[];
  /** The allowed leverages for accounts enrolled into the challenge */
  allowedLeverages: number[];
  /** ISO4217 currency code */
  currency: string;
  /** Represents the percentage of profit to be shared with the trader e.g. 70% */
  profitSharePercent: number;
  /** Represents whether weekend holdings apply */
  allowWeekendHoldings: boolean;
  /** Represents the leverage multiplier (factor) for the account (default 1) */
  leverageMultiplier: number;
  /** Represents the mode of calculation for the account */
  calculationMode:
    | 'DD_EQUITY'
    | 'DD_BALANCE'
    | 'DD_MAX_EQUITY_BALANCE'
    | 'MAX_BALANCE_OVER_FLOATING_SL'
    | 'TDD_MAX_BALANCE_FLOAT_SL_DD_BALANCE'
    | 'TDD_MAX_BALANCE_FLOAT_SL_DD_MAX_EQUITY_BALANCE';
  /** Represents the maximum duration in days a challenge can last */
  maxDuration: number;
}
 
interface ChallengeSettingsDto {
  /** Represents the maximum number of days an account can be idle before being deleted */
  maxIdleDays?: number;
  /** The maximum daily drawdown allowed before failing */
  maxDailyDrawdownPercent: number;
  /** The maximum total drawdown allowed before failing */
  maxDrawdownPercent: number;
  /** The allowed maximum period return */
  maxPeriodReturn?: number;
  /** The profit target to be reached before passing */
  profitTargetPercent: number;
  /** The minimum number of days the account must have traded to pass */
  minDaysTraded: number;
}
 
interface ChallengeIntegrationsDto {
  /** The url to use as a webhook for sending challenge relevant events */
  webhookUrl?: string;
  /** The email to raise Dixa tickets to */
  dixaEmail?: string;
}
 
interface ChallengeCompetitionSettingsDto {
  /**
   * The start datetime of the competition
   * @format date-time
   */
  startsAt: string;
  /**
   * The datetime after which no more enrollments into the competition are allowed
   * @format date-time
   */
  blockEnrollmentsAt?: string;
  /** The prizes for the competition */
  prizes?: object[];
}
 
interface ChallengeWeekendHoldingSettingsDto {
  /**
   * The day of the week the trading should be re-opened. Uses UNIX cron format
   * @min 1
   * @max 7
   */
  openDay: number;
  /**
   * The hour of the day the trading should be re-opened. Uses UNIX cron format
   * @min 1
   * @max 23
   */
  openHour: number;
  /**
   * The day of the week the trading should be blocked. Uses UNIX cron format
   * @min 1
   * @max 7
   */
  closeDay: number;
  /**
   * The hour of the day the trading should be blocked. Uses UNIX cron format
   * @min 1
   * @max 23
   */
  closeHour: number;
}

Listing Challenges

To list PROP challenges the list method should be used which is found under the sdk.prop.challenges namespace. This method takes a single argument, an object containing the query parameters to filter the challenges by.

Example

import { ChallengeDto, ResponsePaginated } from '@tradrapi/trading-sdk';
 
const challenges: ResponsePaginated<ChallengeDto> = await tradrApi.prop.challenges.list({
  stage: 1,
  type: 'CHALLENGE',
  isActive: true,
  ...,
  page: 1,
  limit: 10
});

The ListChallengesDto object used in the above method has the following properties:

interface ListChallengesDto {
  /** The challenge ids to filter by */
  challengeIds?: number[];
  /**
   * Include challenges which are not active
   * @default false
   */
  incInactive?: boolean;
  /** The challenge types to filter by */
  challengeTypes?: ('CHALLENGE' | 'COMPETITION')[];
  /** The stages to filter by */
  stages?: number[];
  /** The platforms to filter by */
  platforms?: ('TL' | 'MT4' | 'MT5')[];
  /**
   * The page number to return
   * @min 1
   * @default 1
   */
  page?: number;
  /**
   * The number of records to return
   * @min 1
   * @default 30
   */
  limit?: number;
}

The response from the list method will be a paginated array of ChallengeDto objects, as defined in the previous section.

Creating A Challenge

To create a new PROP challenge the create method should be used which is found under the sdk.prop.challenges namespace.

The method which takes a single argument, an object containing the challenge details. The challenge details object should contain the following properties:

interface CreateChallengeDto {
  /** The name of the challenge */
  name: string;
  /** The next challenge id */
  description?: string;
  /**
   * The stage of the challenge.
   * @min 0
   */
  stage: number;
  /**
   * The next challenge id
   * @min 1
   */
  nextChallengeId?: number;
  /** The type of the challenge. */
  type: 'CHALLENGE' | 'COMPETITION';
  /** The group in which enrollments into the challenge will be placed. */
  group: string;
  /** The ID of the server in which enrollments into the challenge will be placed. */
  serverId: number;
  /**
   * Whether the created challenge will be immediately active.
   * @default true
   */
  isActive: boolean;
  /**
   * The allowed enrollment types for the challenge
   * @default "STANDARD"
   */
  enrollmentType: 'FREE_TRIAL' | 'STANDARD';
  /** The allowed initial starting balances for enrollments to the challenge */
  initialBalances: number[];
  /**
   * The allowed leverages for accounts enrolled into the challenge
   * @default [100]
   */
  allowedLeverages: number[];
  /**
   * The currency of the challenge.
   * @default "USD"
   */
  currency: string;
  /**
   * Represents whether weekend holdings apply
   * @default false
   */
  allowWeekendHoldings: boolean;
  /**
   * Represents the leverage multiplier (factor) for the account
   * @min 1
   * @default 1
   */
  leverageMultiplier: number;
  /**
   * Represents the percentage of profit to be shared with the trader e.g. 70%
   * @min 1
   * @max 100
   */
  profitSharePercent: number;
  /**
   * Represents the mode of calculation for the account
   * @default "DD_EQUITY"
   */
  calculationMode:
    | 'DD_EQUITY'
    | 'DD_BALANCE'
    | 'DD_MAX_EQUITY_BALANCE'
    | 'MAX_BALANCE_OVER_FLOATING_SL'
    | 'TDD_MAX_BALANCE_FLOAT_SL_DD_BALANCE'
    | 'TDD_MAX_BALANCE_FLOAT_SL_DD_MAX_EQUITY_BALANCE';
  /**
   * Represents the maximum duration in days a challenge can last
   * @min 1
   */
  maxDuration: number;
  /**
   * Represents the maximum number of days an account can be idle before being deleted
   * @min 1
   */
  maxIdleDays?: number;
  /**
   * The maximum daily drawdown percentage allowed before failing
   * @min 1
   * @max 100
   */
  maxDailyDrawdownPercent: number;
  /**
   * The maximum total drawdown percentage allowed before failing
   * @min 1
   * @max 100
   */
  maxDrawdownPercent: number;
  /**
   * The allowed maximum period return
   * @min 1
   */
  maxPeriodReturn?: number;
  /**
   * The profit target to be reached before passing
   * @min 1
   * @max 500
   */
  profitTargetPercent: number;
  /**
   * The minimum number of days the account must have traded to pass
   * @min 1
   */
  minDaysTraded?: number;
  /** The integrations settings for the challenge */
  integrations?: ChallengeIntegrationsDto;
  /** The competition settings for the challenge */
  competitionSettings?: ChallengeCompetitionSettingsDto;
  /** The weekend holding settings for the challenge */
  weekendHoldingSettings?: ChallengeWeekendHoldingSettingsDto;
}
 
interface ChallengeIntegrationsDto {
  /** The url to use as a webhook for sending challenge relevant events */
  webhookUrl?: string;
  /** The email to raise Dixa tickets to */
  dixaEmail?: string;
}
 
interface ChallengeCompetitionSettingsDto {
  /**
   * The start datetime of the competition
   * @format date-time
   */
  startsAt: string;
  /**
   * The datetime after which no more enrollments into the competition are allowed
   * @format date-time
   */
  blockEnrollmentsAt?: string;
  /** The prizes for the competition */
  prizes?: object[];
}
 
interface ChallengeWeekendHoldingSettingsDto {
  /**
   * The day of the week the trading should be re-opened. Uses UNIX cron format
   * @min 1
   * @max 7
   */
  openDay: number;
  /**
   * The hour of the day the trading should be re-opened. Uses UNIX cron format
   * @min 1
   * @max 23
   */
  openHour: number;
  /**
   * The day of the week the trading should be blocked. Uses UNIX cron format
   * @min 1
   * @max 7
   */
  closeDay: number;
  /**
   * The hour of the day the trading should be blocked. Uses UNIX cron format
   * @min 1
   * @max 23
   */
  closeHour: number;
}
ℹ️️
The weekend holdings days are cron based with 0/7 being a Sunday, 1 Monday, etc.

Example

import { ChallengeDto } from '@tradrapi/trading-sdk';
 
 
const challenge: ChallengeDto = await tradrApi.prop.challenges.create({
  name: 'My first challenge',
  stage: 1,
  ...
});

A new challenge can be linked to an existing challenge by setting the nextChallengeId property to the challengeId of the existing challenge. Doing so will allow the new challenge to be unlocked once the existing challenge is completed.

The response from the create method will be the ChallengeDto object, as defined in the previous section.

Updating An Existing Challenge

To update a PROP challenge the update method should be used which is found under the sdk.prop.challenges namespace.

Example

import { ChallengeDto } from '@tradrapi/trading-sdk';
 
const challengeId: number = 10433004323;
const challenge: ChallengeDto = await tradrApi.prop.challenges.update(challengeId, {
  name: 'My first challenge',
  stage: 2,
  ...
});

The response from the update method will be the ChallengeDto object, as defined in the previous section.

Deleting An Existing Challenge

To delete a PROP challenge the delete method should be used which is found under the sdk.prop.challenges namespace.

ℹ️️
A challenge which has active enrollments cannot be deleted.

Example

const challengeId: number = 10433004323;
await tradrApi.prop.challenges.delete(challengeId);