trade-accounting
Double-entry bookkeeping for trading operations with ledger management, P&L statements, balance sheets, and cash flow reporting
What this skill does
# Trade Accounting
Run your trading operation like a business. Every SOL spent, every token acquired, every fee paid, every gain realized — tracked with double-entry bookkeeping so your books always balance. Whether you trade through a personal wallet or an LLC, proper accounting turns chaos into clarity.
**Core principle**: Every transaction touches at least two accounts. Buy a token? Cash goes down, token holdings go up — by the same amount. This double-entry constraint catches errors automatically: if debits do not equal credits, something is wrong.
## Why Traders Need Accounting
Most traders track P&L loosely — "I started with 50 SOL and now I have 62 SOL." That tells you nothing about:
- How much came from realized trades vs unrealized positions
- What you paid in cumulative fees (gas, priority fees, swap fees)
- Whether your staking and LP income covers your operating costs
- Your actual cost basis for each holding (critical for taxes)
- Cash flow timing — are you profitable but illiquid?
Proper accounting answers all of these. It also separates **trading P&L** (mark-to-market, useful for strategy evaluation) from **tax P&L** (realized gains using a specific cost basis method, required for compliance).
---
## Account Types
A trading operation uses four account categories following standard accounting:
| Category | Normal Balance | Examples |
|----------|---------------|----------|
| **Assets** | Debit | Cash (SOL/USDC), token holdings, LP positions, staking deposits, receivables |
| **Liabilities** | Credit | Margin borrowing, accrued taxes payable |
| **Income** | Credit | Realized trading gains, staking rewards, airdrop income, LP fee income |
| **Expenses** | Debit | Trading fees, gas/priority fees, subscription costs, data feeds |
| **Equity** | Credit | Owner capital contributions, retained earnings, withdrawals (contra) |
### Chart of Accounts
See `references/planned_features.md` for a full chart of accounts. A minimal setup:
```
1000 Assets
1010 Cash – SOL
1020 Cash – USDC
1100 Token Holdings (one sub-account per token)
1200 LP Positions
1300 Staking Deposits
3000 Income
3010 Realized Trading Gains
3020 Staking Rewards
3030 Airdrop Income
3040 LP Fee Income
4000 Expenses
4010 Trading Fees (DEX swap fees)
4020 Gas & Priority Fees
4030 Slippage Cost
5000 Equity
5010 Owner Capital
5020 Retained Earnings
5030 Owner Withdrawals (contra-equity)
```
---
## Double-Entry Bookkeeping
Every transaction records equal debits and credits. Debits increase asset and expense accounts; credits increase liability, income, and equity accounts.
### Entry Examples
**Buy 1000 BONK for 0.5 SOL (0.001 SOL gas fee):**
| Account | Debit | Credit |
|---------|-------|--------|
| Token Holdings – BONK | 0.501 SOL | |
| Cash – SOL | | 0.501 SOL |
Or with the fee broken out explicitly:
| Account | Debit | Credit |
|---------|-------|--------|
| Token Holdings – BONK | 0.5 SOL | |
| Gas & Priority Fees | 0.001 SOL | |
| Cash – SOL | | 0.501 SOL |
**Sell 1000 BONK for 0.8 SOL (cost basis was 0.5 SOL, 0.001 SOL gas):**
| Account | Debit | Credit |
|---------|-------|--------|
| Cash – SOL | 0.799 SOL | |
| Gas & Priority Fees | 0.001 SOL | |
| Token Holdings – BONK | | 0.5 SOL |
| Realized Trading Gains | | 0.3 SOL |
**Receive staking rewards of 0.05 SOL:**
| Account | Debit | Credit |
|---------|-------|--------|
| Cash – SOL | 0.05 SOL | |
| Staking Rewards | | 0.05 SOL |
**Receive airdrop of 5000 JUP (valued at 2.1 SOL at receipt):**
| Account | Debit | Credit |
|---------|-------|--------|
| Token Holdings – JUP | 2.1 SOL | |
| Airdrop Income | | 2.1 SOL |
**Collect LP fees of 0.03 SOL:**
| Account | Debit | Credit |
|---------|-------|--------|
| Cash – SOL | 0.03 SOL | |
| LP Fee Income | | 0.03 SOL |
**Partial close — sell half a position:**
If you hold 2000 BONK at cost basis 1.0 SOL and sell 1000 for 0.7 SOL:
| Account | Debit | Credit |
|---------|-------|--------|
| Cash – SOL | 0.699 SOL | |
| Gas & Priority Fees | 0.001 SOL | |
| Token Holdings – BONK | | 0.5 SOL |
| Realized Trading Gains | | 0.2 SOL |
The cost basis of the sold portion (0.5 SOL = half of 1.0 SOL) is removed from the asset account.
---
## Transaction Types
The ledger handles these trading flows:
| Flow | Accounts Touched |
|------|-----------------|
| Fund account | Cash (debit), Owner Capital (credit) |
| Withdraw funds | Owner Withdrawals (debit), Cash (credit) |
| Buy token | Token Holdings (debit), Cash (credit), Gas Expense (debit) |
| Sell token | Cash (debit), Token Holdings (credit), Realized Gains (credit or debit for loss), Gas Expense (debit) |
| Partial close | Same as sell, pro-rated cost basis |
| Swap token for token | Token B (debit), Token A (credit), fees |
| Staking deposit | Staking Deposits (debit), Cash (credit) |
| Staking reward | Cash (debit), Staking Rewards (credit) |
| Airdrop received | Token Holdings (debit), Airdrop Income (credit) |
| LP fee collected | Cash (debit), LP Fee Income (credit) |
| Trading fee | Trading Fees (debit), Cash (credit) |
| Gas/priority fee | Gas & Priority Fees (debit), Cash (credit) |
---
## Reports
### Profit & Loss Statement
Shows income minus expenses for a period:
```
═══════════════════════════════════════════
P&L Statement: 2026-02-01 to 2026-02-28
═══════════════════════════════════════════
INCOME
Realized Trading Gains ........ 4.200 SOL
Staking Rewards ............... 0.150 SOL
Airdrop Income ................ 2.100 SOL
LP Fee Income ................. 0.090 SOL
─────────
Total Income 6.540 SOL
EXPENSES
Trading Fees .................. 0.120 SOL
Gas & Priority Fees ........... 0.045 SOL
Slippage Cost ................. 0.030 SOL
─────────
Total Expenses 0.195 SOL
═══════════════════════════════════════════
NET INCOME 6.345 SOL
═══════════════════════════════════════════
```
### Balance Sheet
Shows the accounting equation: Assets = Liabilities + Equity.
```
═══════════════════════════════════════════
Balance Sheet: 2026-02-28
═══════════════════════════════════════════
ASSETS
Cash – SOL .................... 32.450 SOL
Cash – USDC ................... 0.000 SOL
Token Holdings ................ 12.300 SOL
LP Positions .................. 5.000 SOL
Staking Deposits .............. 10.000 SOL
─────────
Total Assets 59.750 SOL
EQUITY
Owner Capital ................. 50.000 SOL
Retained Earnings ............. 3.405 SOL
Net Income (current period) ... 6.345 SOL
─────────
Total Equity 59.750 SOL
═══════════════════════════════════════════
Assets - Equity = 0.000 SOL ✓ Balanced
═══════════════════════════════════════════
```
### Cash Flow Statement
Tracks where cash came from and where it went:
```
═══════════════════════════════════════════
Cash Flow: 2026-02-01 to 2026-02-28
═══════════════════════════════════════════
OPERATING ACTIVITIES
Trading proceeds .............. 8.500 SOL
Token purchases ............... (4.300) SOL
Fees paid ..................... (0.195) SOL
Staking rewards received ...... 0.150 SOL
LP fees received .............. 0.090 SOL
─────────
Net Operating Cash Flow 4.245 SOL
INVESTING ACTIVITIES
LP deposits ................... (5.000) SOL
Staking deposits .............. (2.000) SOL
─────────
Net Investing Cash Flow (7.000) SOL
FINANCING ACTIVITIES
Capital contributions ......... 10.000 SOL
Withdrawals ................... (1.000) SOL
─────────
Net Financing Cash Flow 9.000 SOL
═══════════════════════════════════════════
Net Change in Cash 6.245 SOL
BeginRelated in Data & Analytics
clawarr-suite
IncludedComprehensive management for self-hosted media stacks (Sonarr, Radarr, Lidarr, Readarr, Prowlarr, Bazarr, Overseerr, Plex, Tautulli, SABnzbd, Recyclarr, Unpackerr, Notifiarr, Maintainerr, Kometa, FlareSolverr). Deep library exploration, analytics, dashboard generation, content management, request handling, subtitle management, indexer control, download monitoring, quality profile sync, library cleanup automation, notification routing, collection/overlay management, and media tracker integration (Trakt, Letterboxd, Simkl).
querying-soql
IncludedSOQL query generation, optimization, and analysis with 100-point scoring. Use this skill when the user needs SOQL/SOSL authoring or optimization: natural-language-to-query generation, relationship queries, aggregates, query-plan analysis, and performance or safety improvements for Salesforce queries. TRIGGER when: user writes, optimizes, or debugs SOQL/SOSL queries, touches .soql files, or asks about relationship queries, aggregates, or query performance. DO NOT TRIGGER when: bulk data operations (use handling-sf-data), Apex DML logic (use generating-apex), or report/dashboard queries.
app-store-optimization
IncludedApp Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklists, and tracking ranking changes.
habit-flow
IncludedAI-powered atomic habit tracker with natural language logging, streak tracking, smart reminders, and coaching. Use for creating habits, logging completions naturally ("I meditated today"), viewing progress, and getting personalized coaching.
app-store-optimization
IncludedApp Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklists, and tracking ranking changes.
visualizing-data
IncludedBuilds dashboards, reports, and data-driven interfaces requiring charts, graphs, or visual analytics. Provides systematic framework for selecting appropriate visualizations based on data characteristics and analytical purpose. Includes 24+ visualization types organized by purpose (trends, comparisons, distributions, relationships, flows, hierarchies, geospatial), accessibility patterns (WCAG 2.1 AA compliance), colorblind-safe palettes, and performance optimization strategies. Use when creating visualizations, choosing chart types, displaying data graphically, or designing data interfaces.