Basislane · Hyperliquid realized P&L guide · Prepared by Chirag Kotadiya, CA
Basislane knowledge guide · No trader-speak required

Your Hyperliquid profit or loss, explained in plain English

This Basislane page turns spreadsheet labels (like “Open Long” or “closedPnl”) into everyday language — so you can see when you made money, when you lost it, and how the final USDC number is calculated.

Prepared by Chirag Kotadiya, CA · Basislane

Full picture of your cash result

Final profit or loss
= closed trade wins/losses
trading fees
± funding (paid or received)

From the trades file: Σ closedPnl − Σ fee. Funding comes from a separate funding history — not the trades CSV.

Closing a bet locks price P&L Trading fees on every fill Funding while you hold a perp
Word guide

What do these words mean?

Read this first. Everything later uses these everyday meanings.

01 · Big picture

What this export is really showing

Think of Hyperliquid as a book that records every trade and, when you finish a bet, how much you won or lost.

Step 1 · Closed trades
Add locked wins & losses
When you finish a futures bet, the score is closedPnl (from the trades file).
Step 2 · Trading fees
Subtract commissions
Paid almost every time you trade. Also in the trades file (fee).
Step 3 · Funding
Add or subtract holding cost
While a futures bet is open, money can move between longs and shorts hourly. Not in the trades CSV.
Step 4 · Full net result (USDC)
Closed P&L − trading fees ± funding
Trades export alone = steps 1–2. For the complete account result, include funding (step 3) from the funding history / API.

Futures-style bets (perps)

You are betting that a price will go up (long) or down (short). You do not take the coin home — only the cash result matters.

  • Names look like BTC, ETH, HYPE
  • Profit/loss is locked when you close the bet
  • That locked amount is closedPnl
  • For tax software: report the cash win/loss, not “I bought Bitcoin”

Actually buying the coin (spot)

Like a shop: you pay USDC and receive the real token (or sell the token back for USDC).

  • Names look like @107 (a code for a token)
  • You own the asset until you sell it
  • Tax software should track buy/sell of the coin itself
  • Usually ignore Hyperliquid’s own spot profit guess
Simple rules: Starting or adding to a bet does not lock price profit yet. Closing does. Trading fees apply when you trade. Funding applies while you hold a futures bet open — even if you never trade that hour.
Funding · holding cost / credit

What is a funding fee?

A separate cash payment between traders who are long and short — not a commission to the exchange.

In plain English

Perpetual futures never expire, so something has to keep the futures price near the real “spot” price. That something is funding: every so often (on Hyperliquid, typically every hour), one side of the market pays the other side a small amount of USDC based on how crowded the bet is.

The exchange does not keep this money as its fee. It is a peer-to-peer transfer between people who are long and people who are short. You only pay or receive funding if you still have an open futures position at settlement time.

Positive funding rate

Futures price is generally rich vs spot — more people want to be long.

  • Longs pay shorts
  • Holding a long costs you a little each period
  • Holding a short earns you a little each period

Negative funding rate

Futures price is generally cheap vs spot — more people want to be short.

  • Shorts pay longs
  • Holding a short costs you a little each period
  • Holding a long earns you a little each period
Who it applies to
Open perps only
Spot holdings do not pay/receive this funding stream.
How often (HL)
Usually hourly
As long as you keep the position open through the checkpoint.
Where it shows up
Funding history
Not in the trades CSV. Use funding ledger / userFunding API.

Rough money formula (idea, not tax advice)

In words: payment ≈ size of your position × price × funding rate for that period

If you pay funding → your USDC balance goes down a little
If you receive funding → your USDC balance goes up a little

Example: $100,000 notional long · rate +0.0013% per hour
You pay about $1.30 that hour to shorts.
Funding ≠ trading fee. Trading fee = commission when you place/fill a trade. Funding = holding cost or credit while the bet stays open. Both affect how much USDC you end up with.

How funding fits your total result

