forked from singlesly/bingx-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrade.service.ts
More file actions
97 lines (88 loc) · 2.96 KB
/
Copy pathtrade.service.ts
File metadata and controls
97 lines (88 loc) · 2.96 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { RequestExecutorInterface } from 'bingx-api/bingx/request-executor/request-executor.interface';
import { BingxCreateTradeOrderInterface } from 'bingx-api/bingx/interfaces/trade-order.interface';
import { AccountInterface } from 'bingx-api/bingx/account/account.interface';
import { BingxTradeOrderEndpoint } from 'bingx-api/bingx/endpoints/bingx-trade-order-endpoint';
import { BingxCloseAllPositionsEndpoint } from 'bingx-api/bingx/endpoints/bingx-close-all-positions-endpoint';
import { BingxCancelAllOrdersEndpoint } from 'bingx-api/bingx/endpoints/bingx-cancel-all-orders-endpoint';
import {
BingxSwitchMarginModeEndpoint,
MarginType,
} from 'bingx-api/bingx/endpoints/bingx-switch-margin-mode-endpoint';
import { BingxSwitchLeverageEndpoint } from 'bingx-api/bingx/endpoints/bingx-switch-leverage-endpoint';
import { OrderPositionSideEnum } from 'bingx-api/bingx';
import { BingxUserHistoryOrdersEndpoint } from 'bingx-api/bingx/endpoints/bingx-user-history-orders-endpoint';
import { BingxCancelOrderEndpoint } from 'bingx-api/bingx/endpoints/bingx-cancel-order-endpoint';
export class TradeService {
constructor(private readonly requestExecutor: RequestExecutorInterface) {}
public async tradeOrder(
order: BingxCreateTradeOrderInterface,
account: AccountInterface,
) {
return this.requestExecutor.execute(
new BingxTradeOrderEndpoint(order, account),
);
}
public async createTradeOrderTest(
order: BingxCreateTradeOrderInterface,
account: AccountInterface,
) {
return this.requestExecutor.execute(
new BingxTradeOrderEndpoint(order, account),
);
}
public async cancelOrder(
orderId: string,
symbol: string,
account: AccountInterface,
) {
return this.requestExecutor.execute(
new BingxCancelOrderEndpoint(account, orderId, symbol),
);
}
public async getUserHistoryOrders(
symbol: string,
limit: number,
startTime: Date,
endTime: Date,
account: AccountInterface,
) {
return this.requestExecutor.execute(
new BingxUserHistoryOrdersEndpoint(
symbol,
limit,
startTime,
endTime,
account,
),
);
}
public closeAllPositions(account: AccountInterface) {
return this.requestExecutor.execute(
new BingxCloseAllPositionsEndpoint(account),
);
}
public cancelAllOrders(symbol: string, account: AccountInterface) {
return this.requestExecutor.execute(
new BingxCancelAllOrdersEndpoint(symbol, account),
);
}
public switchMarginMode(
symbol: string,
marginType: MarginType,
account: AccountInterface,
) {
return this.requestExecutor.execute(
new BingxSwitchMarginModeEndpoint(symbol, marginType, account),
);
}
public switchLeverage(
symbol: string,
leverage: number,
side: OrderPositionSideEnum,
account: AccountInterface,
) {
return this.requestExecutor.execute(
new BingxSwitchLeverageEndpoint(symbol, leverage, side, account),
);
}
}