BloFin Portfolio Analyst
Analyze trading performance, review trade history, compute PnL metrics, and generate portfolio reports.
Core Analysis Workflows
1. Portfolio Snapshot
Build a comprehensive overview of the user's current portfolio state:
- Get account balance via
get_balance— total equity, available margin, unrealized PnL - Get all positions via
get_positions— open positions with entry price, size, PnL - Get current prices via
get_tickersfor each held instrument - Calculate and present:
- Total portfolio value (equity)
- Unrealized PnL (absolute and percentage)
- Per-position breakdown: instrument, side, size, entry price, current price, PnL, PnL%
- Available margin and margin usage ratio
- Largest winning and losing positions
Example prompts:
- "Give me a portfolio overview"
- "How is my portfolio doing?"
- "What's my total PnL?"
2. Trade History Analysis
Review past trades and compute performance metrics:
- Get trade fills via
get_fills_history— recent executed trades with fill prices - Get order history via
get_order_history— all past orders including cancelled ones - Analyze and present:
- Total trades in period
- Win rate (trades with positive
fillPnlvs total closing trades) - Average win size vs average loss size (profit factor)
- Most traded instruments
- Trading frequency patterns
Parameters for get_fills_history:
| Parameter | Type | Required | Description |
|---|---|---|---|
instId | String | No | Filter by instrument |
orderId | String | No | Filter by order |
before / after | String | No | Pagination by tradeId |
begin / end | String | No | Filter by timestamp (ms) |
limit | String | No | Max 100, default 20 |
Key fill response fields: instId, fillPrice, fillSize, fillPnl, positionSide, side, fee, ts.
Example prompts:
- "Show my trade history for the last 7 days"
- "What's my win rate on BTC-USDT?"
- "Analyze my trading performance this month"
3. PnL Breakdown
Detailed profit and loss analysis:
- Realized PnL — from
get_fills_history, sumfillPnlfor all closing trades - Unrealized PnL — from
get_positions, currentunrealizedPnl - Fees paid — from
get_fills_history, sumfeefields - Net PnL = Realized PnL + Unrealized PnL - Total Fees
- Present per-instrument PnL table
Example prompts:
- "Break down my PnL by instrument"
- "How much have I paid in fees?"
- "What's my net profit after fees?"
4. Spot Trade History (if applicable)
For users who also trade spot markets:
Use get_fills_history with spot-specific endpoints:
- Endpoint:
GET /api/v1/spot/trade/fills-history - Requires
instType: "SPOT"
Example prompts:
- "Show my spot trading history"
- "Compare my spot and futures performance"
5. Performance Report Generation
Generate a structured trading performance report:
When asked for a report, compile data from multiple sources and present
a well-formatted summary with tables and key metrics.
Report template:
📈 BloFin Trading Report
========================
Period: [start_date] to [end_date]
## Account Summary
- Total Equity: $XXX
- Available Balance: $XXX
- Margin Usage: XX%
## Open Positions
| Instrument | Side | Size | Entry | Current | PnL | PnL% |
|------------|------|------|-------|---------|-----|------|
## Performance Metrics
- Total Trades: XX
- Win Rate: XX%
- Average Win: $XX
- Average Loss: $XX
- Profit Factor: X.XX
- Total Fees: $XX
- Net Realized PnL: $XX
## Top Performers
- Best trade: [instrument] +$XX
- Worst trade: [instrument] -$XX
Example prompts:
- "Generate a trading report for this week"
- "Give me a detailed performance analysis"
- "Create a summary of my trading activity"
Analysis Guidelines
- Always include fees in PnL calculations — they significantly impact real returns
- Use timestamps to filter data to the user's requested time period
- Handle pagination — if more than 100 records exist, make multiple requests with
before/afterparameters - Present numbers clearly — use currency formatting, percentages, and color-coding context (profit vs loss)
- Compare to entry — always show PnL relative to entry price, not just absolute values
- Note data limitations — fill history may be limited to recent data; inform the user if the requested period exceeds available data