Skip to content

Feature Request: Built-in PnL Tracking and Portfolio Analytics #25

@joseph-eldo

Description

@joseph-eldo

Feature Request: Built-in PnL Tracking and Portfolio Analytics

Summary

Add native portfolio tracking to SlopeSniper to help traders monitor their performance over time without external tools.

Use Case

As a trader, I want to see my realized and unrealized gains/losses, track my portfolio value over time, and understand my trading performance - all within SlopeSniper.

Current Gap

SlopeSniper provides excellent execution tools but lacks portfolio analytics:

  • ✅ Can see current wallet balance
  • ✅ Can see trade history
  • ❌ No starting balance reference
  • ❌ No PnL calculation
  • ❌ No performance metrics
  • ❌ No timeline/charting

Users must manually track this in spreadsheets or build custom scripts.

Proposed Solution

Basic Implementation

Add PnL tracking to existing commands:

# Initialize tracking with current balance as baseline
slopesniper pnl init

# View current PnL
slopesniper pnl

Output example:

Portfolio Performance
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Starting Value:  $14.17 (2026-01-27 22:38:31)
Current Value:   $12.49
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total PnL:       -$1.68 (-11.85%)
Realized PnL:    $0.00
Unrealized PnL:  -$1.68
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Trades:          1 buy, 0 sells
Win Rate:        N/A (no closed positions)

Data Structure

Store in ~/.slopesniper/pnl.db (SQLite):

CREATE TABLE snapshots (
    id INTEGER PRIMARY KEY,
    timestamp TEXT NOT NULL,
    sol_balance REAL,
    sol_value_usd REAL,
    total_value_usd REAL,
    trigger TEXT  -- 'manual', 'trade', 'init'
);

CREATE TABLE positions (
    id INTEGER PRIMARY KEY,
    mint TEXT NOT NULL,
    symbol TEXT,
    entry_timestamp TEXT,
    entry_amount REAL,
    entry_cost_usd REAL,
    entry_price REAL,
    exit_timestamp TEXT,
    exit_amount REAL,
    exit_value_usd REAL,
    exit_price REAL,
    realized_pnl REAL,
    status TEXT  -- 'open', 'closed'
);

Auto-Tracking

Automatically log snapshots after trades:

  • After slopesniper buy succeeds → log snapshot
  • After slopesniper sell succeeds → log snapshot + close position
  • Manual: slopesniper pnl snapshot → log current state

Advanced Features (Future)

1. Timeline view

slopesniper pnl timeline

Shows hourly/daily snapshots in ASCII chart

2. Position-level tracking

slopesniper pnl positions
Open Positions
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Token    Entry      Cost    Current   PnL      Age
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Peyote   $0.00014   $10.00  $8.81     -$1.19   24m

3. Export

slopesniper pnl export --format csv
slopesniper pnl export --format json

4. Statistics

slopesniper pnl stats
Trading Statistics
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total Trades:        42
Win Rate:            57.14%
Average Gain:        +32.5%
Average Loss:        -18.2%
Largest Win:         +247% ($123)
Largest Loss:        -42% ($38)
Average Hold Time:   4.2 hours

5. Reset/Rebase

# Reset starting point to current balance
slopesniper pnl reset

# Set specific starting balance
slopesniper pnl init --starting-value 100

Implementation Notes

Storage:

  • Use SQLite for structured queries
  • Store in ~/.slopesniper/pnl.db
  • Migrate existing trade_history.db if present

Performance:

  • Only log on trades, not on every price check
  • Keep snapshots table pruned (archive old data)
  • Fast queries for common operations

Privacy:

  • All data stored locally
  • No external services
  • User controls retention

Current Workaround

I built a bash + JSON solution:

pnl-tracker.json - Manual tracking database
log-trade.sh - Update after trades
view-pnl.sh - Display summary

Works but requires:

  • Running scripts manually after trades
  • No integration with SlopeSniper commands
  • Fragile JSON parsing
  • No historical charting

Benefits

  • Better decision making - See if your strategy is working
  • Risk management - Track drawdowns and position sizes
  • Tax reporting - Export trade history with cost basis
  • Motivation - Visual progress tracking
  • Professional tool - Compete with centralized exchange UX

Related Issues

Priority

Nice to have but adds significant value:

  • Basic PnL (init + current) = high value, low complexity
  • Position tracking = medium complexity
  • Charts/stats = lower priority, higher complexity

Start with basic PnL in a future release, iterate from there.


Example user flow:

# Day 1: Setup
$ slopesniper pnl init
✅ Baseline set: $100.00 (0.79 SOL)

# Trade some tokens
$ slopesniper buy BONK 25
$ slopesniper sell WIF all

# Check performance
$ slopesniper pnl
Portfolio: $112.50 (+12.50%)
Realized: +$8.00
Unrealized: +$4.50
Trades: 3 (2 closed, 1 open)

Clean, simple, valuable. 📊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions