Skip to content

Commit

Permalink
Merge pull request #21 from JJ-Cro/Update031024
Browse files Browse the repository at this point in the history
feat(): added new endpoints, updated existing endpoints
  • Loading branch information
tiagosiebler authored Oct 3, 2024
2 parents 5edf4f2 + e9af51c commit f27221a
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
12 changes: 8 additions & 4 deletions docs/endpointFunctionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</a>
</p>

Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.
Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.

The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.

Expand Down Expand Up @@ -45,7 +45,7 @@ Table consists of 4 parts:

# RestClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [RestClient.ts](/src/RestClient.ts).
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [RestClient.ts](/src/RestClient.ts).

| Function | AUTH | HTTP Method | Endpoint |
| -------- | :------: | :------: | -------- |
Expand Down Expand Up @@ -138,7 +138,7 @@ This table includes all endpoints from the official Exchange API docs and corres

# FuturesClientV2.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [FuturesClientV2.ts](/src/FuturesClientV2.ts).
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [FuturesClientV2.ts](/src/FuturesClientV2.ts).

| Function | AUTH | HTTP Method | Endpoint |
| -------- | :------: | :------: | -------- |
Expand All @@ -165,11 +165,15 @@ This table includes all endpoints from the official Exchange API docs and corres
| `cancelFuturesPlanOrder()` | :closed_lock_with_key: | POST | `contract/private/cancel-plan-order` |
| `submitFuturesTransfer()` | :closed_lock_with_key: | POST | `account/v1/transfer-contract` |
| `setFuturesLeverage()` | :closed_lock_with_key: | POST | `contract/private/submit-leverage` |
| `submitFuturesTPSLOrder()` | :closed_lock_with_key: | POST | `contract/private/submit-tp-sl-order` |
| `updateFuturesPlanOrder()` | :closed_lock_with_key: | POST | `contract/private/modify-plan-order` |
| `updateFuturesPresetPlanOrder()` | :closed_lock_with_key: | POST | `contract/private/modify-preset-plan-order` |
| `updateFuturesTPSLOrder()` | :closed_lock_with_key: | POST | `contract/private/modify-tp-sl-order` |
| `submitFuturesSubToMainTransferFromMain()` | :closed_lock_with_key: | POST | `account/contract/sub-account/main/v1/sub-to-main` |
| `submitFuturesMainToSubTransferFromMain()` | :closed_lock_with_key: | POST | `account/contract/sub-account/main/v1/main-to-sub` |
| `submitFuturesSubToMainSubFromSub()` | :closed_lock_with_key: | POST | `account/contract/sub-account/sub/v1/sub-to-main` |
| `getFuturesSubWallet()` | :closed_lock_with_key: | GET | `account/contract/sub-account/main/v1/wallet` |
| `getFuturesSubTransfers()` | :closed_lock_with_key: | GET | `account/contract/sub-account/main/v1/transfer-list` |
| `getFuturesSubTransferHistory()` | :closed_lock_with_key: | GET | `account/contract/sub-account/v1/transfer-history` |
| `getFuturesAffiliateRebates()` | :closed_lock_with_key: | GET | `contract/private/affiliate/rebate-list` |
| `getFuturesAffiliateTrades()` | :closed_lock_with_key: | GET | `contract/private/affiliate/trade-list` |
| `getFuturesAffiliateTrades()` | :closed_lock_with_key: | GET | `contract/private/affiliate/trade-list` |
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": "bitmart-api",
"version": "2.1.4",
"version": "2.1.5",
"description": "Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.",
"scripts": {
"clean": "rm -rf dist/*",
Expand Down
42 changes: 42 additions & 0 deletions src/FuturesClientV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ import {
SubmitFuturesOrderRequest,
SubmitFuturesPlanOrderRequest,
SubmitFuturesSubToMainSubFromSubRequest,
SubmitFuturesTPSLOrderRequest,
SubmitFuturesTransferRequest,
TransferFuturesAssetsRequest,
UpdateFuturesPlanOrderRequest,
UpdateFuturesPresetPlanOrderRequest,
UpdateFuturesTPSLOrderRequest,
} from './types/request/futures.types.js';
import {
FuturesAccountAsset,
Expand Down Expand Up @@ -241,6 +245,44 @@ export class FuturesClientV2 extends BaseRestClient {
return this.postPrivate('contract/private/submit-leverage', params);
}

submitFuturesTPSLOrder(params: SubmitFuturesTPSLOrderRequest): Promise<
APIResponse<{
order_id: string;
client_order_id?: string;
}>
> {
return this.postPrivate('contract/private/submit-tp-sl-order', params);
}

updateFuturesPlanOrder(params: UpdateFuturesPlanOrderRequest): Promise<
APIResponse<{
order_id: string;
}>
> {
return this.postPrivate('contract/private/modify-plan-order', params);
}

updateFuturesPresetPlanOrder(
params: UpdateFuturesPresetPlanOrderRequest,
): Promise<
APIResponse<{
order_id: string;
}>
> {
return this.postPrivate(
'contract/private/modify-preset-plan-order',
params,
);
}

updateFuturesTPSLOrder(params: UpdateFuturesTPSLOrderRequest): Promise<
APIResponse<{
order_id: string;
}>
> {
return this.postPrivate('contract/private/modify-tp-sl-order', params);
}

/**
*
* Futures Sub-Account Endpoints
Expand Down
45 changes: 45 additions & 0 deletions src/types/request/futures.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface FuturesKlinesRequest {
export interface FuturesAccountOrderRequest {
symbol: string;
order_id: string;
client_order_id?: string;
}

export interface FuturesAccountHistoricOrderRequest {
Expand All @@ -27,6 +28,7 @@ export interface FuturesAccountPlanOrdersRequest {
symbol?: string;
type?: 'limit' | 'market';
limit?: number;
plan_type?: 'plan' | 'profit_loss';
}

export interface FuturesAccountTradesRequest {
Expand Down Expand Up @@ -137,3 +139,46 @@ export interface FuturesAffiliateTradesRequest {
start_time: number;
end_time: number;
}

export interface SubmitFuturesTPSLOrderRequest {
symbol: string;
type: 'take_profit' | 'stop_loss';
side: 2 | 3;
size?: number;
trigger_price: string;
executive_price: string;
price_type: 1 | 2;
plan_category?: 1 | 2;
client_order_id?: string;
category?: 'limit' | 'market';
}

export interface UpdateFuturesPlanOrderRequest {
symbol: string;
order_id?: string;
client_order_id?: string;
trigger_price: string;
executive_price?: string;
price_type: 1 | 2;
type: 'limit' | 'market';
}

export interface UpdateFuturesPresetPlanOrderRequest {
order_id: string;
symbol: string;
preset_take_profit_price_type?: 1 | 2;
preset_stop_loss_price_type?: 1 | 2;
preset_take_profit_price?: string;
preset_stop_loss_price?: string;
}

export interface UpdateFuturesTPSLOrderRequest {
symbol: string;
order_id?: string;
client_order_id?: string;
trigger_price: string;
executive_price?: string;
price_type: 1 | 2;
plan_category?: 1 | 2;
category?: 'limit' | 'market';
}

0 comments on commit f27221a

Please sign in to comment.