/// <summary> /// Change the margin on an open position /// </summary> /// <param name="symbol">Symbol to adjust the position margin for</param> /// <param name="amount">The amount of margin to be used</param> /// <param name="type">Whether to reduce or add margin to the position</param> /// <param name="positionSide">Default BOTH for One-way Mode ; LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode.</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>The new position margin</returns> public async Task <WebCallResult <BinanceFuturesPositionMarginResult> > ModifyPositionMarginAsync(string symbol, decimal amount, FuturesMarginChangeDirectionType type, PositionSide?positionSide = null, long?receiveWindow = null, CancellationToken ct = default) { var timestampResult = await BaseClient.CheckAutoTimestamp(ct).ConfigureAwait(false); if (!timestampResult) { return(new WebCallResult <BinanceFuturesPositionMarginResult>(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error)); } var parameters = new Dictionary <string, object> { { "symbol", symbol }, { "amount", amount.ToString(CultureInfo.InvariantCulture) }, { "type", JsonConvert.SerializeObject(type, new FuturesMarginChangeDirectionTypeConverter(false)) }, { "timestamp", BaseClient.GetTimestamp() } }; parameters.AddOptionalParameter("positionSide", positionSide == null ? null : JsonConvert.SerializeObject(positionSide, new PositionSideConverter(false))); parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? BaseClient.DefaultReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)); return(await BaseClient.SendRequestInternal <BinanceFuturesPositionMarginResult>(GetUrl(positionMarginEndpoint, Api, signedVersion), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false)); }
/// <summary> /// Change the margin on an open position /// </summary> /// <param name="symbol">Symbol to adjust the position margin for</param> /// <param name="amount">The amount of margin to be used</param> /// <param name="type">Whether to reduce or add margin to the position</param> /// <param name="positionSide">Default BOTH for One-way Mode ; LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode.</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>The new position margin</returns> public WebCallResult <BinanceFuturesPositionMarginResult> ModifyPositionMargin(string symbol, decimal amount, FuturesMarginChangeDirectionType type, PositionSide?positionSide = null, long?receiveWindow = null, CancellationToken ct = default) => ModifyPositionMarginAsync(symbol, amount, type, positionSide, receiveWindow, ct).Result;