Overview
Deriverse uses strongly-typed TypeScript interfaces to represent trading data, annotations, and analytics. All type definitions are located insrc/lib/types.ts.
Core Types
Trade
The primary interface representing a completed trade transaction.Properties
Unique identifier for the trade
Trading pair symbol (e.g.,
SOL-USDC, BTC-PERP)Quote currency for the trade (typically
USDC)Trade direction:
buy/sell: Spot market tradeslong/short: Perpetual futures positions
Order execution type:
'limit', 'market', 'stop_limit', or 'stop_market'Amount of the base asset traded
Execution price per unit
Total trade value (price × quantity)
Profit and loss for the trade (positive for profit, negative for loss)
Total fees paid for the trade
Currency in which fees are denominated
Timestamp when the position was opened
Timestamp when the position was closed
How long the position was held (in seconds)
Whether the trade was profitable (
true) or not (false)Blockchain transaction signature
Detailed breakdown of fee components (protocol, network, etc.)
true if this was a maker order, false for takerLeverage multiplier (perpetual futures only)
Price at which the position would be liquidated (perpetual futures only)
Amount of margin allocated to the position (perpetual futures only)
OrderType
Type alias for supported order types.Annotation Types
TradeAnnotation
User-created notes and metadata for journaling trades.Unique identifier for the annotation
References the associated trade’s
idUser’s notes about the trade
Categorical tags for filtering and organization
Key takeaways from the trade for future reference
When the annotation was first created
When the annotation was last modified
Analytics Types
FeeComposition
Breakdown of different fee components.Fee category (e.g.,
'Protocol (Maker)', 'Protocol (Taker)', 'Network')Absolute fee amount
Percentage of total fees
AnalyticsSummary
Aggregated fee analytics data.Breakdown of fee types and amounts
Total fees paid across all trades
DailyPnL
Daily profit/loss aggregation.Date in
YYYY-MM-DD formatTotal profit/loss for that day
Number of trades executed that day
Number of winning trades
Number of losing trades
SessionBucket
Performance metrics grouped by session (time of day).Time session:
morning: 6:00 AM - 12:00 PMafternoon: 12:00 PM - 6:00 PMevening: 6:00 PM - 10:00 PMnight: 10:00 PM - 6:00 AM
Total PnL for this session
Number of trades in this session
Win rate as a decimal (0.0 to 1.0)
TimeOfDayBucket
Hourly performance metrics.Hour of day (0-23)
Total PnL for this hour across all days
Number of trades executed in this hour
Win rate as a decimal (0.0 to 1.0)
