0

我正在尝试使用CCXT创建一个包含钱包状态的货币表(存款和取款是在线还是离线),以及各自的最小值(最低存款,最低取款)和最大值(最多取款),即

比特币 | 存款:开| 取款:开 | 最低存款:.01 | 最低提款:.01 | 最大提款:10

我正在为火币的交易所做这个,所以如果CCXT不提供这个能力,我可能需要直接使用火币的API 。

4

2 回答 2

1

您可以使用fetchCurrencies获取最小和最大提款金额(这些金额将取决于链)。获取货币返回如下响应

...
{
    "ZRX": {
        "active": true,
        "code": "ZRX",
        "fee": null,
        "id": "zrx",
        "info": { 
            # Unfiltered, non-unified response from the huobi api
            # Is not consistent across exchanges
        },
        "limits": {
            "amount": {
                "max": null,
                "min": null
            },
            "withdraw": {
                "max": null,
                "min": null
            }
        },
        "name": null,
        "networks": {
            "ERC20": {
                "active": true,
                "fee": 20.71036372,
                "id": "zrx",
                "info": {
                    "addrDepositTag": false,
                    "addrWithTag": false,
                    "baseChain": "ETH",
                    "baseChainProtocol": "ERC20",
                    "chain": "zrx",
                    "depositStatus": "allowed",
                    "displayName": "ERC20",
                    "fullName": "Ethereum",
                    "isDynamic": true,
                    "maxWithdrawAmt": "5000000.000000000000000000",
                    "minDepositAmt": "5",
                    "minWithdrawAmt": "10",
                    "numOfConfirmations": "12",
                    "numOfFastConfirmations": "12",
                    "transactFeeWithdraw": "20.71036372",
                    "withdrawFeeType": "fixed",
                    "withdrawPrecision": "8",
                    "withdrawQuotaPerDay": "5000000.000000000000000000",
                    "withdrawQuotaPerYear": null,
                    "withdrawQuotaTotal": null,
                    "withdrawStatus": "allowed"
                },
                "limits": {
                    "withdraw": {
                        "max": 5000000.0,
                        "min": 10.0
                    }
                },
                "network": "ERC20",
                "precision": 1e-08
            },
            ...
        },
        "precision": 1e-08
    }
}

然后,您可以使用fetchDepositAddressfetchWithdrawAddressspotPrivateGetV2AccountWithdrawAddressfetchDepositsfetchWithdrawals来获取所需的其余信息。所有这些看起来像

import ccxt
import sys
import json
# import logging
# logging.basicConfig(level=logging.DEBUG)

print('python', sys.version)
print('CCXT Version:', ccxt.__version__)

exchange = ccxt.huobi({
    'enableRateLimit': True,
    "apiKey": '...',
    "secret": '...',
})
# exchange.verbose = True

currencies = exchange.fetchCurrencies()
for cur in currencies.keys():
    depositAddresses = exchange.fetchDepositAddress(cur)
    withdrawAddresses = exchange.fetchWithdrawAddresses('USDT') # Once the PR get's merged
    deposits = exchange.fetchDeposits(cur)
    withdraws = exchange.fetchWithdrawals(cur)
    # And then organize things how you want to get your table


笔记

总有一种方法可以通过使用隐式 API 方法来完成使用带有 CCXT 的常规 API 完成的任何事情。如果没有为您尝试使用的 api 端点编写统一的 CCXT 方法(例如获取取款地址),您可以使用这些方法,它看起来像

withdrawAddresses = huobi.spotPrivateGetV2AccountWithdrawAddress({"currency": "usdt"})

  • 注意不要用太多请求使 api 过载
  • fetchWithdrawAddress是新的,确保你拉最新的CCXT
于 2021-12-21T13:40:51.053 回答
0

我最终只是以这种方式循环货币:

    currencies = huobi.currencies  

    for item1 in currencies:  
        checkChains = currencies[item1]
        for item2 in checkChains['info']['chains']:
                print(item1,',',item2['chain'],',',item2['depositStatus'],',',item2['minDepositAmt'],',',item2['withdrawStatus'],',',item2['minWithdrawAmt'],',',item2['maxWithdrawAmt'],',',item2['transactFeeWithdraw'])

不过,您的语法看起来更清晰,并提供了有用的洞察力,让我了解如何在此处进行优化。

于 2021-12-23T15:03:05.587 回答