Skip to content

Commit

Permalink
feat: add the getPastTrades method
Browse files Browse the repository at this point in the history
  • Loading branch information
vansergen committed Feb 15, 2021
1 parent faade51 commit c2fc288
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/auth1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export interface DepositsWithdrawalsParams {
limit?: number;
}

export interface PastTradesParams {
symbol?: string;
timestamp?: string;
until?: string;
limit_trades?: number;
reverse?: number;
}

export interface ClaimParams {
position_id: number;
amount?: string;
Expand Down Expand Up @@ -288,6 +296,17 @@ export interface DepositWithdrawal {
fee: number;
}

export interface PastTrade {
price: string;
amount: string;
timestamp: string;
type: "Buy" | "Sell";
fee_currency: string;
fee_amount: string;
tid: number;
order_id: number;
}

export interface AuthenticatedClient1Options extends PublicClient1Params {
key: string;
secret: string;
Expand Down Expand Up @@ -552,6 +571,20 @@ export class AuthenticatedClient1 extends PublicClient1 {
return balances;
}

/** Get past trades. */
public async getPastTrades({
symbol = this.symbol,
...rest
}: PastTradesParams = {}): Promise<PastTrade[]> {
const request = "/v1/mytrades";
const trades = (await this.post(
request,
{},
{ ...rest, symbol }
)) as PastTrade[];
return trades;
}

public set nonce(nonce: () => number) {
this.#nonce = nonce;
}
Expand Down

0 comments on commit c2fc288

Please sign in to comment.