Skip to content

Commit

Permalink
feat: more smart trade endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kirosc committed May 23, 2021
1 parent f71fc95 commit ed2b371
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3commas-typescript",
"version": "1.2.1",
"version": "1.2.2",
"description": "TypeScript 3Commas API client",
"repository": {
"type": "git",
Expand Down
26 changes: 26 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ed2b371

Please sign in to comment.