diff --git a/README.md b/README.md index 58769e0..237b070 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,16 @@ forceProcessSmartTrade(id: number) setNoteSmartTrade(id: number, note: string) ``` +### Bots + +```ts +getBots(params?: BotsParams) + +getBotsStats(params?: BotsStatsParams) + +getDeals(params?: DealsParams) +``` + ## Response Type The Order type returned by smart trade endpoint is generated using [quicktype](https://github.com/quicktype/quicktype). diff --git a/src/index.ts b/src/index.ts index 414be43..94daad3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,9 @@ import Axios, { AxiosError, AxiosInstance } from 'axios'; import qs from 'qs'; import { APIOptions, + BotsParams, + BotsStatsParams, + DealsParams, SmartTradeHistoryParams, SmartTradeParams, ThreeCommasError, @@ -268,6 +271,30 @@ export class API { }); } + async getBots( + params: BotsParams = { + limit: 50, + sort_by: 'created_at', + sort_direction: 'desc', + } + ) { + return await this.request('GET', 1, '/bots', params); + } + + async getBotsStats(params?: BotsStatsParams) { + return await this.request('GET', 1, '/bots/stats', params); + } + + async getDeals( + params: DealsParams = { + limit: 50, + order: 'created_at', + order_direction: 'desc', + } + ) { + return await this.request('GET', 1, '/deals', params); + } + /** * Validate the response order is consistent with the generated type * Or, an error is thrown diff --git a/src/types/types.ts b/src/types/types.ts index c9bd952..766857a 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -16,6 +16,39 @@ export interface ThreeCommasError { }; } +export interface BotsParams { + limit?: number; // Max 100 + offset?: number; + account_id?: number; + scope?: 'enabled' | 'disabled'; + strategy?: 'long' | 'short'; + sort_by?: 'profit' | 'created_at' | 'updated_at'; + sort_direction?: 'asc' | 'desc'; + quote?: string; +} + +export interface BotsStatsParams { + account_id?: number; + bot_id?: number; +} + +export interface DealsParams { + limit?: number; // Max 1000 + offset?: number; + account_id?: number; + bot_id?: number; + scope?: 'active' | 'finished' | 'completed' | 'cancelled' | 'failed'; + order?: + | 'created_at' + | 'updated_at' + | 'closed_at' + | 'profit' + | 'profit_percentage'; + order_direction?: 'asc' | 'desc'; + base?: string; + quote?: string; +} + export interface TransferParams { currency: string; amount: number | string;