Bringing Financial Assets Onchain
  • Introduction
    • Welcome to Allo
  • AlloX
  • Overview
  • Getting Started
    • Sign Up
    • Add Funds
    • Start Trading
  • Trading
    • Perpetual Assets
    • Order Book
    • Trading Pairs
    • Order Types
    • Take profit and stop loss orders (TP/SL)
    • Entry Price and PnL
    • Fees
  • FAQ
  • Staking
    • Overview
    • Architecture
    • Staking Phase 1
      • Mint alloBTC from BTC
      • Redeem BTC from alloBTC
    • Staking Phase 2
  • Tokenize
    • Overview
    • Architecture
  • Lending
    • Overview
    • Architecture
      • Lending Phase-1
  • On-chain Funds
    • Overview
    • Architecture
      • On-chain Fund Phase-1
      • On-chain Fund Phase-2
      • On-chain Fund Phase-3
  • Trading
    • Overview
    • Architecture
  • User Guides
    • Network Information
    • Assets
    • Stake BTC
    • Mint alloBTC
Powered by GitBook
On this page
  • Perps
  • Spot
  1. Trading

Entry Price and PnL

PreviousTake profit and stop loss orders (TP/SL)NextFees

Last updated 29 days ago

On the AlloX, entry price, unrealized pnl, and closed pnl are purely frontend components provided for user convenience. The fundamental accounting is based on margin (balance for spot) and trades.

Perps

Perp trades are considered opening when the absolute value of the position increases. In other words, longing when already long or shorting when already short.

For opening trades, the entry price is updated to an average of the current entry price, and the trade price is weighted by size.

For closing trades, the entry price is kept the same.

Unrealized pnl is defined as side * (mark_price - entry_price) * position_size where side = 1 for a long position and side = -1 for a short position

Closed pnl is fee + side * (mark_price - entry_price) * position_size for a closing trade, and only the fee for an opening trade.

Spot

Spot trades use the same formulas as perps, with the following modifications: Spot trades are considered opening for buys and closing for sale. Transfers are treated as buys or sells at the market price, and genesis distributions are treated as having an entry price at 10000 USDC the market cap. Note that while 0 is the correct answer as genesis distributions are not bought, it leads to an undefined return on equity.

Preexisting spot balances are assigned an entry price equal to the first trade or send after the feature is enabled around July 3, 08:00 UTC.