/// <summary> /// This endpoint supports the transfer of funds between your funding account and trading account, and from the master account to sub-accounts. Direct transfers between sub-accounts are not allowed. /// </summary> /// <param name="currency">Currency</param> /// <param name="amount">Amount</param> /// <param name="type">Transfer type</param> /// <param name="fromAccount">The remitting account</param> /// <param name="toAccount">The beneficiary account</param> /// <param name="subAccountName">Sub Account Name</param> /// <param name="fromInstrumentId">MARGIN trading pair (e.g. BTC-USDT) or contract underlying (e.g. BTC-USD) to be transferred out.</param> /// <param name="toInstrumentId">MARGIN trading pair (e.g. BTC-USDT) or contract underlying (e.g. BTC-USD) to be transferred in.</param> /// <param name="ct">Cancellation Token</param> /// <returns></returns> public virtual WebCallResult <OkexTransferResponse> FundTransfer( string currency, decimal amount, OkexTransferType type, OkexAccount fromAccount, OkexAccount toAccount, string subAccountName = null, string fromInstrumentId = null, string toInstrumentId = null, CancellationToken ct = default) => FundTransfer_Async( currency, amount, type, fromAccount, toAccount, subAccountName, fromInstrumentId, toInstrumentId, ct).Result;
/// <summary> /// This endpoint supports the transfer of funds between your funding account and trading account, and from the master account to sub-accounts. Direct transfers between sub-accounts are not allowed. /// </summary> /// <param name="currency">Currency</param> /// <param name="amount">Amount</param> /// <param name="type">Transfer type</param> /// <param name="fromAccount">The remitting account</param> /// <param name="toAccount">The beneficiary account</param> /// <param name="subAccountName">Sub Account Name</param> /// <param name="fromInstrumentId">MARGIN trading pair (e.g. BTC-USDT) or contract underlying (e.g. BTC-USD) to be transferred out.</param> /// <param name="toInstrumentId">MARGIN trading pair (e.g. BTC-USDT) or contract underlying (e.g. BTC-USD) to be transferred in.</param> /// <param name="ct">Cancellation Token</param> /// <returns></returns> public virtual async Task <WebCallResult <OkexTransferResponse> > FundTransfer_Async( string currency, decimal amount, OkexTransferType type, OkexAccount fromAccount, OkexAccount toAccount, string subAccountName = null, string fromInstrumentId = null, string toInstrumentId = null, CancellationToken ct = default) { var parameters = new Dictionary <string, object> { { "ccy", currency }, { "amt", amount.ToString(OkexGlobals.OkexCultureInfo) }, { "type", JsonConvert.SerializeObject(type, new TransferTypeConverter(false)) }, { "from", JsonConvert.SerializeObject(fromAccount, new AccountConverter(false)) }, { "to", JsonConvert.SerializeObject(toAccount, new AccountConverter(false)) }, }; parameters.AddOptionalParameter("subAcct", subAccountName); parameters.AddOptionalParameter("instId", fromInstrumentId); parameters.AddOptionalParameter("toInstId", toInstrumentId); var result = await SendRequestAsync <OkexRestApiResponse <IEnumerable <OkexTransferResponse> > >(GetUrl(Endpoints_V5_Asset_Transfer), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); if (!result.Success) { return(WebCallResult <OkexTransferResponse> .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, result.Error)); } if (result.Data.ErrorCode > 0) { return(WebCallResult <OkexTransferResponse> .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage, result.Data.Data))); } return(new WebCallResult <OkexTransferResponse>(result.ResponseStatusCode, result.ResponseHeaders, result.Data.Data.FirstOrDefault(), null)); }