zyy
2025-11-11 df42e224ff59c45d88ad15913d27d2b66a33e6c4
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
package com.yami.trading.huobi.websocket.client.req.trade;
 
import java.math.BigDecimal;
 
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
 
import com.yami.trading.huobi.websocket.constant.enums.OrderSourceEnum;
import com.yami.trading.huobi.websocket.constant.enums.OrderTypeEnum;
import com.yami.trading.huobi.websocket.constant.enums.StopOrderOperatorEnum;
 
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CreateOrderRequest {
 
 
  private Long accountId;
 
  private String symbol;
 
  private OrderTypeEnum type;
 
  private BigDecimal price;
 
  private BigDecimal amount;
 
  private String source;
 
  private String clientOrderId;
 
  private BigDecimal stopPrice;
 
  private StopOrderOperatorEnum operator;
 
  private OrderSourceEnum orderSource;
 
  private Integer selfMatchPrevent;
 
  //------------------------------- Spot ---------------------------------------//
 
  public static CreateOrderRequest spotBuyLimit(Long spotAccountId, String symbol, BigDecimal price, BigDecimal amount) {
    return spotBuyLimit(spotAccountId,null, symbol, price, amount);
  }
 
  public static CreateOrderRequest spotBuyLimit(Long spotAccountId,String clientOrderId, String symbol, BigDecimal price, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(spotAccountId)
        .type(OrderTypeEnum.BUY_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .orderSource(OrderSourceEnum.API)
        .build();
  }
 
  public static CreateOrderRequest spotSellLimit(Long spotAccountId,String symbol, BigDecimal price, BigDecimal amount) {
    return spotSellLimit(spotAccountId,null, symbol, price, amount);
  }
 
  public static CreateOrderRequest spotSellLimit(Long spotAccountId,String clientOrderId, String symbol, BigDecimal price, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(spotAccountId)
        .type(OrderTypeEnum.SELL_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .orderSource(OrderSourceEnum.API)
        .build();
  }
 
  public static CreateOrderRequest spotBuyMarket(Long spotAccountId,String symbol, BigDecimal amount) {
    return spotBuyMarket(spotAccountId,null, symbol, amount);
  }
 
  public static CreateOrderRequest spotBuyMarket(Long spotAccountId,String clientOrderId, String symbol, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(spotAccountId)
        .type(OrderTypeEnum.BUY_MARKET)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .amount(amount)
        .orderSource(OrderSourceEnum.API)
        .build();
  }
 
  public static CreateOrderRequest spotSellMarket(Long spotAccountId,String symbol, BigDecimal amount) {
    return spotSellMarket(spotAccountId,null, symbol, amount);
  }
 
  public static CreateOrderRequest spotSellMarket(Long spotAccountId,String clientOrderId, String symbol, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(spotAccountId)
        .type(OrderTypeEnum.SELL_MARKET)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .amount(amount)
        .orderSource(OrderSourceEnum.API)
        .build();
  }
 
  //--------------------------------- Margin -----------------------------------------//
 
  public static CreateOrderRequest marginBuyLimit(Long marginAccountId,String symbol, BigDecimal price, BigDecimal amount) {
    return marginBuyLimit(marginAccountId,null, symbol, price, amount);
  }
 
  public static CreateOrderRequest marginBuyLimit(Long marginAccountId,String clientOrderId, String symbol, BigDecimal price, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(marginAccountId)
        .type(OrderTypeEnum.BUY_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .orderSource(OrderSourceEnum.MARGIN_API)
        .build();
  }
 
  public static CreateOrderRequest marginSellLimit(Long marginAccountId,String symbol, BigDecimal price, BigDecimal amount) {
    return marginSellLimit(marginAccountId,null, symbol, price, amount);
  }
 
  public static CreateOrderRequest marginSellLimit(Long marginAccountId,String clientOrderId, String symbol, BigDecimal price, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(marginAccountId)
        .type(OrderTypeEnum.SELL_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .orderSource(OrderSourceEnum.MARGIN_API)
        .build();
  }
 
  public static CreateOrderRequest marginBuyMarket(Long marginAccountId,String symbol, BigDecimal amount) {
    return marginBuyMarket(marginAccountId,null, symbol, amount);
  }
 
  public static CreateOrderRequest marginBuyMarket(Long marginAccountId,String clientOrderId, String symbol, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(marginAccountId)
        .type(OrderTypeEnum.BUY_MARKET)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .amount(amount)
        .orderSource(OrderSourceEnum.MARGIN_API)
        .build();
  }
 
  public static CreateOrderRequest marginSellMarket(Long marginAccountId,String symbol, BigDecimal amount) {
    return marginSellMarket(marginAccountId,null, symbol, amount);
  }
 
  public static CreateOrderRequest marginSellMarket(Long marginAccountId,String clientOrderId, String symbol, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(marginAccountId)
        .type(OrderTypeEnum.SELL_MARKET)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .amount(amount)
        .orderSource(OrderSourceEnum.MARGIN_API)
        .build();
  }
 
  //-------------------------------Super Margin---------------------------------------//
 
  public static CreateOrderRequest superMarginBuyLimit(Long superMarginAccountId,String symbol, BigDecimal price, BigDecimal amount) {
    return superMarginBuyLimit(superMarginAccountId,null, symbol, price, amount);
  }
 
  public static CreateOrderRequest superMarginBuyLimit(Long superMarginAccountId,String clientOrderId, String symbol, BigDecimal price, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(superMarginAccountId)
        .type(OrderTypeEnum.BUY_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .orderSource(OrderSourceEnum.SUPER_MARGIN_API)
        .build();
  }
 
  public static CreateOrderRequest superMarginSellLimit(Long superMarginAccountId,String symbol, BigDecimal price, BigDecimal amount) {
    return superMarginSellLimit(superMarginAccountId,null, symbol, price, amount);
  }
 
  public static CreateOrderRequest superMarginSellLimit(Long superMarginAccountId,String clientOrderId, String symbol, BigDecimal price, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(superMarginAccountId)
        .type(OrderTypeEnum.SELL_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .orderSource(OrderSourceEnum.SUPER_MARGIN_API)
        .build();
  }
 
  public static CreateOrderRequest superMarginBuyMarket(Long superMarginAccountId,String symbol, BigDecimal amount) {
    return superMarginBuyMarket(superMarginAccountId,null, symbol, amount);
  }
 
  public static CreateOrderRequest superMarginBuyMarket(Long superMarginAccountId,String clientOrderId, String symbol, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(superMarginAccountId)
        .type(OrderTypeEnum.BUY_MARKET)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .amount(amount)
        .orderSource(OrderSourceEnum.SUPER_MARGIN_API)
        .build();
  }
 
  public static CreateOrderRequest superMarginSellMarket(Long superMarginAccountId,String symbol, BigDecimal amount) {
    return superMarginSellMarket(superMarginAccountId,null, symbol, amount);
  }
 
  public static CreateOrderRequest superMarginSellMarket(Long superMarginAccountId,String clientOrderId, String symbol, BigDecimal amount) {
    return CreateOrderRequest.builder()
        .accountId(superMarginAccountId)
        .type(OrderTypeEnum.SELL_MARKET)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .amount(amount)
        .orderSource(OrderSourceEnum.SUPER_MARGIN_API)
        .build();
  }
 
 
  //-------------------------------Stop Loss---------------------------------------//
  public static CreateOrderRequest buyStopLoss(Long accountId, String symbol, BigDecimal price, BigDecimal amount,
      BigDecimal stopPrice, StopOrderOperatorEnum operator, OrderSourceEnum orderSource) {
    return buyStopLoss(null, accountId, symbol, price, amount, stopPrice, operator,orderSource);
  }
 
  public static CreateOrderRequest buyStopLoss(String clientOrderId, Long accountId, String symbol,
      BigDecimal price, BigDecimal amount, BigDecimal stopPrice, StopOrderOperatorEnum operator, OrderSourceEnum orderSource) {
    return CreateOrderRequest.builder()
        .accountId(accountId)
        .type(OrderTypeEnum.BUY_STOP_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .stopPrice(stopPrice)
        .operator(operator)
        .orderSource(orderSource)
        .build();
  }
 
 
  public static CreateOrderRequest sellStopLoss(Long accountId, String symbol, BigDecimal price, BigDecimal amount,
      BigDecimal stopPrice, StopOrderOperatorEnum operator, OrderSourceEnum orderSource) {
    return sellStopLoss(null, accountId, symbol, price, amount, stopPrice, operator,orderSource);
  }
 
  public static CreateOrderRequest sellStopLoss(String clientOrderId, Long accountId, String symbol,
      BigDecimal price, BigDecimal amount, BigDecimal stopPrice, StopOrderOperatorEnum operator, OrderSourceEnum orderSource) {
    return CreateOrderRequest.builder()
        .accountId(accountId)
        .type(OrderTypeEnum.SELL_STOP_LIMIT)
        .clientOrderId(clientOrderId)
        .symbol(symbol)
        .price(price)
        .amount(amount)
        .stopPrice(stopPrice)
        .operator(operator)
        .orderSource(orderSource)
        .build();
  }
}