n8n-nodes-tk-modify-orders 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -0
- package/dist/credentials/BitgetTKApi.credentials.d.ts +8 -0
- package/dist/credentials/BitgetTKApi.credentials.d.ts.map +1 -0
- package/dist/credentials/BitgetTKApi.credentials.js +41 -0
- package/dist/credentials/BitgetTKApi.credentials.js.map +1 -0
- package/dist/nodes/BitgetTK/BitgetHelper.d.ts +10 -0
- package/dist/nodes/BitgetTK/BitgetHelper.d.ts.map +1 -0
- package/dist/nodes/BitgetTK/BitgetHelper.js +84 -0
- package/dist/nodes/BitgetTK/BitgetHelper.js.map +1 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyOrder.node.d.ts +6 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyOrder.node.d.ts.map +1 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyOrder.node.js +523 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyOrder.node.js.map +1 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyPosition.node.d.ts +6 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyPosition.node.d.ts.map +1 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyPosition.node.js +769 -0
- package/dist/nodes/BitgetTK/BitgetTKModifyPosition.node.js.map +1 -0
- package/dist/nodes/BitgetTK/BitgetTKPlaceOrder.node.d.ts +6 -0
- package/dist/nodes/BitgetTK/BitgetTKPlaceOrder.node.d.ts.map +1 -0
- package/dist/nodes/BitgetTK/BitgetTKPlaceOrder.node.js +311 -0
- package/dist/nodes/BitgetTK/BitgetTKPlaceOrder.node.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# n8n-nodes-tk-modify-orders
|
|
2
|
+
|
|
3
|
+
A custom n8n node package for the **Bitget Exchange** (Futures/Contracts).
|
|
4
|
+
Includes **all parameters** from the official Bitget API v2 for placing, modifying orders, and managing open positions.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Nodes Included
|
|
9
|
+
|
|
10
|
+
| Node | Operation |
|
|
11
|
+
|---|---|
|
|
12
|
+
| **Bitget TK – Place Order** | Place a new futures order (all order types, TP/SL presets, STP) |
|
|
13
|
+
| **Bitget TK – Modify Open Order** | Modify pending regular orders, trigger/plan orders, or TP/SL orders |
|
|
14
|
+
| **Bitget TK – Modify Open Position** | Change leverage, margin, margin mode, position mode, set TP/SL, flash close |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### From npm (once published)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cd ~/.n8n/custom
|
|
24
|
+
npm install n8n-nodes-tk-modify-orders
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Manual Installation (local development)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 1. Clone / copy this folder to your n8n custom nodes directory
|
|
31
|
+
cp -r n8n-nodes-tk-modify-orders ~/.n8n/custom/
|
|
32
|
+
|
|
33
|
+
# 2. Install and build
|
|
34
|
+
cd ~/.n8n/custom/n8n-nodes-tk-modify-orders
|
|
35
|
+
npm install
|
|
36
|
+
npm run build
|
|
37
|
+
|
|
38
|
+
# 3. Restart n8n
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Build from Source (TypeScript)
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install
|
|
45
|
+
npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Credentials Setup
|
|
51
|
+
|
|
52
|
+
In n8n, create a new credential of type **Bitget TK API** and fill in:
|
|
53
|
+
|
|
54
|
+
| Field | Description |
|
|
55
|
+
|---|---|
|
|
56
|
+
| API Key | Your Bitget API Key |
|
|
57
|
+
| Secret Key | Your Bitget Secret Key |
|
|
58
|
+
| Passphrase | The passphrase set when creating your API key |
|
|
59
|
+
|
|
60
|
+
> Generate credentials at: Bitget → Settings → API Management
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Node Reference
|
|
65
|
+
|
|
66
|
+
### 1. Bitget TK – Place Order
|
|
67
|
+
|
|
68
|
+
**Endpoint:** `POST /api/v2/mix/order/place-order`
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Required | Description |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| symbol | string | ✅ | e.g. `BTCUSDT` |
|
|
73
|
+
| productType | select | ✅ | USDT-FUTURES, COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, SUSDC-FUTURES |
|
|
74
|
+
| marginMode | select | ✅ | `isolated` / `crossed` |
|
|
75
|
+
| marginCoin | string | ✅ | e.g. `USDT` |
|
|
76
|
+
| side | select | ✅ | `buy` / `sell` |
|
|
77
|
+
| tradeSide | select | — | `open` / `close` (hedge mode only) |
|
|
78
|
+
| orderType | select | ✅ | `limit` / `market` |
|
|
79
|
+
| size | string | ✅ | Order quantity |
|
|
80
|
+
| price | string | for limit | Limit price |
|
|
81
|
+
| force | select | — | `gtc` / `ioc` / `fok` / `post_only` |
|
|
82
|
+
| clientOid | string | — | Custom order ID (recommended) |
|
|
83
|
+
| reduceOnly | select | — | `NO` / `YES` |
|
|
84
|
+
| presetStopSurplusPrice | string | — | Preset TP trigger price |
|
|
85
|
+
| presetStopSurplusExecutePrice | string | — | Preset TP execute price |
|
|
86
|
+
| presetStopSurplusTriggerType | select | — | `fill_price` / `mark_price` / `index_price` |
|
|
87
|
+
| presetStopLossPrice | string | — | Preset SL trigger price |
|
|
88
|
+
| presetStopLossExecutePrice | string | — | Preset SL execute price |
|
|
89
|
+
| presetStopLossTriggerType | select | — | `fill_price` / `mark_price` / `index_price` |
|
|
90
|
+
| stpMode | select | — | Self-trade prevention: `cancel_maker` / `cancel_taker` / `cancel_both` |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### 2. Bitget TK – Modify Open Order
|
|
95
|
+
|
|
96
|
+
Choose the **Order Operation**:
|
|
97
|
+
|
|
98
|
+
#### A) Modify Regular Order
|
|
99
|
+
**Endpoint:** `POST /api/v2/mix/order/modify-order`
|
|
100
|
+
|
|
101
|
+
| Parameter | Description |
|
|
102
|
+
|---|---|
|
|
103
|
+
| symbol, productType, marginCoin | Identify the market |
|
|
104
|
+
| orderId / clientOid | Identify the order (at least one required) |
|
|
105
|
+
| newClientOid | Reassign a new client ID |
|
|
106
|
+
| newPrice | New limit price |
|
|
107
|
+
| newSize | New quantity |
|
|
108
|
+
| newPresetStopSurplusPrice | Update attached TP price |
|
|
109
|
+
| newPresetStopLossPrice | Update attached SL price |
|
|
110
|
+
|
|
111
|
+
#### B) Modify Trigger / Plan Order
|
|
112
|
+
**Endpoint:** `POST /api/v2/mix/order/modify-plan-order`
|
|
113
|
+
|
|
114
|
+
| Parameter | Description |
|
|
115
|
+
|---|---|
|
|
116
|
+
| planType | `normal_plan` (trigger) / `track_plan` (trailing stop) |
|
|
117
|
+
| orderId / clientOid | Identify the order |
|
|
118
|
+
| newSize | New quantity |
|
|
119
|
+
| newPrice | New execution price |
|
|
120
|
+
| newTriggerPrice | New trigger price |
|
|
121
|
+
| newTriggerType | `fill_price` / `mark_price` / `index_price` |
|
|
122
|
+
| newCallbackRatio | Trailing ratio (%) for `track_plan` |
|
|
123
|
+
| newStopSurplusTriggerPrice / Type / ExecutePrice | Attached TP modification |
|
|
124
|
+
| newStopLossTriggerPrice / Type / ExecutePrice | Attached SL modification |
|
|
125
|
+
|
|
126
|
+
#### C) Modify TP/SL Order
|
|
127
|
+
**Endpoint:** `POST /api/v2/mix/order/modify-tpsl-order`
|
|
128
|
+
|
|
129
|
+
| Parameter | Description |
|
|
130
|
+
|---|---|
|
|
131
|
+
| orderId / clientOid | Identify the order |
|
|
132
|
+
| triggerPrice | New trigger price |
|
|
133
|
+
| triggerType | `fill_price` / `mark_price` / `index_price` |
|
|
134
|
+
| executePrice | New execution price (`0` = market) |
|
|
135
|
+
| size | New quantity |
|
|
136
|
+
| rangeRate | Trailing % for trailing TP/SL |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### 3. Bitget TK – Modify Open Position
|
|
141
|
+
|
|
142
|
+
Choose the **Position Operation**:
|
|
143
|
+
|
|
144
|
+
| Operation | Endpoint | Key Parameters |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| Change Leverage | `POST /api/v2/mix/account/set-leverage` | symbol, productType, marginCoin, leverage, holdSide (long/short for hedge) |
|
|
147
|
+
| Adjust Position Margin | `POST /api/v2/mix/account/set-margin` | symbol, productType, marginCoin, amount (+/-), holdSide |
|
|
148
|
+
| Change Margin Mode | `POST /api/v2/mix/account/set-margin-mode` | symbol, productType, marginCoin, marginMode (isolated/crossed) |
|
|
149
|
+
| Change Position Mode | `POST /api/v2/mix/account/set-position-mode` | productType, posMode (one_way_mode/hedge_mode) |
|
|
150
|
+
| Set Position TP/SL | `POST /api/v2/mix/order/place-pos-tpsl` | symbol, holdSide, stopSurplus + stopLoss trigger/execute/type prices, custom clientOids |
|
|
151
|
+
| Place Single TP/SL | `POST /api/v2/mix/order/place-tpsl-order` | planType, symbol, holdSide, triggerPrice, triggerType, executePrice, size, rangeRate |
|
|
152
|
+
| Flash Close Position | `POST /api/v2/mix/order/close-positions` | symbol, productType, holdSide (or both), clientOid |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Position Mode Guide
|
|
157
|
+
|
|
158
|
+
**One-Way Mode:**
|
|
159
|
+
- `side=buy` → Opens long OR closes short
|
|
160
|
+
- `side=sell` → Opens short OR closes long
|
|
161
|
+
- Use `reduceOnly=YES` to force close-only
|
|
162
|
+
|
|
163
|
+
**Hedge Mode:**
|
|
164
|
+
- `side=buy` + `tradeSide=open` → Open long
|
|
165
|
+
- `side=buy` + `tradeSide=close` → Close long
|
|
166
|
+
- `side=sell` + `tradeSide=open` → Open short
|
|
167
|
+
- `side=sell` + `tradeSide=close` → Close short
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Rate Limits
|
|
172
|
+
|
|
173
|
+
All endpoints: **10 requests/second per UID**
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## API Reference
|
|
178
|
+
|
|
179
|
+
- [Bitget API v2 Docs](https://www.bitget.com/api-doc/common/intro)
|
|
180
|
+
- [Place Order](https://www.bitget.com/api-doc/contract/trade/Place-Order)
|
|
181
|
+
- [Modify Order](https://www.bitget.com/api-doc/contract/trade/Modify-Order)
|
|
182
|
+
- [Modify Trigger Order](https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order)
|
|
183
|
+
- [Modify TPSL Order](https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order)
|
|
184
|
+
- [Flash Close](https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position)
|
|
185
|
+
- [Set Leverage](https://www.bitget.com/api-doc/contract/account/Change-Leverage)
|
|
186
|
+
- [Set Margin](https://www.bitget.com/api-doc/contract/account/Change-Margin)
|
|
187
|
+
- [Set Margin Mode](https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode)
|
|
188
|
+
- [Set Position Mode](https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode)
|
|
189
|
+
- [Place Pos TPSL](https://www.bitget.com/api-doc/contract/plan/Place-Pos-Tpsl-Order)
|
|
190
|
+
- [Place TPSL Order](https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order)
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class BitgetTKApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=BitgetTKApi.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitgetTKApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/BitgetTKApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,qBAAa,WAAY,YAAW,eAAe;IACjD,IAAI,SAAiB;IACrB,WAAW,SAAmB;IAC9B,gBAAgB,SAAiD;IACjE,UAAU,EAAE,eAAe,EAAE,CA4B3B;CACH"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitgetTKApi = void 0;
|
|
4
|
+
class BitgetTKApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'bitgetTKApi';
|
|
7
|
+
this.displayName = 'Bitget TK API';
|
|
8
|
+
this.documentationUrl = 'https://www.bitget.com/api-doc/common/intro';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Key',
|
|
12
|
+
name: 'apiKey',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
default: '',
|
|
16
|
+
required: true,
|
|
17
|
+
description: 'Your Bitget API Key',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Secret Key',
|
|
21
|
+
name: 'secretKey',
|
|
22
|
+
type: 'string',
|
|
23
|
+
typeOptions: { password: true },
|
|
24
|
+
default: '',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'Your Bitget Secret Key',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Passphrase',
|
|
30
|
+
name: 'passphrase',
|
|
31
|
+
type: 'string',
|
|
32
|
+
typeOptions: { password: true },
|
|
33
|
+
default: '',
|
|
34
|
+
required: true,
|
|
35
|
+
description: 'Your Bitget API Passphrase',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.BitgetTKApi = BitgetTKApi;
|
|
41
|
+
//# sourceMappingURL=BitgetTKApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitgetTKApi.credentials.js","sourceRoot":"","sources":["../../credentials/BitgetTKApi.credentials.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAAxB;QACE,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,eAAe,CAAC;QAC9B,qBAAgB,GAAG,6CAA6C,CAAC;QACjE,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,qBAAqB;aACnC;YACD;gBACE,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,wBAAwB;aACtC;YACD;gBACE,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,4BAA4B;aAC1C;SACF,CAAC;IACJ,CAAC;CAAA;AAjCD,kCAiCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface BitgetCredentials {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
secretKey: string;
|
|
4
|
+
passphrase: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createSignature(timestamp: string, method: string, requestPath: string, body: string, secretKey: string): string;
|
|
7
|
+
export declare function buildHeaders(credentials: BitgetCredentials, method: string, requestPath: string, body: string): Record<string, string>;
|
|
8
|
+
export declare function bitgetRequest(credentials: BitgetCredentials, method: 'GET' | 'POST', endpoint: string, body?: Record<string, unknown>): Promise<unknown>;
|
|
9
|
+
export declare function cleanBody(obj: Record<string, unknown>): Record<string, unknown>;
|
|
10
|
+
//# sourceMappingURL=BitgetHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitgetHelper.d.ts","sourceRoot":"","sources":["../../../nodes/BitgetTK/BitgetHelper.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,MAAM,CAMR;AAED,wBAAgB,YAAY,CAC1B,WAAW,EAAE,iBAAiB,EAC9B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWxB;AAED,wBAAsB,aAAa,CACjC,WAAW,EAAE,iBAAiB,EAC9B,MAAM,EAAE,KAAK,GAAG,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,OAAO,CAAC,CAelB;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS/E"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createSignature = createSignature;
|
|
37
|
+
exports.buildHeaders = buildHeaders;
|
|
38
|
+
exports.bitgetRequest = bitgetRequest;
|
|
39
|
+
exports.cleanBody = cleanBody;
|
|
40
|
+
const crypto = __importStar(require("crypto"));
|
|
41
|
+
function createSignature(timestamp, method, requestPath, body, secretKey) {
|
|
42
|
+
const message = timestamp + method.toUpperCase() + requestPath + body;
|
|
43
|
+
return crypto
|
|
44
|
+
.createHmac('sha256', secretKey)
|
|
45
|
+
.update(message)
|
|
46
|
+
.digest('base64');
|
|
47
|
+
}
|
|
48
|
+
function buildHeaders(credentials, method, requestPath, body) {
|
|
49
|
+
const timestamp = Date.now().toString();
|
|
50
|
+
const sign = createSignature(timestamp, method, requestPath, body, credentials.secretKey);
|
|
51
|
+
return {
|
|
52
|
+
'ACCESS-KEY': credentials.apiKey,
|
|
53
|
+
'ACCESS-SIGN': sign,
|
|
54
|
+
'ACCESS-TIMESTAMP': timestamp,
|
|
55
|
+
'ACCESS-PASSPHRASE': credentials.passphrase,
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
'locale': 'en-US',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function bitgetRequest(credentials, method, endpoint, body = {}) {
|
|
61
|
+
const baseUrl = 'https://api.bitget.com';
|
|
62
|
+
const bodyString = method === 'POST' ? JSON.stringify(body) : '';
|
|
63
|
+
const headers = buildHeaders(credentials, method, endpoint, bodyString);
|
|
64
|
+
const url = baseUrl + endpoint;
|
|
65
|
+
const response = await fetch(url, {
|
|
66
|
+
method,
|
|
67
|
+
headers,
|
|
68
|
+
body: method === 'POST' ? bodyString : undefined,
|
|
69
|
+
});
|
|
70
|
+
const data = await response.json();
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
// Remove keys with undefined or empty string values to avoid sending blank fields
|
|
74
|
+
function cleanBody(obj) {
|
|
75
|
+
const result = {};
|
|
76
|
+
for (const key of Object.keys(obj)) {
|
|
77
|
+
const v = obj[key];
|
|
78
|
+
if (v !== undefined && v !== '' && v !== null) {
|
|
79
|
+
result[key] = v;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=BitgetHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitgetHelper.js","sourceRoot":"","sources":["../../../nodes/BitgetTK/BitgetHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,0CAYC;AAED,oCAgBC;AAED,sCAoBC;AAGD,8BASC;AAxED,+CAAiC;AAQjC,SAAgB,eAAe,CAC7B,SAAiB,EACjB,MAAc,EACd,WAAmB,EACnB,IAAY,EACZ,SAAiB;IAEjB,MAAM,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,WAAW,GAAG,IAAI,CAAC;IACtE,OAAO,MAAM;SACV,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC/B,MAAM,CAAC,OAAO,CAAC;SACf,MAAM,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC;AAED,SAAgB,YAAY,CAC1B,WAA8B,EAC9B,MAAc,EACd,WAAmB,EACnB,IAAY;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC1F,OAAO;QACL,YAAY,EAAE,WAAW,CAAC,MAAM;QAChC,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,SAAS;QAC7B,mBAAmB,EAAE,WAAW,CAAC,UAAU;QAC3C,cAAc,EAAE,kBAAkB;QAClC,QAAQ,EAAE,OAAO;KAClB,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,aAAa,CACjC,WAA8B,EAC9B,MAAsB,EACtB,QAAgB,EAChB,OAAgC,EAAE;IAElC,MAAM,OAAO,GAAG,wBAAwB,CAAC;IACzC,MAAM,UAAU,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAExE,MAAM,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC;IAE/B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM;QACN,OAAO;QACP,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACjD,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,kFAAkF;AAClF,SAAgB,SAAS,CAAC,GAA4B;IACpD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class BitgetTKModifyOrder implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=BitgetTKModifyOrder.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitgetTKModifyOrder.node.d.ts","sourceRoot":"","sources":["../../../nodes/BitgetTK/BitgetTKModifyOrder.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EAErB,MAAM,cAAc,CAAC;AAItB,qBAAa,mBAAoB,YAAW,SAAS;IACnD,WAAW,EAAE,oBAAoB,CA6b/B;IAEI,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAgFxE"}
|