コード例 #1
0
        /// <summary>
        /// applies to master accounts only
        /// </summary>
        /// <param name="currency">Currency</param>
        /// <param name="amount">Amount</param>
        /// <param name="fromAccount">6:Funding Account 18:Unified Account</param>
        /// <param name="toAccount">6:Funding Account 18:Unified Account</param>
        /// <param name="fromSubAccountName">Sub-account name of the account that transfers funds out.</param>
        /// <param name="toSubAccountName">Sub-account name of the account that transfers funds in.</param>
        /// <param name="ct">Cancellation Token</param>
        /// <returns></returns>
        public virtual async Task <WebCallResult <OkexSubAccountTransfer> > TransferBetweenSubAccounts_Async(
            string currency,
            decimal amount,
            OkexAccount fromAccount,
            OkexAccount toAccount,
            string fromSubAccountName,
            string toSubAccountName,
            CancellationToken ct = default)
        {
            var parameters = new Dictionary <string, object>
            {
                { "ccy", currency },
                { "amt", amount.ToString(OkexGlobals.OkexCultureInfo) },
                { "from", JsonConvert.SerializeObject(fromAccount, new AccountConverter(false)) },
                { "to", JsonConvert.SerializeObject(toAccount, new AccountConverter(false)) },
                { "fromSubAccount", fromSubAccountName },
                { "toSubAccount", toSubAccountName },
            };

            var result = await SendRequestAsync <OkexRestApiResponse <IEnumerable <OkexSubAccountTransfer> > >(GetUrl(Endpoints_V5_SubAccount_Transfer), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false);

            if (!result.Success)
            {
                return(WebCallResult <OkexSubAccountTransfer> .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, result.Error));
            }
            if (result.Data.ErrorCode > 0)
            {
                return(WebCallResult <OkexSubAccountTransfer> .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage, result.Data.Data)));
            }

            return(new WebCallResult <OkexSubAccountTransfer>(result.ResponseStatusCode, result.ResponseHeaders, result.Data.Data.FirstOrDefault(), null));
        }
コード例 #2
0
 /// <summary>
 /// applies to master accounts only
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="amount">Amount</param>
 /// <param name="fromAccount">6:Funding Account 18:Unified Account</param>
 /// <param name="toAccount">6:Funding Account 18:Unified Account</param>
 /// <param name="fromSubAccountName">Sub-account name of the account that transfers funds out.</param>
 /// <param name="toSubAccountName">Sub-account name of the account that transfers funds in.</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <OkexSubAccountTransfer> TransferBetweenSubAccounts(
     string currency,
     decimal amount,
     OkexAccount fromAccount,
     OkexAccount toAccount,
     string fromSubAccountName,
     string toSubAccountName,
     CancellationToken ct = default) => TransferBetweenSubAccounts_Async(currency, amount, fromAccount, toAccount, fromSubAccountName, toSubAccountName, ct).Result;
コード例 #3
0
 /// <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;