<commit_before># -*- coding: utf-8 -*-

import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt  # noqa: E402


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

exchange = ccxt.ftx({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
})


markets = exchange.load_markets ()

# exchange.verbose = True  # uncomment for debugging

all_trades = []
symbol = None
since = None
limit = 200
end_time = exchange.milliseconds()

while True:
    print('------------------------------------------------------------------')
    params = {
        'end_time': int(end_time / 1000),
    }
    trades = exchange.fetch_my_trades(symbol, since, limit, params)
    if len(trades):
        first_trade = trades[0]
        last_trade = trades[len(trades) - 1]
        end_time = first_trade['timestamp']
        all_trades = trades + all_trades
        print('Fetched', len(trades), 'trades from', first_trade['datetime'], 'till', last_trade['datetime'])
    else:
        print('Done')
        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'])
<commit_msg>Update ftx-fetch-all-my-trades.py<commit_after># -*- coding: utf-8 -*-

import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt  # noqa: E402


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

exchange = ccxt.ftx({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
})


markets = exchange.load_markets ()

# exchange.verbose = True  # uncomment for debugging

all_trades = []
symbol = None
since = None
limit = 200
end_time = exchange.milliseconds()

while True:
    print('------------------------------------------------------------------')
    params = {
        'end_time': int(end_time / 1000),
    }
    trades = exchange.fetch_my_trades(symbol, since, limit, params)
    if len(trades):
        first_trade = trades[0]
        if(end_time == first_trade['timestamp'] + 1000): break
        last_trade = trades[len(trades) - 1]
        end_time = first_trade['timestamp'] + 1000
        all_trades = trades + all_trades
        print('Fetched', len(trades), 'trades from', first_trade['datetime'], 'till', last_trade['datetime'])
    else:
        print('Done')
        break

        
ret_list = []
dup_ids = set()
for trade in all_trades:
    if trade['id'] in dup_ids: continue
    dup_ids.add(trade['id'])
    ret_list = [trade] + ret_list
all_trades = ret_list

   

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'])

{'fraction_non_alphanumeric': 0.19206680584551147, 'fraction_numerical': 0.014613778705636743, 'mean_word_length': 2.864247311827957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3209243', 'n_tokens_mistral': 1025, 'n_tokens_neox': 956, 'n_words': 212}