1
Price P&L when you close (closedPnl from trades)
Did the market move for or against you between entry and exit?
2
Trading fees (fee from trades)
What you paid (or rebates you got) on fills.
3
Funding while open (from funding history)
All the small hourly payments you paid or received before closing.
=
Full futures cash result
net = Σ closedPnl − Σ trading fees + Σ funding received − Σ funding paid
(If funding is stored as one signed number — positive = received, negative = paid — just add Σ funding.)
02 · Trade types

What each “direction” means in plain English

The spreadsheet column dir is just a short label for “what did this trade do to your position?”

Remember: “Open only” = you opened or added — no final score yet. “Locks in profit/loss” = you closed some or all of the bet — score is counted. “Flip” = you closed one side and immediately started the opposite bet in one trade.
03 · How money is counted

The math, without the jargon

Hyperliquid remembers your average entry price. When you close, it compares that to the exit price.

When you open or add (Open Long / Open Short)

You are only getting into the bet (or adding more). Nothing is “finished,” so there is no locked-in profit or loss yet.

1
You already hold some at an average price
Example: long 2 coins, average buy price $100.
2
You add more at a new price
Example: buy 2 more at $120.
3
Your new average entry is blended
Average becomes $110. Closed profit = still $0 on this add.
In words: new average = (old amount × old price + new amount × new price) ÷ total amount
Locked-in profit on this step = $0

When you close (Close Long / Close Short)

You are finishing some or all of the bet. That is when Hyperliquid writes a profit or loss number into closedPnl.

Close Long (you had bet on “price up”)

You sell to exit.
Profit if the exit price is higher than your average entry.

Profit = (exit − entry) × size closed
Close Short (you had bet on “price down”)

You buy back to exit.
Profit if the exit price is lower than your average entry.

Profit = (entry − exit) × size closed
Everyday example — Close Long:
Entry $100 · Exit $110 · Size 2
closedPnl = (110 − 100) × 2 = +$20
If fee was $0.50 → net = 20 − 0.50 = +$19.50

When you flip (Long > Short / Short > Long)

One trade both ends the old bet and starts the opposite bet.

1
You were long 5 (betting price goes up).
2
You sell 8 in one go → label can be Long > Short.
3
First 5 close the long → profit/loss is counted.
Remaining 3 open a new short → no profit yet on those 3.
Only the part that closed the old bet counts toward closedPnl. The leftover is a brand-new opposite bet at today’s price.

While the bet is open (funding)

Even if you do not trade, an open perpetual can move USDC in or out of your account each funding period. That is separate from the price win/loss you get when you close.

1
You hold a long or short through the hour
No need to place a new trade for funding to apply.
2
The market’s funding rate is positive or negative
Positive → longs pay shorts. Negative → shorts pay longs.
3
A small USDC amount is debited or credited
Rough idea: position size × price × rate for that period.
From funding history (signed USDC):
funding_net = Σ amounts receivedΣ amounts paid
or simply Σ signed funding if paid is already negative
You can make money on the price move and still lose on funding (or the reverse). Always check both closed trade P&L and funding when judging a long hold.

Your final net result in USDC

A
Add every closed profit and loss (trades file)
Wins positive, losses negative → Σ closedPnl.
B
Add every trading fee (trades file; rebates can be negative)
→ Σ fee.
C
Add net funding (funding history — not trades CSV)
Money received minus money paid while positions were open.
D
Full net = A − B + C
Trades-only view stops at A − B. Complete futures result includes C.
trades_only = Σ closedPnlΣ fee
full_net = trades_only + Σ funding (signed)
funding signed: + received, − paid
04 · Try it

See a number change live

Pick a trade type, enter prices and size, and watch profit/loss update.

Use “size closed” as only the part that ends the old bet when flipping.
The blended price Hyperliquid used when you opened.
The price of this fill.
How much of the position you finished on this trade.
Use a negative number if you received a rebate.

Your result for this trade

Locked-in profit/loss
Fee
After fee

Change the numbers to see what happens.

05 · Step-by-step

What to do with each line in the file

Click a path to highlight the journey of one trade row.

