$npx -y skills add agiprolabs/claude-trading-skills --skill trade-accountingDouble-entry bookkeeping for trading operations with ledger management, P&L statements, balance sheets, and cash flow reporting
| 1 | # Trade Accounting |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | **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. |
| 6 | |
| 7 | ## Why Traders Need Accounting |
| 8 | |
| 9 | Most traders track P&L loosely — "I started with 50 SOL and now I have 62 SOL." That tells you nothing about: |
| 10 | |
| 11 | - How much came from realized trades vs unrealized positions |
| 12 | - What you paid in cumulative fees (gas, priority fees, swap fees) |
| 13 | - Whether your staking and LP income covers your operating costs |
| 14 | - Your actual cost basis for each holding (critical for taxes) |
| 15 | - Cash flow timing — are you profitable but illiquid? |
| 16 | |
| 17 | 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). |
| 18 | |
| 19 | --- |
| 20 | |
| 21 | ## Account Types |
| 22 | |
| 23 | A trading operation uses four account categories following standard accounting: |
| 24 | |
| 25 | | Category | Normal Balance | Examples | |
| 26 | |----------|---------------|----------| |
| 27 | | **Assets** | Debit | Cash (SOL/USDC), token holdings, LP positions, staking deposits, receivables | |
| 28 | | **Liabilities** | Credit | Margin borrowing, accrued taxes payable | |
| 29 | | **Income** | Credit | Realized trading gains, staking rewards, airdrop income, LP fee income | |
| 30 | | **Expenses** | Debit | Trading fees, gas/priority fees, subscription costs, data feeds | |
| 31 | | **Equity** | Credit | Owner capital contributions, retained earnings, withdrawals (contra) | |
| 32 | |
| 33 | ### Chart of Accounts |
| 34 | |
| 35 | See `references/planned_features.md` for a full chart of accounts. A minimal setup: |
| 36 | |
| 37 | ``` |
| 38 | 1000 Assets |
| 39 | 1010 Cash – SOL |
| 40 | 1020 Cash – USDC |
| 41 | 1100 Token Holdings (one sub-account per token) |
| 42 | 1200 LP Positions |
| 43 | 1300 Staking Deposits |
| 44 | |
| 45 | 3000 Income |
| 46 | 3010 Realized Trading Gains |
| 47 | 3020 Staking Rewards |
| 48 | 3030 Airdrop Income |
| 49 | 3040 LP Fee Income |
| 50 | |
| 51 | 4000 Expenses |
| 52 | 4010 Trading Fees (DEX swap fees) |
| 53 | 4020 Gas & Priority Fees |
| 54 | 4030 Slippage Cost |
| 55 | |
| 56 | 5000 Equity |
| 57 | 5010 Owner Capital |
| 58 | 5020 Retained Earnings |
| 59 | 5030 Owner Withdrawals (contra-equity) |
| 60 | ``` |
| 61 | |
| 62 | --- |
| 63 | |
| 64 | ## Double-Entry Bookkeeping |
| 65 | |
| 66 | Every transaction records equal debits and credits. Debits increase asset and expense accounts; credits increase liability, income, and equity accounts. |
| 67 | |
| 68 | ### Entry Examples |
| 69 | |
| 70 | **Buy 1000 BONK for 0.5 SOL (0.001 SOL gas fee):** |
| 71 | |
| 72 | | Account | Debit | Credit | |
| 73 | |---------|-------|--------| |
| 74 | | Token Holdings – BONK | 0.501 SOL | | |
| 75 | | Cash – SOL | | 0.501 SOL | |
| 76 | |
| 77 | Or with the fee broken out explicitly: |
| 78 | |
| 79 | | Account | Debit | Credit | |
| 80 | |---------|-------|--------| |
| 81 | | Token Holdings – BONK | 0.5 SOL | | |
| 82 | | Gas & Priority Fees | 0.001 SOL | | |
| 83 | | Cash – SOL | | 0.501 SOL | |
| 84 | |
| 85 | **Sell 1000 BONK for 0.8 SOL (cost basis was 0.5 SOL, 0.001 SOL gas):** |
| 86 | |
| 87 | | Account | Debit | Credit | |
| 88 | |---------|-------|--------| |
| 89 | | Cash – SOL | 0.799 SOL | | |
| 90 | | Gas & Priority Fees | 0.001 SOL | | |
| 91 | | Token Holdings – BONK | | 0.5 SOL | |
| 92 | | Realized Trading Gains | | 0.3 SOL | |
| 93 | |
| 94 | **Receive staking rewards of 0.05 SOL:** |
| 95 | |
| 96 | | Account | Debit | Credit | |
| 97 | |---------|-------|--------| |
| 98 | | Cash – SOL | 0.05 SOL | | |
| 99 | | Staking Rewards | | 0.05 SOL | |
| 100 | |
| 101 | **Receive airdrop of 5000 JUP (valued at 2.1 SOL at receipt):** |
| 102 | |
| 103 | | Account | Debit | Credit | |
| 104 | |---------|-------|--------| |
| 105 | | Token Holdings – JUP | 2.1 SOL | | |
| 106 | | Airdrop Income | | 2.1 SOL | |
| 107 | |
| 108 | **Collect LP fees of 0.03 SOL:** |
| 109 | |
| 110 | | Account | Debit | Credit | |
| 111 | |---------|-------|--------| |
| 112 | | Cash – SOL | 0.03 SOL | | |
| 113 | | LP Fee Income | | 0.03 SOL | |
| 114 | |
| 115 | **Partial close — sell half a position:** |
| 116 | |
| 117 | If you hold 2000 BONK at cost basis 1.0 SOL and sell 1000 for 0.7 SOL: |
| 118 | |
| 119 | | Account | Debit | Credit | |
| 120 | |---------|-------|--------| |
| 121 | | Cash – SOL | 0.699 SOL | | |
| 122 | | Gas & Priority Fees | 0.001 SOL | | |
| 123 | | Token Holdings – BONK | | 0.5 SOL | |
| 124 | | Realized Trading Gains | | 0.2 SOL | |
| 125 | |
| 126 | The cost basis of the sold portion (0.5 SOL = half of 1.0 SOL) is removed from the asset account. |
| 127 | |
| 128 | --- |
| 129 | |
| 130 | ## Transaction Types |
| 131 | |
| 132 | The ledger handles these trading flows: |
| 133 | |
| 134 | | Flow | Accounts Touched | |
| 135 | |------|-----------------| |
| 136 | | Fund account | Cash (debit), Owner Capital (credit) | |
| 137 | | Withdraw funds | Owner Withdrawals (debit), Cash (credit) | |
| 138 | | Buy token | Token Holdings (debit), Cash (credit), Gas Expense (debit) | |
| 139 | | Sell token | Cash (debit), Token Holdings (credit), Realized Gains (credit or debit for loss), Gas Expense (debit) | |
| 140 | | Partial close | Same as sell, pro-rated cost basis | |
| 141 | | S |