Profit Parser — How to Run & Use | Broxynet
Developer Utility · Profit Parsing

Profit Parser

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.

0npm Dependencies
2Prompts to Answer
< 1 minTo Run
v14+Node.js Minimum
Step 01 — Overview

What the Parser Does

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.

  • Input — one JSON state file per pair + exchange (for example from Gunbot), containing the full list of buy and sell orders for that position in an orders array.
  • Matching — every sell is matched to the earliest open buy with an identical order amount. Matching is first-in, first-out within each size.
  • Per-pair P&L — calculated as sell.costProceed − |buy.costProceed|, so a negative cost on the buy side is handled automatically.
  • Report — a new JSON file listing every matched pair, any orders that never closed, and your total profit for the position.

How Matching Works

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.

Step 02 — Setup

Prerequisites & Folder Layout

Two things are needed before you run anything: Node.js and the state file in place. There is nothing to install.

  • Node.js v14 or newer — the runtime that executes the CLI. Download from nodejs.org if you don’t have it. No npm packages are required for this tool.
  • A state JSON file per pair/exchange — placed in a json/ folder, e.g. json/cryptocom-USD-BTC-state.json, with an orders array inside.
  • A terminal — Command Prompt or PowerShell on Windows; Terminal on Linux/macOS.

Folder Layout

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

What a State File Looks Like

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 }
  ]
}
File naming matters. The script builds the path as 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.
Step 03 — Run It

Running the Parser

Open a terminal, step into the folder that contains json/, and run the script with Node.js.

Windows (Command Prompt or PowerShell)

  1. Open Command Prompt or PowerShell.
  2. Navigate to the folder that contains json/:
    cd C:\profit-parser
  3. Run the script with Node.js:
    node profit-parser-pub.js

Linux / macOS (Ubuntu · Debian, etc.)

  1. Open a Terminal.
  2. Navigate to the folder that contains json/:
    cd ~/profit-parser
  3. Run the script with Node.js:
    node profit-parser-pub.js

Answering the Two Prompts

The script asks two questions, in this order:

  • Trading pair — exactly as it appears in your state file name, e.g. USD-BTC. Type it upper-cased so the path resolves correctly.
  • Exchange — the same prefix used in the filename, e.g. cryptocom.

What a Successful Run Looks Like

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
If you see “File not found”: the pair/exchange you typed doesn’t resolve to an existing state file. The script looks in 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).
Reference — Output

Reading the P&L Report

Each run writes one JSON file into the folder you ran it from: profits-parsed-{pair}-{exchange}.json.

  • matchedOrders — every completed buy→sell round trip, including the original orders and that pair’s profit.
  • unmatchedBuys — buys that are still open (no same-size sell yet).
  • unmatchedSells — sells with no matching buy at all (for example partial fills or short positions).
  • totalProfit — the sum of all matched profits. A positive number means the closed portion of that position is net profitable.

Example Report

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
}
How profit is signed. The formula is 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.
Get The Tool

Download profit parser

confirm and analyze your Gribz profit performance.

📊
profit-parser

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.

SHA-256:  1567a3da1b692fbaac3c93026c4e29edd2d4105161bfccbd58e220ff141268fa
Reference — Troubleshooting

Common Issues & Fixes

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.
  • Invalid JSON (SyntaxError) — The state file isn’t valid JSON or is empty. Open it in a text editor, fix the syntax, save, and re-run.
  • Empty report (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.
  • Missing fields in an order — If an order lacks type, amount, time, or costProceed, that order can’t be matched. Verify the state file format from Step 02.
This tool is provided “as is” for informational and testing purposes only. No liability is assumed by Broxynet or the developer for any resulting losses, damages, or misuse. P&L figures are calculated from the values present in your state file and do not account for funding rates, spread, or fees beyond what those values already include. Use at your own risk and ensure compliance with your exchange’s terms of service.