-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathrest-private-futures.ts
37 lines (32 loc) · 1.1 KB
/
rest-private-futures.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
import { RestClientV2, WebsocketClient } from '../src/index';
// or
// import { RestClientV2 } from 'bitget-api';
// read from environmental variables
const API_KEY = process.env.API_KEY_COM;
const API_SECRET = process.env.API_SECRET_COM;
const API_PASS = process.env.API_PASS_COM;
const client = new RestClientV2({
apiKey: API_KEY,
apiSecret: API_SECRET,
apiPass: API_PASS,
// apiKey: 'apiKeyHere',
// apiSecret: 'apiSecretHere',
// apiPass: 'apiPassHere',
});
/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */
(async () => {
try {
const now = new Date();
const fromTime = new Date(now.getTime() - 24 * 60 * 60 * 1000);
console.log(
await client.getFuturesAccountBills({
productType: 'USDT-FUTURES',
startTime: fromTime.getTime() + '', // should be sent as a string
endTime: now.getTime() + '', // should be sent as a string
limit: '100',
}),
);
} catch (e) {
console.error('request failed: ', e);
}
})();