-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplace-order.ts
56 lines (48 loc) · 1.25 KB
/
place-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
51
52
53
54
55
import Client, {Way} from '../src/node-client';
import '../env';
const main = async () => {
const client = new Client({
baseUrl: process.env.BASE_URL,
credentials: {
publicKey: process.env.PUBLIC_KEY as string,
privateKey: process.env.PRIVATE_KEY as string,
}
});
// place a limit buy order for BTC
const response = await client.placeOrder({
code: 'BTCEUR',
way: Way.Bid,
amount: 1,
price: 10
});
console.log(response);
// check order status
const orderResponse = await client.getOrder(response.clOrderId);
console.log(orderResponse.order.statusDesc);
// place a limit sell order
const sellResponse = await client.placeOrder({
code: 'BTCEUR',
way: Way.Ask,
amount: 1,
price: 20
});
console.log(sellResponse);
// to place a market buy order, don't specify the price
const marketBuyResponse = await client.placeOrder({
code: 'BTCEUR',
way: Way.Bid,
amount: 1,
});
console.log(marketBuyResponse);
// to place a market sell order, don't specify the price
const marketSellResponse = await client.placeOrder({
code: 'BTCEUR',
way: Way.Ask,
amount: 1,
});
console.log(marketSellResponse);
};
main().catch(e => {
console.error(e);
process.exit(1);
});