Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2021 02:48
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Convert FTX's transactions CSV format to CoinTracker's upload format for taxes
# Python 3.7+
# Usage: Download `trades.csv` from FTX.US, run this, and upload `cointracker.csv` to CoinTracker.
if __name__ == '__main__':
import csv
from datetime import datetime
trades = []
with open('trades.csv') as f:
reader = csv.DictReader(f)
for row in reader:
trade = {}
trade['Date'] = datetime.fromisoformat(row['time']).strftime("%m/%d/%Y %H:%M:%S")
trade['Fee Amount'] = row['fee']
trade['Fee Currency'] = row['feeCurrency']
pair = row['market'].split('/')
amounts = row['size'], float(row['price']) * float(row['size'])
if row['side'] == 'sell':
trade['Sent Currency'], trade['Received Currency'] = pair
trade['Sent Quantity'], trade['Received Quantity'] = amounts
trade['Received Currency'], trade['Sent Currency'] = pair
trade['Received Quantity'], trade['Sent Quantity'] = amounts
with open('cointracker.csv', 'w') as f:
writer = csv.DictWriter(f, ['Date', 'Received Quantity', 'Received Currency',
'Sent Quantity', 'Sent Currency', 'Fee Amount', 'Fee Currency'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment