Skip to content

Commit

Permalink
feat: add the getActiveOrders method
Browse files Browse the repository at this point in the history
  • Loading branch information
vansergen committed Sep 9, 2020
1 parent 27d87da commit 9c0bc72
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,43 @@ export interface IOrdersOptionsV3 extends IBaseOrdersOptions {

export type IOrdersOptions = IOrdersOptionsV2 | IOrdersOptionsV3;

export interface IBaseActiveOrdersOptions extends IVersion {
/**
* Limit for max items of the order list
*/
limit?: string;
}

export interface IActiveOrdersOptionsV2 extends IBaseActiveOrdersOptions {
/**
* User's account
*/
account: string;
/**
* Instrument identifier
*/
instrument: string;
}

export interface IActiveOrdersOptionsV3 extends IBaseActiveOrdersOptions {
/**
* API version
*/
version: "3.0";
/**
* User's account
*/
accountId: string;
/**
* Instrument identifier
*/
symbolId: string;
}

export type IActiveOrdersOptions =
| IActiveOrdersOptionsV2
| IActiveOrdersOptionsV3;

export interface IUserAccount {
/**
* Account status
Expand Down Expand Up @@ -976,6 +1013,20 @@ export class RestClient {
return orders;
}

/**
* Get the list of active trading orders
*/
public async getActiveOrders({
version = DefaultAPIVersion,
...query
}: IActiveOrdersOptions): Promise<IOrder[]> {
const url = new URL(`/trade/${version}/orders/active`, this.url);
RestClient.setQuery(url, { ...query });

const orders = (await this.fetch(url)) as IOrder[];
return orders;
}

/**
* Get a JSON Web Token
*/
Expand Down

0 comments on commit 9c0bc72

Please sign in to comment.