CCXT提取存款仅显示过去的1个月数据

发布于 2025-02-06 16:02:11 字数 1575 浏览 2 评论 0 原文

我使用ccxt从FTX提取。我的目的是找到该特定FTX地址的所有比特币沉积物的总和。当我尝试获得所有历史存款(超过1个月)时,问题就会发生。 FTX仅返回过去的1个月数据。

  • 开始存款的开始日期= 2022年4月1日= 1648771200
  • 假期存款末期= 2022年4月30日= 1651363199
  • 预期的存款结束日期=现在= 1655033415

我尝试过的是:

  1. fetchdeposit /strong>。正确的数据 返回 33 交易。

  2. 从4月1日起-30 APR = 失败。数据返回与 (1)。正确的数据应返回 3 交易。

  3. 从1月1日起 - 现在= 失败。数据返回与(1)相同。 正确的数据应返回 44 交易。

我知道分页限制了返回数据。但是,无论我尝试过,我总是只得到一个月的数据。缺少较旧的数据。

参考:

代码

def get_deposits(asset_name):
    deposits_total = 0
    deposits_count = 0

    since = 1648771200
    param = {"endTime": 1655033415}
    deposits = exchange.fetch_deposits(asset_name, since, limit=None, params=param)

    #This sum up all deposits if such deposit is made to specified deposit address
    for item in deposits:
      if item['addressTo'] == deposit_address[asset_name]:
        deposits_total = deposits_total + item['amount']
        deposits_count = deposits_count +1
        print(item['datetime'])

    return(deposits_total, deposits_count)

I use CCXT to fetchDeposits from FTX. My aim is to find the sum of all Bitcoin deposits to this specific FTX address. Problem happens when I try to get all historical deposits (older than 1 month). FTX only returns past 1 month data.

  • Start date of deposit = 1 April 2022 = 1648771200
  • Dummy end of deposit = 30 April 2022 = 1651363199
  • Intended End date of deposit = now = 1655033415

What I've tried:

  1. fetchDeposits from the past one month = successful. Correct data
    returns 33 transactions.

  2. fetchDeposits from 1 Apr - 30 Apr = fail. Data returns same as
    (1). Correct data should return 3 transactions.

  3. fetchDeposits from 1 Apr - now = fail. Data returns same as (1).
    Correct data should return 44 transactions.

I'm aware of pagination which limits the returned data. However, no matter I've tried, I always get only past one month data. Older data is missing.

Reference:

Code

def get_deposits(asset_name):
    deposits_total = 0
    deposits_count = 0

    since = 1648771200
    param = {"endTime": 1655033415}
    deposits = exchange.fetch_deposits(asset_name, since, limit=None, params=param)

    #This sum up all deposits if such deposit is made to specified deposit address
    for item in deposits:
      if item['addressTo'] == deposit_address[asset_name]:
        deposits_total = deposits_total + item['amount']
        deposits_count = deposits_count +1
        print(item['datetime'])

    return(deposits_total, deposits_count)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软的没边 2025-02-13 16:02:11

感谢Alex和Kroitor(在Github上)。

下面的代码应归功于KROOTOR(在GitHub上) https://github.com/github.com/ccxt/ccxt/问题/13806

import ccxt

# make sure your version is 1.51+
print('CCXT Version:', ccxt.__version__)

exchange = ccxt.ftx({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
    # "headers": {
    #     "FTX-SUBACCOUNT": "YOUR_SUBACCOUNT"
    # }
})


markets = exchange.load_markets ()

# exchange.verbose = True  # uncomment for debugging

all_results = {}
symbol = None
since = None
limit = 200
end_time = exchange.milliseconds()

while True:
    print('------------------------------------------------------------------')
    params = {
        'end_time': int(end_time / 1000),
    }
    results = exchange.fetch_deposits(symbol, since, limit, params)
    if len(results):
        first = results[0]
        last = results[len(results) - 1]
        end_time = first['timestamp']
        print('Fetched', len(results), 'deposits from', first['datetime'], 'till', last['datetime'])
        fetched_new_results = False
        for result in results:
            if result['id'] not in all_results:
                fetched_new_results = True
                all_results[result['id']] = result
        if not fetched_new_results:
            print('Done')
            break
    else:
        print('Done')
        break


all_results = list(all_results.values())
all_results = exchange.sort_by(all_results, 'timestamp')

print('Fetched', len(all_results), 'deposits')
for i in range(0, len(all_results)):
    result = all_results[i]
    print(i, result['id'], result['currency'], result['datetime'], result['amount'])

检查正确性的最简单方法是使用

https://chain.so/api/v2/get_address_received/coin_name/your_address

示例

比较 escrenceed_received_value 与ftx返回的值

Thanks Alex and Kroitor(on Github).

Code below should credit to Kroitor (on Github) https://github.com/ccxt/ccxt/issues/13806

import ccxt

# make sure your version is 1.51+
print('CCXT Version:', ccxt.__version__)

exchange = ccxt.ftx({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
    # "headers": {
    #     "FTX-SUBACCOUNT": "YOUR_SUBACCOUNT"
    # }
})


markets = exchange.load_markets ()

# exchange.verbose = True  # uncomment for debugging

all_results = {}
symbol = None
since = None
limit = 200
end_time = exchange.milliseconds()

while True:
    print('------------------------------------------------------------------')
    params = {
        'end_time': int(end_time / 1000),
    }
    results = exchange.fetch_deposits(symbol, since, limit, params)
    if len(results):
        first = results[0]
        last = results[len(results) - 1]
        end_time = first['timestamp']
        print('Fetched', len(results), 'deposits from', first['datetime'], 'till', last['datetime'])
        fetched_new_results = False
        for result in results:
            if result['id'] not in all_results:
                fetched_new_results = True
                all_results[result['id']] = result
        if not fetched_new_results:
            print('Done')
            break
    else:
        print('Done')
        break


all_results = list(all_results.values())
all_results = exchange.sort_by(all_results, 'timestamp')

print('Fetched', len(all_results), 'deposits')
for i in range(0, len(all_results)):
    result = all_results[i]
    print(i, result['id'], result['currency'], result['datetime'], result['amount'])

The easiest way to check the correctness is using

https://chain.so/api/v2/get_address_received/coin_name/your_address

Example
https://chain.so/api/v2/get_address_received/DOGE/DM7Yo7YqPtgMsGgphX9RAZFXFhu6Kd6JTT

Compare confirmed_received_value with returned value from FTX

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文