forked from CryptoGnome/Bybit-Lick-Hunter-v4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.js
51 lines (42 loc) · 1.19 KB
/
order.js
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
import { env } from 'process';
export async function createMarketOrder(linearClient, pair, side, size, take_profit = 0, stop_loss = 0) {
var cfg = {
side: side,
order_type: "Market",
symbol: pair,
qty: size,
time_in_force: "GoodTillCancel",
reduce_only: false,
close_on_trigger: false
};
if (take_profit != 0)
cfg['take_profit'] = take_profit;
if (stop_loss != 0)
cfg['stop_loss'] = stop_loss;
// send order payload
const order = await linearClient.placeActiveOrder(cfg);
return order;
}
export async function createLimitOrder(linearClient, pair, side, size, price, take_profit = 0, stop_loss = 0) {
var cfg = {
side: side,
order_type: "Limit",
symbol: pair,
qty: size,
time_in_force: "GoodTillCancel",
reduce_only: false,
close_on_trigger: false,
price: price
};
if (take_profit != 0)
cfg['take_profit'] = take_profit;
if (stop_loss != 0)
cfg['stop_loss'] = stop_loss;
// send order payload
const order = await linearClient.placeActiveOrder(cfg);
return order;
}
export async function cancelOrder(linearClient, pair, id) {
res = await linearClient.cancelOrder({pair: pair, orderId: id});
return res;
}