-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspot-submit-order.ts
50 lines (43 loc) · 1.16 KB
/
spot-submit-order.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { RestClient } from '../src';
// import from npm, after installing via npm `npm install bitmart-api`
// import { RestClient } from 'bitmart-api';
const account = {
key: process.env.API_KEY || 'apiKeyHere',
secret: process.env.API_SECRET || 'apiSecretHere',
memo: process.env.API_MEMO || 'apiMemoHere',
};
async function start() {
const client = new RestClient({
apiKey: account.key,
apiSecret: account.secret,
apiMemo: account.memo,
});
try {
// const usdValue = 6;
// const price = 52000;
// const qty = usdValue / price;
// const limitBuyOrder = {
// symbol: 'BTC_USDT',
// side: 'buy',
// type: 'limit',
// size: String(qty),
// price: String(price),
// };
// const res = await client.submitSpotOrder({
// symbol: 'BTC_USDT',
// side: 'buy',
// type: 'market',
// size: String(qty),
// });
const res = await client.submitSpotOrderV2({
symbol: 'BTC_USDT',
side: 'sell',
type: 'market',
size: String(0.00011),
});
console.log('res ', JSON.stringify(res, null, 2));
} catch (e) {
console.error(`Req error: `, e);
}
}
start();