/// <summary> /// Change the margin type for an open position /// </summary> /// <param name="symbol">Symbol to change the position type for</param> /// <param name="marginType">The type of margin to use</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>Whether the request was successful</returns> public async Task <WebCallResult <BinanceFuturesChangeMarginTypeResult> > ChangeMarginTypeAsync(string symbol, FuturesMarginType marginType, long?receiveWindow = null, CancellationToken ct = default) { var timestampResult = await BaseClient.CheckAutoTimestamp(ct).ConfigureAwait(false); if (!timestampResult) { return(new WebCallResult <BinanceFuturesChangeMarginTypeResult>(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error)); } var parameters = new Dictionary <string, object> { { "symbol", symbol }, { "marginType", JsonConvert.SerializeObject(marginType, new FuturesMarginTypeConverter(false)) }, { "timestamp", BaseClient.GetTimestamp() } }; parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? BaseClient.DefaultReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)); return(await BaseClient.SendRequestInternal <BinanceFuturesChangeMarginTypeResult>(GetUrl(changeMarginTypeEndpoint, Api, signedVersion), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false)); }
/// <summary> /// Change the margin type for an open position /// </summary> /// <param name="symbol">Symbol to change the position type for</param> /// <param name="marginType">The type of margin to use</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>Whether the request was successful</returns> public WebCallResult <BinanceFuturesChangeMarginTypeResult> ChangeMarginType(string symbol, FuturesMarginType marginType, long?receiveWindow = null, CancellationToken ct = default) => ChangeMarginTypeAsync(symbol, marginType, receiveWindow, ct).Result;