A lightweight Node.js CLI that reads an exchange state file, matches every sell order back to its original buy by amount, and writes a clean profit-and-loss report. No npm install — it runs on the built-in fs and path modules alone.
In plain terms: you give it a trading pair and an exchange, it finds that pair’s state file, pairs each sell with its buy, and tells you what every closed round trip made or lost.
orders array.sell.costProceed − |buy.costProceed|, so a negative cost on the buy side is handled automatically.Buy and sell orders are grouped by amount. When a sell of exactly X coins arrives, the parser takes the oldest open buy of X coins and closes it out. Sells with no same-size buy — and any buys left over at the end — are reported as unmatched: they are still-open positions, not closed trades.
Two things are needed before you run anything: Node.js and the state file in place. There is nothing to install.
json/ folder, e.g. json/cryptocom-USD-BTC-state.json, with an orders array inside.profit-parser/
├── profit-parser-pub.js # the CLI — this is the file you run
└── json/
├── cryptocom-USD-BTC-state.json # state file for that pair + exchange
└── binance-ETH-USDT-state.json # one more per pair/exchange you want to parse
Only the orders array is read. Each order must carry four fields: type ("buy" or "sell"), amount, time, and costProceed.
{
"orders": [
{ "type": "buy", "amount": 0.5, "time": "2026-10-01T14:05:00Z", "costProceed": -1250 },
{ "type": "sell", "amount": 0.5, "time": "2026-10-03T09:20:00Z", "costProceed": 1400 },
{ "type": "buy", "amount": 0.25, "time": "2026-10-04T11:00:00Z", "costProceed": -620 }
]
}
json/{exchange}-{PAIR}-state.json with the pair upper-cased. For exchange cryptocom and pair USD-BTC, the file must be exactly json/cryptocom-USD-BTC-state.json.Open a terminal, step into the folder that contains json/, and run the script with Node.js.
json/:
cd C:\profit-parser
node profit-parser-pub.js
json/:
cd ~/profit-parser
node profit-parser-pub.js
The script asks two questions, in this order:
USD-BTC. Type it upper-cased so the path resolves correctly.cryptocom.Enter the trading pair (e.g., USD-BTC): USD-BTC
Enter the exchange (e.g., cryptocom): cryptocom
Results written to C:\profit-parser\profits-parsed-USD-BTC-cryptocom.json
json/ relative to wherever you ran it — check that you’re inside the folder containing json/, and that the filename matches exactly (including casing of the exchange name).Each run writes one JSON file into the folder you ran it from: profits-parsed-{pair}-{exchange}.json.
For the state file shown in Step 02, running the parser produces:
{
"matchedOrders": [
{
"buyOrder": { "type": "buy", "amount": 0.5, "time": "2026-10-01T14:05:00Z", "costProceed": -1250 },
"sellOrder": { "type": "sell", "amount": 0.5, "time": "2026-10-03T09:20:00Z", "costProceed": 1400 },
"profit": 150
}
],
"unmatchedBuys": [
{ "type": "buy", "amount": 0.25, "time": "2026-10-04T11:00:00Z", "costProceed": -620 }
],
"unmatchedSells": [],
"totalProfit": 150
}
profit = sell.costProceed − |buy.costProceed|. A buy’s cost is always treated as a positive spend, so the sign of costProceed in your state file doesn’t matter. The parser uses the cost values exactly as they appear — it performs no fee adjustments of its own.confirm and analyze your Gribz profit performance.
A lightweight Node.js CLI that reads an exchange state file, matches every sell order back to its original buy by amount, and writes a clean profit-and-loss report.
Most problems come down to the path or the filename. Check these first.
File not found: json/… — You ran the script from a different folder, or the filename doesn’t match json/{exchange}-{PAIR}-state.json. Run it from the folder that contains json/, and double-check spelling and casing.totalProfit: 0, no matched orders) — Usually means there are no sells yet, or sell amounts never exactly equal buy amounts. The parser only matches identical sizes, so partial fills won’t pair up.type, amount, time, or costProceed, that order can’t be matched. Verify the state file format from Step 02.