From ed2b371539855cbafb00cf08231854d2c03a2c72 Mon Sep 17 00:00:00 2001 From: kirosc Date: Sun, 23 May 2021 19:36:40 +0800 Subject: [PATCH] feat: more smart trade endpoint --- README.md | 11 +++++++++-- package-lock.json | 4 ++-- package.json | 2 +- src/index.ts | 26 ++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 237b070..33bc573 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ npm install 3commas-typescript import { API } from '3commas-typescript'; const api = new API({ - key: 'YOUR_KEY', - secrets: 'YOUR_SECRETS', + key: 'YOUR_KEY', // Optional if only query endpoints with no security requirement + secrets: 'YOUR_SECRETS', // Optional timeout: 60000, // Optional, in ms, default to 30000 errorHandler: (response, reject) => { // Optional, Custom handler for 3Commas error @@ -106,6 +106,13 @@ forceStartSmartTrade(id: number) forceProcessSmartTrade(id: number) setNoteSmartTrade(id: number, note: string) + +getSubTrade(id: number) + +closeSubTrade(smartTradeId: number, subTradeId: number) + +cancelSubTrade(smartTradeId: number, subTradeId: number) + ``` ### Bots diff --git a/package-lock.json b/package-lock.json index 3764e52..1f97228 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "3commas-typescript", - "version": "1.2.1", + "version": "1.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.2.1", + "version": "1.2.2", "license": "MIT", "dependencies": { "axios": "^0.21.1", diff --git a/package.json b/package.json index ff7963d..1b25f79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "3commas-typescript", - "version": "1.2.1", + "version": "1.2.2", "description": "TypeScript 3Commas API client", "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index 282f5ef..c8a73ca 100644 --- a/src/index.ts +++ b/src/index.ts @@ -273,6 +273,32 @@ export class API { }); } + /** + * Get the sub trades of a smart trade, including entry and take profit orders. + * + * @param id smart trade id + * @returns SmartTrade Order + */ + async getSubTrade(id: number) { + return await this.request('GET', 2, `/smart_trades/${id}/trades`); + } + + async closeSubTrade(smartTradeId: number, subTradeId: number) { + return await this.request( + 'POST', + 2, + `/smart_trades/${smartTradeId}/trades/${subTradeId}/close_by_market` + ); + } + + async cancelSubTrade(smartTradeId: number, subTradeId: number) { + return await this.request( + 'DELETE', + 2, + `/smart_trades/${smartTradeId}/trades/${subTradeId}` + ); + } + async getBots( params: BotsParams = { limit: 50,