/// <summary> /// Execute transfer between spot account and margin account. /// </summary> /// <param name="asset">The asset being transferred, e.g., BTC</param> /// <param name="amount">The amount to be transferred</param> /// <param name="type">TransferDirection (MainToMargin/MarginToMain)</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>Transaction Id</returns> public async Task <WebCallResult <BinanceTransaction> > TransferAsync(string asset, decimal amount, TransferDirectionType type, int?receiveWindow = null, CancellationToken ct = default) { asset.ValidateNotNull(nameof(asset)); var timestampResult = await _baseClient.CheckAutoTimestamp(ct).ConfigureAwait(false); if (!timestampResult) { return(new WebCallResult <BinanceTransaction>(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error)); } var parameters = new Dictionary <string, object> { { "asset", asset }, { "amount", amount.ToString(CultureInfo.InvariantCulture) }, { "type", JsonConvert.SerializeObject(type, new TransferDirectionTypeConverter(false)) }, { "timestamp", _baseClient.GetTimestamp() } }; parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? _baseClient.DefaultReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)); return(await _baseClient.SendRequestInternal <BinanceTransaction>(_baseClient.GetUrlSpot(marginTransferEndpoint, marginApi, marginVersion), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false)); }
/// <summary> /// Execute transfer between spot account and margin account. /// </summary> /// <param name="asset">The asset being transferred, e.g., BTC</param> /// <param name="amount">The amount to be transferred</param> /// <param name="type">TransferDirection (MainToMargin/MarginToMain)</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>Transaction Id</returns> public WebCallResult <BinanceMarginTransaction> Transfer(string asset, decimal amount, TransferDirectionType type, int?receiveWindow = null, CancellationToken ct = default) => TransferAsync(asset, amount, type, receiveWindow, ct).Result;