-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathBinanceApiModels.cs
528 lines (463 loc) · 11.9 KB
/
BinanceApiModels.cs
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
namespace Outcompute.Trader.Trading.Binance;
internal record ApiError(int Code, string Msg);
internal record ApiServerTime(long ServerTime);
internal record ApiRateLimiter(
string RateLimitType,
string Interval,
int IntervalNum,
int Limit);
internal record ApiSymbolFilter(
string FilterType,
decimal MinPrice,
decimal MaxPrice,
decimal TickSize,
decimal MultiplierUp,
decimal MultiplierDown,
decimal MinQty,
decimal MaxQty,
decimal StepSize,
decimal MinNotional,
bool ApplyToMarket,
int AvgPriceMins,
int Limit,
int MaxNumOrders,
int MaxNumAlgoOrders,
int MaxNumIcebergOrders,
int MinTrailingAboveDelta,
int MaxTrailingAboveDelta,
int MinTrailingBelowDelta,
int MaxTrailingBelowDelta,
decimal MaxPosition)
{
public static ApiSymbolFilter Empty { get; } = new ApiSymbolFilter(string.Empty, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
internal record ApiSymbol(
string Symbol,
string Status,
string BaseAsset,
int BaseAssetPrecision,
string QuoteAsset,
int QuoteAssetPrecision,
int BaseCommissionPrecision,
int QuoteCommissionPrecision,
string[] OrderTypes,
bool IcebergAllowed,
bool OcoAllowed,
bool QuoteOrderQtyMarketAllowed,
bool IsSpotTradingAllowed,
bool IsMarginTradingAllowed,
ApiSymbolFilter[] Filters,
string[] Permissions);
internal record ApiExchangeFilter(
string FilterType,
int? MaxNumOrders,
int? MaxNumAlgoOrders);
internal record ApiExchangeInfo(
string Timezone,
long ServerTime,
ApiRateLimiter[] RateLimits,
ApiExchangeFilter[] ExchangeFilters,
ApiSymbol[] Symbols);
internal record ApiOrderBook(
int LastUpdateId,
decimal[][] Bids,
decimal[][] Asks);
internal record ApiTrade(
int Id,
decimal Price,
decimal Qty,
decimal QuoteQty,
long Time,
bool IsBuyerMaker,
bool IsBestMatch);
internal record ApiAvgPrice(
int Mins,
decimal Price);
internal record ApiTicker(
string Symbol,
decimal PriceChange,
decimal PriceChangePercent,
decimal WeightedAvgPrice,
decimal PrevClosePrice,
decimal LastPrice,
decimal LastQty,
decimal BidPrice,
decimal AskPrice,
decimal OpenPrice,
decimal HighPrice,
decimal LowPrice,
decimal Volume,
decimal QuoteVolume,
long OpenTime,
long CloseTime,
int FirstId,
int LastId,
int Count);
internal record ApiSymbolPriceTicker(
string Symbol,
decimal Price);
internal record ApiSymbolOrderBookTicker(
string Symbol,
decimal BidPrice,
decimal BidQty,
decimal AskPrice,
decimal AskQty);
internal record CreateOrderRequest(
string Symbol,
string Side,
string Type,
string TimeInForce,
decimal? Quantity,
decimal? QuoteOrderQty,
decimal? Price,
string NewClientOrderId,
decimal? StopPrice,
decimal? IcebergQty,
string NewOrderRespType,
long? RecvWindow,
long Timestamp);
internal record CreateOrderResponse(
string Symbol,
long OrderId,
long OrderListId,
string ClientOrderId,
long TransactTime,
decimal Price,
decimal OrigQty,
decimal ExecutedQty,
decimal CummulativeQuoteQty,
string Status,
string TimeInForce,
string Type,
string Side,
CreateOrderResponseFill[] Fills);
internal record CreateOrderResponseFill(
decimal Price,
decimal Qty,
decimal Commission,
string CommissionAsset);
internal record GetOrderRequest(
string Symbol,
long? OrderId,
string OrigClientOrderId,
long? RecvWindow,
long? Timestamp);
internal record GetAllOrdersRequest(
string Symbol,
long? OrderId,
long? StartTime,
long? EndTime,
int? Limit,
long? RecvWindow,
long Timestamp);
internal record GetOrderResponse(
string Symbol,
long OrderId,
long OrderListId,
string ClientOrderId,
decimal Price,
decimal OrigQty,
decimal ExecutedQty,
decimal CummulativeQuoteQty,
string Status,
string TimeInForce,
string Type,
string Side,
decimal StopPrice,
decimal IcebergQty,
long Time,
long UpdateTime,
bool IsWorking,
decimal OrigQuoteOrderQty);
internal record CancelOrderRequest(
string Symbol,
long? OrderId,
string OrigClientOrderId,
string NewClientOrderId,
long? RecvWindow,
long Timestamp);
internal record CancelOrderResponse(
string Symbol,
string OrigClientOrderId,
long OrderId,
long OrderListId,
string ClientOrderId,
decimal Price,
decimal OrigQty,
decimal ExecutedQty,
decimal CummulativeQuoteQty,
string Status,
string TimeInForce,
string Type,
string Side);
internal record CancelAllOrdersRequest(
string Symbol,
long? RecvWindow,
long Timestamp);
internal record CancelAllOrdersResponse(
// shared properties
string Symbol,
long OrderListId,
// standard order properties
string OrigClientOrderId,
long OrderId,
string ClientOrderId,
decimal Price,
decimal OrigQty,
decimal ExecutedQty,
decimal CummulativeQuoteQty,
string Status,
string TimeInForce,
string Type,
string Side,
// oco order properties
string ContingencyType,
string ListStatusType,
string ListOrderStatus,
string ListClientOrderId,
long TransactionTime,
CancelAllOrdersResponseOrder[] Orders,
CancelAllOrdersResponseOrderReport[] OrderReports);
internal record CancelAllOrdersResponseOrder(
string Symbol,
long OrderId,
string ClientOrderId);
internal record CancelAllOrdersResponseOrderReport(
string Symbol,
string OrigClientOrderId,
long OrderId,
long OrderListId,
string ClientOrderId,
decimal Price,
decimal OrigQty,
decimal ExecutedQty,
decimal CummulativeQuoteQty,
string Status,
string TimeInForce,
string Type,
string Side,
decimal StopPrice,
decimal IcebergQty);
internal record GetOpenOrdersRequest(
string Symbol,
long? RecvWindow,
long Timestamp);
internal record GetAccountInfoRequest(
long? RecvWindow,
long Timestamp);
internal record GetAccountInfoResponse(
decimal MakerCommission,
decimal TakerCommission,
decimal BuyerCommission,
decimal SellerCommission,
bool CanTrade,
bool CanWithdraw,
bool CanDeposit,
long UpdateTime,
string AccountType,
GetAccountInfoResponseBalance[] Balances,
string[] Permissions);
internal record GetAccountInfoResponseBalance(
string Asset,
decimal Free,
decimal Locked);
internal record GetAccountTradesRequest(
string Symbol,
long? StartTime,
long? EndTime,
long? FromId,
int? Limit,
long? RecvWindow,
long Timestamp);
internal record GetAccountTradesResponse(
string Symbol,
long Id,
long OrderId,
long OrderListId,
decimal Price,
decimal Qty,
decimal QuoteQty,
decimal Commission,
string CommissionAsset,
long Time,
bool IsBuyer,
bool IsMaker,
bool IsBestMatch);
internal record CreateUserDataStreamResponse(
string ListenKey);
internal record PingUserDataStreamRequest(
string ListenKey);
internal record CloseUserDataStreamRequest(
string ListenKey);
internal record GetKlinesRequest(
string Symbol,
string Interval,
long StartTime,
long EndTime,
int Limit);
internal record GetKlinesResponse(
long OpenTime,
long CloseTime,
string OpenPrice,
string HighPrice,
string LowPrice,
string ClosePrice,
string Volume,
string QuoteAssetVolume,
int TradeCount,
string TakerBuyBaseAssetVolume,
string TakerBuyQuoteAssetVolume);
internal record GetFlexibleProductPositionsRequest(
string Asset,
long? RecvWindow,
long Timestamp);
internal record GetFlexibleProductPositionsResponse(
decimal AnnualInterestRate,
string Asset,
decimal AvgAnnualInterestRate,
bool CanRedeem,
decimal DailyInterestRate,
decimal FreeAmount,
decimal FreezeAmount,
decimal LockedAmount,
string ProductId,
string ProductName,
decimal RedeemingAmount,
decimal TodayPurchasedAmount,
decimal TotalAmount,
decimal TotalInterest);
internal record GetLeftDailyRedemptionQuotaOnFlexibleProductRequest(
string ProductId,
string Type,
long? RecvWindow,
long Timestamp);
internal record GetLeftDailyRedemptionQuotaOnFlexibleProductResponse(
string Asset,
decimal DailyQuota,
decimal LeftQuota,
decimal MinRedemptionAmount);
internal record RedeemFlexibleProductRequest(
string ProductId,
decimal Amount,
string Type,
long? RecvWindow,
long Timestamp);
internal record GetFlexibleProductListRequest(
string Status,
string Featured,
long? Current,
long? Size,
long? RecvWindow,
long Timestamp);
internal record GetFlexibleProductListResponse(
string Asset,
decimal AvgAnnualInterestRate,
bool CanPurchase,
bool CanRedeem,
decimal DailyInterestPerThousand,
bool Featured,
decimal MinPurchaseAmount,
string ProductId,
decimal PurchasedAmount,
string Status,
decimal UpLimit,
decimal UpLimitPerUser);
internal record GetSwapPoolsResponse(
long PoolId,
string PoolName,
string[] Assets);
internal record GetSwapPoolLiquidityRequest(
long? PoolId,
long? RecvWindow,
long Timestamp);
internal record GetSwapPoolLiquidityResponse(
long PoolId,
string PoolName,
long UpdateTime,
Dictionary<string, decimal> Liquidity,
GetSwapPoolLiquidityResponseShare Share);
internal record GetSwapPoolLiquidityResponseShare(
decimal ShareAmount,
decimal SharePercentage,
Dictionary<string, decimal> Asset);
internal record AddSwapPoolLiquidityRequest(
long PoolId,
string? Type,
string Asset,
decimal Quantity,
long? RecvWindow,
long Timestamp);
internal record AddSwapPoolLiquidityResponse(
long OperationId);
internal record RemoveSwapPoolLiquidityRequest(
long PoolId,
string Type,
string? Asset,
decimal ShareAmount,
long? RecvWindow,
long Timestamp);
internal record RemoveSwapPoolLiquidityResponse(
long OperationId);
internal record GetSwapPoolConfigurationRequest(
long? PoolId,
long? RecvWindow,
long Timestamp);
internal record GetSwapPoolConfigurationResponse(
long PoolId,
string PoolName,
long UpdateTime,
GetSwapPoolConfigurationResponseLiquidity Liquidity,
Dictionary<string, GetSwapPoolConfigurationResponseAssetConfigure> AssetConfigure);
internal record GetSwapPoolConfigurationResponseLiquidity(
decimal MinRedeemShare,
decimal SlippageTolerance);
internal record GetSwapPoolConfigurationResponseAssetConfigure(
decimal MinAdd,
decimal MaxAdd,
decimal MinSwap,
decimal MaxSwap);
internal record AddSwapPoolLiquidityPreviewRequest(
long PoolId,
string Type,
string QuoteAsset,
decimal QuoteQty,
long? RecvWindow,
long Timestamp);
internal record AddSwapPoolLiquidityPreviewResponse(
string QuoteAsset,
string BaseAsset,
decimal QuoteAmt,
decimal BaseAmt,
decimal Price,
decimal Share,
decimal Slippage,
decimal Fee);
internal record GetSwapPoolQuoteRequest(
string QuoteAsset,
string BaseAsset,
decimal QuoteQty,
long? RecvWindow,
long Timestamp);
internal record GetSwapPoolQuoteResponse(
string QuoteAsset,
string BaseAsset,
decimal QuoteQty,
decimal BaseQty,
decimal Price,
decimal Slippage,
decimal Fee);
internal record MarketDataStreamMessage(
ExternalError? Error,
MiniTicker? MiniTicker,
Kline? Kline,
MarketDataStreamResult? Result)
{
public static MarketDataStreamMessage Empty { get; } = new MarketDataStreamMessage(null, null, null, null);
}
internal record MarketDataStreamRequest(
string Method,
string[] Params,
long Id);
internal record MarketDataStreamResult(
string Result,
long Id);