-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathIBinanceClient.cs
More file actions
246 lines (220 loc) · 12 KB
/
IBinanceClient.cs
File metadata and controls
246 lines (220 loc) · 12 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
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
using Binance.API.Csharp.Client.Models.Account;
using Binance.API.Csharp.Client.Models.Enums;
using Binance.API.Csharp.Client.Models.General;
using Binance.API.Csharp.Client.Models.Market;
using Binance.API.Csharp.Client.Models.UserStream;
using Binance.API.Csharp.Client.Models.WebSocket;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using WebSocketSharp;
using static Binance.API.Csharp.Client.Domain.Abstract.ApiClientAbstract;
namespace Binance.API.Csharp.Client.Domain.Interfaces
{
public interface IBinanceClient
{
#region General
/// <summary>
/// Test connectivity to the Rest API.
/// </summary>
/// <returns></returns>
Task<dynamic> TestConnectivity();
/// <summary>
/// Test connectivity to the Rest API and get the current server time.
/// </summary>
/// <returns></returns>
Task<ServerInfo> GetServerTime();
#endregion
#region Market Data
/// <summary>
/// Get order book for a particular symbol.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="limit">Limit of records to retrieve.</param>
/// <returns></returns>
Task<OrderBook> GetOrderBook(string symbol, int limit = 100);
/// <summary>
/// Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="limit">Limit of records to retrieve.</param>
/// <returns></returns>
Task<IEnumerable<AggregateTrade>> GetAggregateTrades(string symbol, int limit = 500);
/// <summary>
/// Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="interval">Time interval to retreive.</param>
/// <param name="limit">Limit of records to retrieve.</param>
/// <returns></returns>
Task<IEnumerable<Candlestick>> GetCandleSticks(string symbol, TimeInterval interval, DateTime? startTime = null, DateTime? endTime = null, int limit = 500);
/// <summary>
/// 24 hour price change statistics.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <returns></returns>
Task<IEnumerable<PriceChangeInfo>> GetPriceChange24H(string symbol);
/// <summary>
/// Latest price for all symbols.
/// </summary>
/// <returns></returns>
Task<IEnumerable<SymbolPrice>> GetAllPrices();
/// <summary>
/// Best price/qty on the order book for all symbols.
/// </summary>
/// <returns></returns>
Task<IEnumerable<OrderBookTicker>> GetOrderBookTicker();
#endregion
#region Account Information
/// <summary>
/// Send in a new order.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="quantity">Quantity to transaction.</param>
/// <param name="price">Price of the transaction.</param>
/// <param name="orderType">Order type (LIMIT-MARKET).</param>
/// <param name="side">Order side (BUY-SELL).</param>
/// <param name="timeInForce">Indicates how long an order will remain active before it is executed or expires.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<NewOrder> PostNewOrder(string symbol, decimal quantity, decimal price, OrderSide side, OrderType orderType = OrderType.LIMIT, TimeInForce timeInForce = TimeInForce.GTC, decimal icebergQty = 0m, long recvWindow = 6000000);
/// <summary>
/// Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="quantity">Quantity to transaction.</param>
/// <param name="price">Price of the transaction.</param>
/// <param name="orderType">Order type (LIMIT-MARKET).</param>
/// <param name="side">Order side (BUY-SELL).</param>
/// <param name="timeInForce">Indicates how long an order will remain active before it is executed or expires.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<dynamic> PostNewOrderTest(string symbol, decimal quantity, decimal price, OrderSide side, OrderType orderType = OrderType.LIMIT, TimeInForce timeInForce = TimeInForce.GTC, decimal icebergQty = 0m, long recvWindow = 6000000);
/// <summary>
/// Check an order's status.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="orderId">Id of the order to retrieve.</param>
/// <param name="origClientOrderId">origClientOrderId of the order to retrieve.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<Order> GetOrder(string symbol, long? orderId = null, string origClientOrderId = null, long recvWindow = 6000000);
/// <summary>
/// Cancel an active order.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="orderId">Id of the order to cancel.</param>
/// <param name="origClientOrderId">origClientOrderId of the order to cancel.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<CanceledOrder> CancelOrder(string symbol, long? orderId = null, string origClientOrderId = null, long recvWindow = 6000000);
/// <summary>
/// Get all open orders on a symbol.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<IEnumerable<Order>> GetCurrentOpenOrders(string symbol, long recvWindow = 6000000);
/// <summary>
/// Get all account orders; active, canceled, or filled.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="orderId">If is set, it will get orders >= that orderId. Otherwise most recent orders are returned.</param>
/// <param name="limit">Limit of records to retrieve.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<IEnumerable<Order>> GetAllOrders(string symbol, long? orderId = null, int limit = 500, long recvWindow = 6000000);
/// <summary>
/// Get current account information.
/// </summary>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<AccountInfo> GetAccountInfo(long recvWindow = 6000000);
/// <summary>
/// Get trades for a specific account and symbol.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<IEnumerable<Trade>> GetTradeList(string symbol, long recvWindow = 6000000);
/// <summary>
/// Submit a withdraw request.
/// </summary>
/// <param name="asset">Asset to withdraw.</param>
/// <param name="amount">Amount to withdraw.</param>
/// <param name="address">Address where the asset will be deposited.</param>
/// <param name="addressName">Address name.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<WithdrawResponse> Withdraw(string asset, decimal amount, string address, string addressName = "", long recvWindow = 6000000);
/// <summary>
/// Fetch deposit history.
/// </summary>
/// <param name="asset">Asset you want to see the information for.</param>
/// <param name="status">Deposit status.</param>
/// <param name="startTime">Start time. </param>
/// <param name="endTime">End time.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<DepositHistory> GetDepositHistory(string asset, DepositStatus? status = null, DateTime? startTime = null, DateTime? endTime = null, long recvWindow = 6000000);
/// <summary>
/// Fetch withdraw history.
/// </summary>
/// <param name="asset">Asset you want to see the information for.</param>
/// <param name="status">Withdraw status.</param>
/// <param name="startTime">Start time. </param>
/// <param name="endTime">End time.</param>
/// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param>
/// <returns></returns>
Task<WithdrawHistory> GetWithdrawHistory(string asset, WithdrawStatus? status = null, DateTime? startTime = null, DateTime? endTime = null, long recvWindow = 6000000);
#endregion
#region User Stream
/// <summary>
/// Start a new user data stream.
/// </summary>
/// <returns></returns>
Task<UserStreamInfo> StartUserStream();
/// <summary>
/// PING a user data stream to prevent a time out.
/// </summary>
/// <param name="listenKey">Listenkey of the user stream to keep alive.</param>
/// <returns></returns>
Task<dynamic> KeepAliveUserStream(string listenKey);
/// <summary>
/// Close out a user data stream.
/// </summary>
/// <param name="listenKey">Listenkey of the user stream to close.</param>
/// <returns></returns>
Task<dynamic> CloseUserStream(string listenKey);
#endregion
#region WebSocket
/// <summary>
/// Listen to the Depth endpoint.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="depthHandler">Handler to be used when a message is received.</param>
WebSocket ListenDepthEndpoint(string symbol, MessageHandler<DepthMessage> messageHandler);
/// <summary>
/// Listen to the Kline endpoint.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="interval">Time interval to retreive.</param>
/// <param name="klineHandler">Handler to be used when a message is received.</param>
WebSocket ListenKlineEndpoint(string symbol, TimeInterval interval, MessageHandler<KlineMessage> messageHandler);
/// <summary>
/// Listen to the Trades endpoint.
/// </summary>
/// <param name="symbol">Ticker symbol.</param>
/// <param name="tradeHandler">Handler to be used when a message is received.</param>
WebSocket ListenTradeEndpoint(string symbol, MessageHandler<AggregateTradeMessage> messageHandler);
/// <summary>
/// Listen to the User Data endpoint.
/// </summary>
/// <param name="accountInfoHandler">Handler to be used when a account message is received.</param>
/// <param name="tradesHandler">Handler to be used when a trade message is received.</param>
/// <param name="ordersHandler">Handler to be used when a order message is received.</param>
/// <returns></returns>
string ListenUserDataEndpoint(MessageHandler<AccountUpdatedMessage> accountInfoHandler, MessageHandler<OrderOrTradeUpdatedMessage> tradesHandler, MessageHandler<OrderOrTradeUpdatedMessage> ordersHandler);
#endregion
}
}