CCXT-13-查询记录

1. 查询充值记录 - fetchDeposits

使用ccxt统一API的fetchDeposits方法查询充值记录。示例代码如下。 JavaScript:

// fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {})
if (exchange.has['fetchDeposits']) {
    const deposits = await exchange.fetchDeposits (code, since, limit, params)
} else {
    throw new Error (exchange.id + ' does not have the fetchDeposits method')
}

Python:

# fetch_deposits(code = None, since = None, limit = None, params = {})
if exchange.has['fetchDeposits']:
    deposits = exchange.fetch_deposits(code, since, limit, params)
else:
    raise Exception (exchange.id + ' does not have the fetch_deposits method')

PHP:

// fetch_deposits ($code = null, $since = null, $limit = null, $params = {})
if ($exchange->has['fetchDeposits']) {
    $deposits = $exchange->fetch_deposits ($code, $since, $limit, $params);
} else {
    throw new Exception ($exchange->id . ' does not have the fetch_deposits method');
}

2. 查询提现记录 - fetchWithdrawals

使用ccxt统一API的fetchWithdrawals方法查询提现记录。示例代码如下。 JavaScript:

// fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {})
if (exchange.has['fetchWithdrawals']) {
    const withdrawals = await exchange.fetchWithdrawals (code, since, limit, params)
} else {
    throw new Error (exchange.id + ' does not have the fetchWithdrawals method')
}

Python:

# fetch_withdrawals(code = None, since = None, limit = None, params = {})
if exchange.has['fetchWithdrawals']:
    withdrawals = exchange.fetch_withdrawals(code, since, limit, params)
else:
    raise Exception (exchange.id + ' does not have the fetch_withdrawals method')

PHP:

// fetch_withdrawals ($code = null, $since = null, $limit = null, $params = {})
if ($exchange->has['fetchWithdrawals']) {
    $withdrawals = $exchange->fetch_withdrawals ($code, $since, $limit, $params);
} else {
    throw new Exception ($exchange->id . ' does not have the fetch_withdrawals method');
}

3. 查询手续费 - fetchFees

手续费通常可以分为以下两类:

  • 交易手续费:向交易所支付的交易手续费,通常按成交量的百分点计取
  • 资金操作手续费:在充值和提现时向交易所支付的费用,包含链上交易费用

因为手续费结构会依赖于用户交易的货币的实际交易量,手续费是与账户相关的。 ccxt的统一API中,提供了以下方法用于账户相关的手续费处理:

  • fetchFees (params = {})
  • fetchTradingFees (params = {})
  • fetchFundingFees (params = {})

手续费方法将返回一个统一的手续费结构,该结构在整个ccxt库中保持统一, 通常采用交易市场或货币为索引键。手续费结构如下:

{
    'type': takerOrMaker,
    'currency': 'BTC', // the unified fee currency code
    'rate': percentage, // the fee rate, 0.05% = 0.0005, 1% = 0.01, ...
    'cost': feePaid, // the fee cost (amount * fee rate)
}

手续费这一部分的代码目前还在进行中,因此其中有些方法和属性在某些交易所 可能还会缺失。 不要使用已经废弃的.fees属性。

4. 查询交易所状态 - fetchStatus

交易所状态描述交易所API的最近可用情况。交易所状态信息可能是在交易所实现类中硬编码的,也可能是从交易所API直接获取的。 可以使用ccxt的统一API中的fetchStatus方法来查询交易所状态。其返回结果为以下三者之一:

  • 交易所实现类硬编码的信息,例如,如果交易所宕机的话
  • 使用交易所对象的ping或fetchTime方法检查交易所API是否存活
  • 使用交易所提供的API获取状态信息

fetchStatus方法原型如下:

fetchStatus(params = {})

方法返回的状态数据结构如下:

{
    'status': 'ok', // 'ok', 'shutdown', 'error', 'maintenance'
    'updated': undefined, // integer, last updated timestamp in milliseconds if updated via the API
    'eta': undefined, // when the maintenance or outage is expected to end
    'url': undefined, // a link to a GitHub issue or to an exchange post on the subject
}

说明:

  • ‘ok'表示交易所API可用
  • ‘shutdown'表示交易所停机,这时updated字段的值就表示停机时间
  • ‘error'表示API不兼容
  • ‘maintenance'表示常规维护,eta字段的值表示预计恢复时间。