PnL Tracking
PnL Tracking
Ganancias y Perdidas (PnL) tracking tells you si your grid bot is actually making money. Gridera tracks PnL at multiple levels: per trade, per session, and over el bot’s lifetime. Understanding each type te ayuda a evaluate performance accurately and make better decisions about tu configuracion.
Realized vs UnPnL realizado
La distincion mas importante in PnL tracking is between realized and unrealized profit.
Realized PnL is ganancia que ha sido asegurada a traves de operaciones completadas. When el bot compra at $95 and the TP sells at $96, the $1 difference (minus fees) is realized profit. This money is yours independientemente de what el precio does next. It cannot decrease a menos que you make new trades that lose money.
UnPnL realizado is the paper profit or loss on positions you currently hold. If el bot bought at $95 and the precio actual is $93, tienes an unrealized loss of $2 per unit. If el precio recovers to $97, that becomes an unrealized gain of $2. UnPnL realizado fluctuates constantly with el mercado price.
La clave insight: a grid bot with high PnL realizado and temporary unrealized losses is performing well. The realized profits are permanent, mientras el unrealized losses will likely recover as el precio oscila back a traves del grid.
Session PnL
Session PnL tracks performance from the moment you start el bot until you stop it. It includes ambos realized and unrealized components.
Each time you restart el bot, the session PnL resets to zero. This gives you a clean measurement of each run’s performance. Session PnL is useful for evaluating si a configuration change improved results.
Session PnL data is stored in a session file that updates as trades complete. El dashboard reads this file to display current session metrics.
Lifetime PnL
Lifetime PnL accumulates across all sessions. Cuando stop and restart el bot, the lifetime tracker preserves previous session results and continues adding to them.
This gives you the true long-term picture of tu bot’s profitability. A bot might have several sessions with small losses during mercado con tendencias but overall positive lifetime PnL from productive sideways periods. Looking only at individual sessions would miss this bigger picture.
Lifetime PnL is stored in a persistent file that survives bot restarts and updates with each completed trade.
How PnL Is Calculated
For each completed grid trade, the PnL realizado calculation is:
Realized PnL = (Sell price - Buy price) x Quantity - Total fees
For a long grid bot that buys at $95 and sells at $96, with 10 units and 0.02% maker fees on each side:
- Gross profit = ($96 - $95) x 10 = $10
- Buy fee = $95 x 10 x 0.0002 = $0.19
- Sell fee = $96 x 10 x 0.0002 = $0.192
- Net PnL realizado = $10 - $0.19 - $0.192 = $9.618
UnPnL realizado se calcula as:
UnPnL realizado = (Current price - Entry price) x Position quantity
For a long position entered at $95 with 10 units and precio actual at $93:
- UnPnL realizado = ($93 - $95) x 10 = -$20
PnL Files
Gridera stores PnL data in two files:
realized_pnl.json: Contains the cumulative PnL realizado across all sessions. This file updates cada vez que a TP order fills and a round-trip trade completes. The data includes total realized profit, number of completed trades, and average profit per trade.
session.json: Contains the current session’s PnL data. This resets when el bot restarts. It includes session start time, session PnL realizado, trade count, and el mas recent trade details.
Both files are written to the pnl/ directory and are read by el dashboard for display.
Reading PnL on the Dashboard
El dashboard presents PnL information in several ways:
Total PnL number: The combined realized and PnL no realizado. Este es el headline number but can be misleading during temporary drawdowns. A bot with $50 realized profit and -$30 unrealized shows $20 total, but the $50 is permanent mientras el -$30 is temporary.
PnL chart: A time-series chart showing how PnL has evolved. Look for a generally upward-trending line with dips during price drops. A healthy grid bot shows a staircase pattern: flat during holds, stepping up when TP orders fill.
Trade history: Individual completed trades with their profit contribution. This lets you see which nivel de grids are generating el mas profit and how frequently trades occur.
Common PnL Patterns
Staircase pattern: Realized PnL steps up with each completed trade while PnL no realizado oscillates. Este es el ideal grid bot pattern indicating consistent trade completion.
Sawtooth pattern: PnL rises gradually then drops sharply. This happens cuando el precio trends down through multiple nivel de grids, accumulating positions that create large unrealized losses. The sharp drops reverse cuando el precio recovers.
Flat line: No trades are completing. El precio is either above your entire grid (no buys filling) or below (no TPs filling). Consider adjusting your range.
Steady decline: Both realized and PnL no realizado are trending down. Thes generalmente indicates fees are consuming mas que el grid spacing generates, or funding costs are eroding profits. Review your fee optimization and spacing.
Resumen
- Realized PnL is locked-in profit from completed trades; PnL no realizado fluctuates with current positions and market price.
- Session PnL resets on each restart, while lifetime PnL accumulates across all sessions for long-term performance tracking.
- A healthy grid bot shows a staircase PnL pattern with realized profits stepping up and PnL no realizado oscillating.
Siguiente Paso
Learn how to assess and manage risk using el riesgo panel in Risk Panel Usage.
✨ Te fue util este articulo?
Haz tus preguntas en Discord →