KCB Solutions

Hummingbot cost basis

Turn a Hummingbot session’s USD spot buys and sells into a FIFO workpaper. The converter runs on your own computer. It needs Python 3.9 or later and local time-zone data.

Convert your trades

Run export trades in Hummingbot. Its session CSV records the bot’s local time to the second and omits fees. For one spot account, supply the bot’s time zone, the actual USD fee for every fill and one documented opening lot or empty balance for each asset. Where fills of one asset share a second, supply their original order in sameTimeOrder.

Use pairs quoted directly in USD and fees charged in USD. The converter refuses unsupported orders, mixed exchanges and ambiguous timestamps. Keep the original records for other sessions and accounts.

Download the local converter

Fictional Hummingbot export · Matching fee and opening records

python3 hummingbot.py hummingbot-example.csv hummingbot-context.json trades.json

The context uses Market/Id to match each fee and any same-second order to its fill. Set authorized and spotOnly only when both are true. The output is a new file on your device.

Get the FIFO workpaper

In the fictional DOGE example, the bot buys 100 DOGE for $20 plus a $0.20 fee. It later sells 40 for $12 with a $0.12 fee. The allocated basis is $8.08, net proceeds are $11.88 and the realized gain is $3.80.

Download the matching workpaper CSV

Download the FIFO upload client and prepare the converted book. The two-fill example costs 0.05 USDC total. Preparing it is free.

python3 bulk_upload.py prepare trades.json --state my-order

Authorize the amount and collect the CSV

Read the example’s quote (JSON)