Take the next row in your export
Is this a trades row, or a funding history row?
Spot trade → buy/sell of the token (qty & USDC)
Futures fill → check direction + closedPnl + trading fee
Funding row → paid or received USDC while holding (separate file)
On a futures fill: did this close or flip a bet?
Yes → use closedPnl as the price win/loss
No → price P&L = 0 (you may still owe trading fee)
Combine: price P&L − trading fees ± funding into your running USDC total
06 · Cheat sheet

Every direction at a glance

Label in the file In plain English What you did Profit/loss locked?
Open Long Start or add a “price goes up” bet Bought exposure No — still open
Open Short Start or add a “price goes down” bet Sold exposure No — still open
Close Long End (part of) a “price up” bet Sold to exit Yes
Close Short End (part of) a “price down” bet Bought to exit Yes
Long > Short Flip: exit up-bet and start down-bet Sold more than you held long Yes (on the closed part)
Short > Long Flip: exit down-bet and start up-bet Bought more than you held short Yes (on the closed part)
Buy Bought (spot or old-style label) Paid USDC for an asset / long-ish Usually not on futures
Sell Sold (spot or old-style label) Gave asset for USDC / short-ish Often on spot sells
Spot Dust Conversion Tiny leftover cleaned up Dust cleanup Usually no
07 · For tax software (e.g. Koinly)

How to import without double-counting

Futures bets (perps)

Do not tell the software “I bought Bitcoin” on every open/close. You only had a cash win or loss in USDC.

  • If closedPnl is positive → record received that much USDC
  • If closedPnl is negative → record sent that much USDC
  • Record trading fees as money paid (or rebates received)
  • You can group by day or month per coin to keep files small

Real coin trades (spot)

Here you really moved tokens. Let the tax software track cost basis.

  • Buy: send USDC amount, receive the coin amount
  • Sell: send the coin amount, receive USDC amount
  • Usually ignore Hyperliquid’s own spot profit number so you don’t count gains twice

Funding payments

Import funding from the funding history, not from the trades CSV. Treat it as cash moving in or out of USDC while you held perps.

  • Funding received → receive USDC (often labeled like funding / income depending on your tool)
  • Funding paid → send USDC (expense / fee-style outflow)
  • Safe approach: one summarized row per coin per month (net paid or received)
  • Do not double-count: if closedPnl already included something, don’t add it again — on Hyperliquid fills, funding is separate
Watch-outs: older months may only say Buy/Sell and leave closedPnl blank; some trading fees may not be in USDC; funding is a third stream — without it, long-held perps can look more profitable (or worse) than they really were.
08 · For builders

If you want the technical version

Same logic as above, written for scripts. Skip if you only need the plain-English parts.

Preferred: trust Hyperliquid’s closedPnl

Add up closedPnl on futures rows, subtract fees. Opens contribute zero profit.

REALIZE_DIRS = { "Close Long", "Close Short", "Long > Short", "Short > Long", } def is_perp(coin): return not str(coin).startswith("@") def net_realized_usdc(fills): gross = fees = 0.0 for row in fills: if not is_perp(row.coin): continue gross += float(row.closedPnl or 0) fees += float(row.fee or 0) return gross - fees
Fallback: rebuild with average cost (only if closedPnl missing)

Walk trades in time order per coin. Adding same direction updates average entry. Reducing opposite direction locks profit on the closed size. Flips close first, then open the rest.

09 · Quick recap

If you only remember five things

QuestionSimple answer
When is price profit or loss final? When you close or flip a futures bet
Where is that dollar amount? In the closedPnl column (USDC) of the trades file
What about trading fees? Subtract Σ fee from the trades file
What is funding? Hourly-style payment between longs and shorts while a perp is open — not in the trades CSV
Full futures net? Σ closedPnl − Σ trading fees + Σ funding (signed)
What about Open Long / Open Short? No closed price score yet — but you can still pay/receive funding while open
Spot vs perp? Spot = real coin shop. Perp = cash bet on price — plus possible funding while held.