/// <summary> /// Gets all user trades for provided symbol /// </summary> /// <param name="symbol">Symbol to get trades for</param> /// <param name="pair">Symbol to get trades for</param> /// <param name="limit">The max number of results</param> /// <param name="fromId">TradeId to fetch from. Default gets most recent trades</param> /// <param name="startTime">Orders newer than this date will be retrieved</param> /// <param name="endTime">Orders older than this date will be retrieved</param> /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> /// <param name="ct">Cancellation token</param> /// <returns>List of trades</returns> public async Task <WebCallResult <IEnumerable <BinanceFuturesCoinTrade> > > GetMyTradesAsync(string?symbol = null, string?pair = null, DateTime?startTime = null, DateTime?endTime = null, int?limit = null, long?fromId = null, long?receiveWindow = null, CancellationToken ct = default) { limit?.ValidateIntBetween(nameof(limit), 1, 1000); var timestampResult = await BaseClient.CheckAutoTimestamp(ct).ConfigureAwait(false); if (!timestampResult) { return(new WebCallResult <IEnumerable <BinanceFuturesCoinTrade> >(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error)); } var parameters = new Dictionary <string, object> { { "timestamp", BaseClient.GetTimestamp() } }; parameters.AddOptionalParameter("symbol", symbol); parameters.AddOptionalParameter("pair", pair); parameters.AddOptionalParameter("limit", limit?.ToString(CultureInfo.InvariantCulture)); parameters.AddOptionalParameter("fromId", fromId?.ToString(CultureInfo.InvariantCulture)); parameters.AddOptionalParameter("startTime", startTime.HasValue ? JsonConvert.SerializeObject(startTime.Value, new TimestampConverter()) : null); parameters.AddOptionalParameter("endTime", endTime.HasValue ? JsonConvert.SerializeObject(endTime.Value, new TimestampConverter()) : null); parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? BaseClient.DefaultReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)); return(await BaseClient.SendRequestInternal <IEnumerable <BinanceFuturesCoinTrade> >(FuturesClient.GetUrl(myFuturesTradesEndpoint, Api, SignedVersion), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false)); }
/// <summary> /// Gets account information, including balances /// </summary> /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> /// <param name="ct">Cancellation token</param> /// <returns>The account information</returns> public async Task <WebCallResult <BinanceFuturesAccountInfo> > GetAccountInfoAsync(long?receiveWindow = null, CancellationToken ct = default) { var timestampResult = await BaseClient.CheckAutoTimestamp(ct).ConfigureAwait(false); if (!timestampResult) { return(new WebCallResult <BinanceFuturesAccountInfo>(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error)); } var parameters = new Dictionary <string, object> { { "timestamp", BaseClient.GetTimestamp() } }; parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? BaseClient.DefaultReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)); return(await BaseClient.SendRequestInternal <BinanceFuturesAccountInfo>(FuturesClient.GetUrl(accountInfoEndpoint, Api, SignedV2), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false)); }
/// <summary> /// Gets account information /// </summary> /// <param name="symbol">Symbol</param> /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> /// <param name="ct">Cancellation token</param> /// <returns>List of Positions</returns> public async Task <WebCallResult <IEnumerable <BinanceFuturesPosition> > > GetPositionInformationAsync(string?symbol = null, long?receiveWindow = null, CancellationToken ct = default) { var timestampResult = await BaseClient.CheckAutoTimestamp(ct).ConfigureAwait(false); if (!timestampResult) { return(new WebCallResult <IEnumerable <BinanceFuturesPosition> >(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error)); } var parameters = new Dictionary <string, object> { { "timestamp", BaseClient.GetTimestamp() } }; parameters.AddOptionalParameter("symbol", symbol); parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? BaseClient.DefaultReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)); return(await BaseClient.SendRequestInternal <IEnumerable <BinanceFuturesPosition> >(GetUrl(positionInformationEndpoint, Api, "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false)); }