Skip to main content

Documentation Index

Fetch the complete documentation index at: https://quantumfinance.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Quantum Finance tracks your performance through two distinct layers: a live floating PnL that updates every second while a position is open, and a realized PnL that is locked in when the engine closes the trade. How that realized profit is recorded, split, and surfaced to you depends on whether you are trading in demo or real mode.

Floating PnL while a trade is open

As soon as the engine opens a position, the Trading tab begins calculating a live floating PnL based on how far the current market price has moved from your entry price. The formula is:
price_diff = (current_price - entry_price)   # for LONG
price_diff = (entry_price - current_price)   # for SHORT

pnl_percent = price_diff / entry_price
floating_pnl = trade_amount × leverage × pnl_percent
In real mode, leverage is 100×. This means a 0.5% favorable move on a 100positionproducesa100 position produces a 50 floating profit. The same move in the opposite direction produces a $50 floating loss. The floating PnL resets to zero when a position closes. It is a display-only figure — no funds move until settlement.
Floating PnL is not written to the database or the smart contract. It is calculated client-side in real time and exists only for display purposes while the engine is running.

Realized PnL on settlement

When the engine closes a trade — whether due to take profit, stop loss, momentum reversal, or scalping timeout — the position is settled. Settlement calculates the final PnL as:
pnl = lot_size × trade_amount × price_movement_percent
Note that the settlement calculation uses lot_size × trade_amount (not the full leveraged amount) as the base for the position. The 100× leverage figure applies to the floating display only. Realized PnL is grounded in the actual dollar amount traded per lot. Anti-slippage clamping: If a trade closes via stop loss or a timeout, the engine clamps the PnL loss to the strategy’s exact stop-loss threshold. This prevents polling gaps — where the price might have moved past the stop level between updates — from over-penalizing the settlement amount.
StrategySL clamp
Scalping−0.10%
Aggressive−0.20%
Momentum−0.50%
Conservative−0.30%

The 50/50 profit split

When a trade produces a positive PnL, the settlement engine splits it equally:
  • 50% goes to you (credited to your user account and reflected in your on-chain vault balance in real mode)
  • 50% goes to the Quantum treasury (a protocol fee that funds ongoing development and operations)
Losses are not split — they are absorbed entirely by your position. The split is enforced by the TradingVault smart contract — you can verify it by reading the TREASURY_FEE_PERCENT constant on the deployed contract. The ledger update credits your balance, and the blockchain sync follows so your on-chain profit figure updates shortly after.

Demo mode PnL

In demo mode, trades are simulated against live market prices using your virtual balance. No on-chain transactions occur. Demo mode applies an artificial win rate boost: when a trade would result in a loss, the engine has an 80% chance of flipping it to a profit of the same absolute value. This makes demo sessions feel consistently positive and is intentional — it lets you explore the engine’s behavior and strategy differences without the frustration of random early losses.
Demo mode results do not reflect what you will experience in real mode. The artificial win rate is removed entirely in real mode, where all trades settle based on actual market outcomes.
Your demo session PnL resets each time you start a new trading session. The cumulative total (total PnL) persists across sessions in your account.

Real mode PnL and on-chain profit

In real mode, every trade that closes generates an on-chain record. The ProfitDistributed event is emitted by the TradingVault contract with the user address, user share, and treasury share. The Quantum UI polls this data every 10 seconds and displays it as on-chain profit.
The sum of all completed trade PnLs for the current calendar day, across both demo and real modes depending on which mode you are viewing. Resets at midnight UTC.
The cumulative sum of all completed trade PnLs since your account was created, for the current mode (demo or real). This figure persists across sessions and is sourced from your trade history in the database.
Only available in real mode. This is the profit balance held in your TradingVault position on BNB Chain, as reported by the contract’s getUserInfo function. It represents your share of profits from completed real-mode trades and is the amount available for withdrawal via withdrawProfits.The UI syncs this value every 10 seconds from the contract. If you see a discrepancy between the UI figure and the contract directly, wait for the next sync cycle or refresh the page.

Trade settlement state

After you press Stop, the engine does not immediately clear. Any open position must close before the session ends. During this window, the Trading tab displays a “PROTOCOL SETTLING…” status. This is normal — the engine is waiting for the current position to hit its take-profit or stop-loss before marking the session as complete.
Do not close the browser tab while the engine is in the settling state. If the page is closed mid-settlement, the position may remain as “Running” in the database until the next sync cycle resolves it.
Once all positions are closed and the session ends, the final session PnL is written to your trade history and your total and daily PnL figures update accordingly.