Skip to content

Commit

Permalink
feat: add getDailyChange method
Browse files Browse the repository at this point in the history
  • Loading branch information
vansergen committed Aug 28, 2020
1 parent 6a0e916 commit ff0a1d7
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export interface IVersion {
version?: "2.0" | "3.0";
}

export interface ISymbolId extends IVersion {
symbolId: string | string[];
}

export interface IAccountSummaryOptions extends IVersion {
id: string;
date: string;
Expand All @@ -31,10 +35,10 @@ export interface IUserAccount {
}

export interface IDailyChange {
lastSessionClosePrice: string;
basePrice: string;
lastSessionClosePrice?: string | null;
basePrice?: string | null;
symbolId: string;
dailyChange: string;
dailyChange?: string | null;
}

export interface ICurrency {
Expand Down Expand Up @@ -124,14 +128,26 @@ export class RestClient {
/**
* Get the list of daily changes
*/
public async getDailyChanges({ version = "2.0" }: IVersion = {}): Promise<
IDailyChange[]
> {
public async getDailyChanges({
version = DefaultAPIVersion,
}: IVersion = {}): Promise<IDailyChange[]> {
const url = new URL(`/md/${version}/change`, this.url);
const changes = (await this.fetch(url)) as IDailyChange[];
return changes;
}

/**
* Get the list of daily changes for requested instruments
*/
public async getDailyChange({
version = DefaultAPIVersion,
symbolId,
}: ISymbolId): Promise<IDailyChange[]> {
const url = new URL(`/md/${version}/change/${symbolId}`, this.url);
const changes = (await this.fetch(url)) as IDailyChange[];
return changes;
}

/**
* Get the summary for the specified account.
*/
Expand Down

0 comments on commit ff0a1d7

Please sign in to comment.