Beispiel #1
0
 /// <summary>
 /// This endpoint supports the transfer of funds among your funding account, trading accounts, main account, and sub accounts.
 /// Limit: 1 request per 2 seconds (per currency)
 /// </summary>
 /// <param name="currency">Token symbol, e.g., 'EOS'</param>
 /// <param name="amount">Amount to be transferred</param>
 /// <param name="fromAccount">Remitting account</param>
 /// <param name="toAccount">Receiving account</param>
 /// <param name="subAccountName">Name of the sub account</param>
 /// <param name="fromSymbol">Margin trading pair of token or underlying of USDT-margined futures transferred out, such as: btc-usdt. Limited to trading pairs available for margin trading or underlying of enabled futures trading.</param>
 /// <param name="toSymbol">Margin trading pair of token or underlying of USDT-margined futures transferred in, such as: btc-usdt. Limited to trading pairs available for margin trading or underlying of enabled futures trading.</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public WebCallResult <OkexFundingAssetTransfer> Funding_Transfer(
     string currency,
     decimal amount,
     OkexFundingTransferAccountType fromAccount,
     OkexFundingTransferAccountType toAccount,
     string?subAccountName = null,
     string?fromSymbol     = null,
     string?toSymbol       = null,
     CancellationToken ct  = default)
 => Funding_Transfer_Async(currency, amount, fromAccount, toAccount, subAccountName, fromSymbol, toSymbol, ct).Result;
Beispiel #2
0
        /// <summary>
        /// This endpoint supports the transfer of funds among your funding account, trading accounts, main account, and sub accounts.
        /// Limit: 1 request per 2 seconds (per currency)
        /// </summary>
        /// <param name="currency">Token symbol, e.g., 'EOS'</param>
        /// <param name="amount">Amount to be transferred</param>
        /// <param name="fromAccount">Remitting account</param>
        /// <param name="toAccount">Receiving account</param>
        /// <param name="subAccountName">Name of the sub account</param>
        /// <param name="fromSymbol">Margin trading pair of token or underlying of USDT-margined futures transferred out, such as: btc-usdt. Limited to trading pairs available for margin trading or underlying of enabled futures trading.</param>
        /// <param name="toSymbol">Margin trading pair of token or underlying of USDT-margined futures transferred in, such as: btc-usdt. Limited to trading pairs available for margin trading or underlying of enabled futures trading.</param>
        /// <param name="ct">Cancellation Token</param>
        /// <returns></returns>
        public async Task <WebCallResult <OkexFundingAssetTransfer> > Funding_Transfer_Async(
            string currency,
            decimal amount,
            OkexFundingTransferAccountType fromAccount,
            OkexFundingTransferAccountType toAccount,
            string?subAccountName = null,
            string?fromSymbol     = null,
            string?toSymbol       = null,
            CancellationToken ct  = default)
        {
            currency = currency.ValidateCurrency();

            if (fromAccount == toAccount)
            {
                throw new ArgumentException("'fromAccount' and 'toAccount' must be different.");
            }

            if ((fromAccount == OkexFundingTransferAccountType.SubAccount || toAccount == OkexFundingTransferAccountType.SubAccount) && string.IsNullOrEmpty(subAccountName))
            {
                throw new ArgumentException("When 'fromAccount' or 'toAccount' is SubAccount, subAccountName parameter is required.");
            }

            if (fromAccount == OkexFundingTransferAccountType.SubAccount && toAccount != OkexFundingTransferAccountType.FundingAccount)
            {
                throw new ArgumentException("When 'fromAccount' is SubAccount, 'toAccount' can only be FundingAccount as the sub account can only be transferred to the main account.");
            }

            if ((fromAccount == OkexFundingTransferAccountType.Margin || toAccount == OkexFundingTransferAccountType.Margin) && string.IsNullOrEmpty(fromSymbol))
            {
                throw new ArgumentException("When 'fromAccount' or 'toAccount' is Margin, fromSymbol parameter is required.");
            }

            var parameters = new Dictionary <string, object>
            {
                { "currency", currency },
                { "amount", amount },
                { "from", JsonConvert.SerializeObject(fromAccount, new FundingTransferAccountTypeConverter(false)) },
                { "to", JsonConvert.SerializeObject(toAccount, new FundingTransferAccountTypeConverter(false)) },
            };

            parameters.AddOptionalParameter("sub_account", subAccountName);
            parameters.AddOptionalParameter("instrument_id", fromSymbol);
            parameters.AddOptionalParameter("to_instrument_id", toSymbol);

            return(await SendRequest <OkexFundingAssetTransfer>(GetUrl(Endpoints_Funding_Transfer, currency), HttpMethod.Post, ct, parameters, signed : true).ConfigureAwait(false));
        }