0

I am trying to get my trades earlier than 3 months I do it like this:

#I use ccxt library 
result = ccxt_binance.fetchMyTrades('BTC/USDT', since = 1588669559517)

But still get the trades only for 3 months and can't get trads before 2020-05-05 enter image description here Am i missing something?

Progman
  • 16,827
  • 6
  • 33
  • 48
user2950593
  • 9,233
  • 15
  • 67
  • 131

1 Answers1

0

Answered in the original issue on GitHub here:

An example in Python is available here:

# -*- coding: utf-8 -*-
import ccxt


exchange = ccxt.binance({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
    'enableRateLimit': True,
    # 'options': {
    #     'defaultType': 'spot', // spot, future, margin
    # },
})


exchange.load_markets ()

# exchange.verbose = True  # uncomment for debugging

symbol = 'ETH/BTC'
from_id = '0'
params = { 'fromId': from_id }
previous_from_id = from_id

all_trades = []

while True:

    print('------------------------------------------------------------------')
    print('Fetching with params', params)
    trades = exchange.fetch_my_trades(symbol, None, None, params)
    print('Fetched', len(trades), 'trades')
    if len(trades):
        # for i in range(0, len(trades)):
        #     trade = trades[i]
        #     print (i, trade['id'], trade['datetime'], trade['amount'])
        last_trade = trades[len(trades) - 1]
        from_id = last_trade['id']
        params['fromId'] = from_id
        if from_id == previous_from_id:
            break
        else:
            all_trades = all_trades + trades
    else:
        break

print('Fetched', len(all_trades), 'trades')
for i in range(0, len(all_trades)):
    trade = all_trades[i]
    print (i, trade['id'], trade['datetime'], trade['amount'])
Igor Kroitor
  • 1,548
  • 13
  • 16