[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E52JHPRS3T4MM93J9FG5RZ":3,"skill-same:01M7E52JHPRS3T4MM93J9FG5RZ":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M7E52JHPRS3T4MM93J9FG5RZ","trade-accounting",null,"Double-entry bookkeeping for trading operations with ledger management, P&L statements, balance sheets, and cash flow reporting","feliksness\u002FQuartzite-Prompt-Library","feliksness","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F306417198?v=4","01M7E3WAY8ZDW6ZJGX2DEBDTYR","FKH","01M7E3WAYR09SCHFP489W0TWRE",1,"MIT","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_crypto\u002Ftrade-accounting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: trade-accounting\ndescription: Double-entry bookkeeping for trading operations with ledger management, P&L statements, balance sheets, and cash flow reporting\nlicense: MIT\nmetadata:\n  author: agipro\n  version: \"0.1.0\"\n  category: trading\n---\n\n# Trade Accounting\n\nRun 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.\n\n**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.\n\n## Why Traders Need Accounting\n\nMost traders track P&L loosely — \"I started with 50 SOL and now I have 62 SOL.\" That tells you nothing about:\n\n- How much came from realized trades vs unrealized positions\n- What you paid in cumulative fees (gas, priority fees, swap fees)\n- Whether your staking and LP income covers your operating costs\n- Your actual cost basis for each holding (critical for taxes)\n- Cash flow timing — are you profitable but illiquid?\n\nProper 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).\n\n---\n\n## Account Types\n\nA trading operation uses four account categories following standard accounting:\n\n| Category | Normal Balance | Examples |\n|----------|---------------|----------|\n| **Assets** | Debit | Cash (SOL\u002FUSDC), token holdings, LP positions, staking deposits, receivables |\n| **Liabilities** | Credit | Margin borrowing, accrued taxes payable |\n| **Income** | Credit | Realized trading gains, staking rewards, airdrop income, LP fee income |\n| **Expenses** | Debit | Trading fees, gas\u002Fpriority fees, subscription costs, data feeds |\n| **Equity** | Credit | Owner capital contributions, retained earnings, withdrawals (contra) |\n\n### Chart of Accounts\n\nSee `references\u002Fplanned_features.md` for a full chart of accounts. A minimal setup:\n\n```\n1000  Assets\n  1010  Cash – SOL\n  1020  Cash – USDC\n  1100  Token Holdings (one sub-account per token)\n  1200  LP Positions\n  1300  Staking Deposits\n\n3000  Income\n  3010  Realized Trading Gains\n  3020  Staking Rewards\n  3030  Airdrop Income\n  3040  LP Fee Income\n\n4000  Expenses\n  4010  Trading Fees (DEX swap fees)\n  4020  Gas & Priority Fees\n  4030  Slippage Cost\n\n5000  Equity\n  5010  Owner Capital\n  5020  Retained Earnings\n  5030  Owner Withdrawals (contra-equity)\n```\n\n---\n\n## Double-Entry Bookkeeping\n\nEvery transaction records equal debits and credits. Debits increase asset and expense accounts; credits increase liability, income, and equity accounts.\n\n### Entry Examples\n\n**Buy 1000 BONK for 0.5 SOL (0.001 SOL gas fee):**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Token Holdings – BONK | 0.501 SOL | |\n| Cash – SOL | | 0.501 SOL |\n\nOr with the fee broken out explicitly:\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Token Holdings – BONK | 0.5 SOL | |\n| Gas & Priority Fees | 0.001 SOL | |\n| Cash – SOL | | 0.501 SOL |\n\n**Sell 1000 BONK for 0.8 SOL (cost basis was 0.5 SOL, 0.001 SOL gas):**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.799 SOL | |\n| Gas & Priority Fees | 0.001 SOL | |\n| Token Holdings – BONK | | 0.5 SOL |\n| Realized Trading Gains | | 0.3 SOL |\n\n**Receive staking rewards of 0.05 SOL:**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.05 SOL | |\n| Staking Rewards | | 0.05 SOL |\n\n**Receive airdrop of 5000 JUP (valued at 2.1 SOL at receipt):**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Token Holdings – JUP | 2.1 SOL | |\n| Airdrop Income | | 2.1 SOL |\n\n**Collect LP fees of 0.03 SOL:**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.03 SOL | |\n| LP Fee Income | | 0.03 SOL |\n\n**Partial close — sell half a position:**\n\nIf you hold 2000 BONK at cost basis 1.0 SOL and sell 1000 for 0.7 SOL:\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.699 SOL | |\n| Gas & Priority Fees | 0.001 SOL | |\n| Token Holdings – BONK | | 0.5 SOL |\n| Realized Trading Gains | | 0.2 SOL |\n\nThe cost basis of the sold portion (0.5 SOL = half of 1.0 SOL) is removed from the asset account.\n\n---\n\n## Transaction Types\n\nThe ledger handles these trading flows:\n\n| Flow | Accounts Touched |\n|------|-----------------|\n| Fund account | Cash (debit), Owner Capital (credit) |\n| Withdraw funds | Owner Withdrawals (debit), Cash (credit) |\n| Buy token | Token Holdings (debit), Cash (credit), Gas Expense (debit) |\n| Sell token | Cash (debit), Token Holdings (credit), Realized Gains (credit or debit for loss), Gas Expense (debit) |\n| Partial close | Same as sell, pro-rated cost basis |\n| Swap token for token | Token B (debit), Token A (credit), fees |\n| Staking deposit | Staking Deposits (debit), Cash (credit) |\n| Staking reward | Cash (debit), Staking Rewards (credit) |\n| Airdrop received | Token Holdings (debit), Airdrop Income (credit) |\n| LP fee collected | Cash (debit), LP Fee Income (credit) |\n| Trading fee | Trading Fees (debit), Cash (credit) |\n| Gas\u002Fpriority fee | Gas & Priority Fees (debit), Cash (credit) |\n\n---\n\n## Reports\n\n### Profit & Loss Statement\n\nShows income minus expenses for a period:\n\n```\n═══════════════════════════════════════════\n  P&L Statement: 2026-02-01 to 2026-02-28\n═══════════════════════════════════════════\nINCOME\n  Realized Trading Gains ........  4.200 SOL\n  Staking Rewards ...............  0.150 SOL\n  Airdrop Income ................  2.100 SOL\n  LP Fee Income .................  0.090 SOL\n                                  ─────────\n  Total Income                     6.540 SOL\n\nEXPENSES\n  Trading Fees ..................  0.120 SOL\n  Gas & Priority Fees ...........  0.045 SOL\n  Slippage Cost .................  0.030 SOL\n                                  ─────────\n  Total Expenses                   0.195 SOL\n\n═══════════════════════════════════════════\n  NET INCOME                       6.345 SOL\n═══════════════════════════════════════════\n```\n\n### Balance Sheet\n\nShows the accounting equation: Assets = Liabilities + Equity.\n\n```\n═══════════════════════════════════════════\n  Balance Sheet: 2026-02-28\n═══════════════════════════════════════════\nASSETS\n  Cash – SOL ....................  32.450 SOL\n  Cash – USDC ...................   0.000 SOL\n  Token Holdings ................  12.300 SOL\n  LP Positions ..................   5.000 SOL\n  Staking Deposits ..............  10.000 SOL\n                                  ─────────\n  Total Assets                    59.750 SOL\n\nEQUITY\n  Owner Capital .................  50.000 SOL\n  Retained Earnings .............   3.405 SOL\n  Net Income (current period) ...   6.345 SOL\n                                  ─────────\n  Total Equity                    59.750 SOL\n\n═══════════════════════════════════════════\n  Assets - Equity = 0.000 SOL  ✓ Balanced\n═══════════════════════════════════════════\n```\n\n### Cash Flow Statement\n\nTracks where cash came from and where it went:\n\n```\n═══════════════════════════════════════════\n  Cash Flow: 2026-02-01 to 2026-02-28\n═══════════════════════════════════════════\nOPERATING ACTIVITIES\n  Trading proceeds ..............  8.500 SOL\n  Token purchases ...............  (4.300) SOL\n  Fees paid .....................  (0.195) SOL\n  Staking rewards received ......  0.150 SOL\n  LP fees received ..............  0.090 SOL\n                                  ─────────\n  Net Operating Cash Flow        4.245 SOL\n\nINVESTING ACTIVITIES\n  LP deposits ...................  (5.000) SOL\n  Staking deposits ..............  (2.000) SOL\n                                  ─────────\n  Net Investing Cash Flow       (7.000) SOL\n\nFINANCING ACTIVITIES\n  Capital contributions .........  10.000 SOL\n  Withdrawals ...................  (1.000) SOL\n                                  ─────────\n  Net Financing Cash Flow        9.000 SOL\n\n═══════════════════════════════════════════\n  Net Change in Cash              6.245 SOL\n  Beginning Cash Balance         26.205 SOL\n  Ending Cash Balance            32.450 SOL\n═══════════════════════════════════════════\n```\n\n---\n\n## Trading P&L vs Tax P&L\n\nThese are different numbers and serve different purposes:\n\n| Aspect | Trading P&L | Tax P&L |\n|--------|------------|---------|\n| **Purpose** | Strategy evaluation | Compliance, filing |\n| **Unrealized gains** | Included (mark-to-market) | Excluded (until realized) |\n| **Cost basis method** | Average cost (simple) | FIFO, LIFO, or specific ID (jurisdiction-dependent) |\n| **Timing** | Real-time | At disposal event |\n| **Airdrops** | Valued at receipt | Ordinary income at FMV on receipt |\n| **LP IL** | Tracked as unrealized loss | Not a taxable event until withdrawal |\n\nThe ledger in `scripts\u002Ftrading_ledger.py` tracks realized gains using FIFO by default. For trading P&L, you can overlay mark-to-market valuations on open positions.\n\nSee `references\u002Fplanned_features.md` for detailed worked examples of how the same trades produce different P&L under FIFO vs average cost.\n\n---\n\n## Entity Considerations\n\nTraders operating through an LLC or S-Corp should track additional accounts:\n\n- **Management fees** — if the entity charges a management fee\n- **Distributions** — payments from entity to owner (not the same as withdrawals from a trading account)\n- **Payroll expenses** — S-Corp officer salary\n- **Tax provisions** — estimated quarterly tax payments\n\nThe accounting principles are identical; the chart of accounts simply expands. The scripts in this skill focus on the trading-level ledger, which is the foundation for entity-level reporting.\n\n---\n\n## Quick Start\n\n```python\nfrom trading_ledger import Ledger, Amount\n\nledger = Ledger(base_currency=\"SOL\")\n\n# Fund the account\nledger.record_funding(amount=50.0, memo=\"Initial capital\")\n\n# Buy a token\nledger.record_buy(\n    token=\"BONK\",\n    quantity=100_000,\n    cost_sol=0.5,\n    fee_sol=0.001,\n    memo=\"Entry on volume spike\"\n)\n\n# Sell for profit\nledger.record_sell(\n    token=\"BONK\",\n    quantity=100_000,\n    proceeds_sol=0.8,\n    fee_sol=0.001,\n    memo=\"Target hit\"\n)\n\n# Record staking reward\nledger.record_income(\n    income_type=\"staking\",\n    amount_sol=0.05,\n    memo=\"Epoch 580 rewards\"\n)\n\n# Generate reports\nledger.print_pnl(start=\"2026-02-01\", end=\"2026-02-28\")\nledger.print_balance_sheet(as_of=\"2026-02-28\")\n```\n\nRun the demo script to see a full month of trading activity with all report types:\n\n```bash\npython scripts\u002Ftrading_ledger.py --demo\n```\n\n---\n\n## Use Cases\n\n1. **Track real P&L** — Know exactly how much you made after all fees, not just entry\u002Fexit prices\n2. **Tax preparation** — Hand your accountant a clean ledger with cost basis and realized gains\n3. **Fee analysis** — Discover that gas and priority fees are eating 3% of your gross profits\n4. **Strategy comparison** — Compare net P&L across strategies, not just win rates\n5. **Cash flow planning** — Know if you have enough liquid SOL for the next trade\n6. **Audit trail** — Every number traces back to a dated, memo-tagged journal entry\n\n---\n\n## Prerequisites\n\n- Python 3.10+\n- No external dependencies (the ledger uses only the standard library)\n\n---\n\n## Files\n\n| File | Description |\n|------|-------------|\n| `references\u002Fplanned_features.md` | Chart of accounts, double-entry examples, report formats, trading vs tax P&L |\n| `scripts\u002Ftrading_ledger.py` | Double-entry ledger with P&L, balance sheet, and demo mode |\n\n---\n\n> **Disclaimer**: This skill provides accounting structure and calculations for informational and organizational purposes only. It is not tax advice, legal advice, or financial advice. Consult a qualified tax professional or CPA for guidance on your specific tax obligations. Cryptocurrency tax treatment varies by jurisdiction and changes frequently.\n","# Trade Accounting\n\nRun 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.\n\n**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.\n\n## Why Traders Need Accounting\n\nMost traders track P&L loosely — \"I started with 50 SOL and now I have 62 SOL.\" That tells you nothing about:\n\n- How much came from realized trades vs unrealized positions\n- What you paid in cumulative fees (gas, priority fees, swap fees)\n- Whether your staking and LP income covers your operating costs\n- Your actual cost basis for each holding (critical for taxes)\n- Cash flow timing — are you profitable but illiquid?\n\nProper 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).\n\n---\n\n## Account Types\n\nA trading operation uses four account categories following standard accounting:\n\n| Category | Normal Balance | Examples |\n|----------|---------------|----------|\n| **Assets** | Debit | Cash (SOL\u002FUSDC), token holdings, LP positions, staking deposits, receivables |\n| **Liabilities** | Credit | Margin borrowing, accrued taxes payable |\n| **Income** | Credit | Realized trading gains, staking rewards, airdrop income, LP fee income |\n| **Expenses** | Debit | Trading fees, gas\u002Fpriority fees, subscription costs, data feeds |\n| **Equity** | Credit | Owner capital contributions, retained earnings, withdrawals (contra) |\n\n### Chart of Accounts\n\nSee `references\u002Fplanned_features.md` for a full chart of accounts. A minimal setup:\n\n```\n1000  Assets\n  1010  Cash – SOL\n  1020  Cash – USDC\n  1100  Token Holdings (one sub-account per token)\n  1200  LP Positions\n  1300  Staking Deposits\n\n3000  Income\n  3010  Realized Trading Gains\n  3020  Staking Rewards\n  3030  Airdrop Income\n  3040  LP Fee Income\n\n4000  Expenses\n  4010  Trading Fees (DEX swap fees)\n  4020  Gas & Priority Fees\n  4030  Slippage Cost\n\n5000  Equity\n  5010  Owner Capital\n  5020  Retained Earnings\n  5030  Owner Withdrawals (contra-equity)\n```\n\n---\n\n## Double-Entry Bookkeeping\n\nEvery transaction records equal debits and credits. Debits increase asset and expense accounts; credits increase liability, income, and equity accounts.\n\n### Entry Examples\n\n**Buy 1000 BONK for 0.5 SOL (0.001 SOL gas fee):**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Token Holdings – BONK | 0.501 SOL | |\n| Cash – SOL | | 0.501 SOL |\n\nOr with the fee broken out explicitly:\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Token Holdings – BONK | 0.5 SOL | |\n| Gas & Priority Fees | 0.001 SOL | |\n| Cash – SOL | | 0.501 SOL |\n\n**Sell 1000 BONK for 0.8 SOL (cost basis was 0.5 SOL, 0.001 SOL gas):**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.799 SOL | |\n| Gas & Priority Fees | 0.001 SOL | |\n| Token Holdings – BONK | | 0.5 SOL |\n| Realized Trading Gains | | 0.3 SOL |\n\n**Receive staking rewards of 0.05 SOL:**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.05 SOL | |\n| Staking Rewards | | 0.05 SOL |\n\n**Receive airdrop of 5000 JUP (valued at 2.1 SOL at receipt):**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Token Holdings – JUP | 2.1 SOL | |\n| Airdrop Income | | 2.1 SOL |\n\n**Collect LP fees of 0.03 SOL:**\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.03 SOL | |\n| LP Fee Income | | 0.03 SOL |\n\n**Partial close — sell half a position:**\n\nIf you hold 2000 BONK at cost basis 1.0 SOL and sell 1000 for 0.7 SOL:\n\n| Account | Debit | Credit |\n|---------|-------|--------|\n| Cash – SOL | 0.699 SOL | |\n| Gas & Priority Fees | 0.001 SOL | |\n| Token Holdings – BONK | | 0.5 SOL |\n| Realized Trading Gains | | 0.2 SOL |\n\nThe cost basis of the sold portion (0.5 SOL = half of 1.0 SOL) is removed from the asset account.\n\n---\n\n## Transaction Types\n\nThe ledger handles these trading flows:\n\n| Flow | Accounts Touched |\n|------|-----------------|\n| Fund account | Cash (debit), Owner Capital (credit) |\n| Withdraw funds | Owner Withdrawals (debit), Cash (credit) |\n| Buy token | Token Holdings (debit), Cash (credit), Gas Expense (debit) |\n| Sell token | Cash (debit), Token Holdings (credit), Realized Gains (credit or debit for loss), Gas Expense (debit) |\n| Partial close | Same as sell, pro-rated cost basis |\n| Swap token for token | Token B (debit), Token A (credit), fees |\n| Staking deposit | Staking Deposits (debit), Cash (credit) |\n| Staking reward | Cash (debit), Staking Rewards (credit) |\n| Airdrop received | Token Holdings (debit), Airdrop Income (credit) |\n| LP fee collected | Cash (debit), LP Fee Income (credit) |\n| Trading fee | Trading Fees (debit), Cash (credit) |\n| Gas\u002Fpriority fee | Gas & Priority Fees (debit), Cash (credit) |\n\n---\n\n## Reports\n\n### Profit & Loss Statement\n\nShows income minus expenses for a period:\n\n```\n═══════════════════════════════════════════\n  P&L Statement: 2026-02-01 to 2026-02-28\n═══════════════════════════════════════════\nINCOME\n  Realized Trading Gains ........  4.200 SOL\n  Staking Rewards ...............  0.150 SOL\n  Airdrop Income ................  2.100 SOL\n  LP Fee Income .................  0.090 SOL\n                                  ─────────\n  Total Income                     6.540 SOL\n\nEXPENSES\n  Trading Fees ..................  0.120 SOL\n  Gas & Priority Fees ...........  0.045 SOL\n  Slippage Cost .................  0.030 SOL\n                                  ─────────\n  Total Expenses                   0.195 SOL\n\n═══════════════════════════════════════════\n  NET INCOME                       6.345 SOL\n═══════════════════════════════════════════\n```\n\n### Balance Sheet\n\nShows the accounting equation: Assets = Liabilities + Equity.\n\n```\n═══════════════════════════════════════════\n  Balance Sheet: 2026-02-28\n═══════════════════════════════════════════\nASSETS\n  Cash – SOL ....................  32.450 SOL\n  Cash – USDC ...................   0.000 SOL\n  Token Holdings ................  12.300 SOL\n  LP Positions ..................   5.000 SOL\n  Staking Deposits ..............  10.000 SOL\n                                  ─────────\n  Total Assets                    59.750 SOL\n\nEQUITY\n  Owner Capital .................  50.000 SOL\n  Retained Earnings .............   3.405 SOL\n  Net Income (current period) ...   6.345 SOL\n                                  ─────────\n  Total Equity                    59.750 SOL\n\n═══════════════════════════════════════════\n  Assets - Equity = 0.000 SOL  ✓ Balanced\n═══════════════════════════════════════════\n```\n\n### Cash Flow Statement\n\nTracks where cash came from and where it went:\n\n```\n═══════════════════════════════════════════\n  Cash Flow: 2026-02-01 to 2026-02-28\n═══════════════════════════════════════════\nOPERATING ACTIVITIES\n  Trading proceeds ..............  8.500 SOL\n  Token purchases ...............  (4.300) SOL\n  Fees paid .....................  (0.195) SOL\n  Staking rewards received ......  0.150 SOL\n  LP fees received ..............  0.090 SOL\n                                  ─────────\n  Net Operating Cash Flow        4.245 SOL\n\nINVESTING ACTIVITIES\n  LP deposits ...................  (5.000) SOL\n  Staking deposits ..............  (2.000) SOL\n                                  ─────────\n  Net Investing Cash Flow       (7.000) SOL\n\nFINANCING ACTIVITIES\n  Capital contributions .........  10.000 SOL\n  Withdrawals ...................  (1.000) SOL\n                                  ─────────\n  Net Financing Cash Flow        9.000 SOL\n\n═══════════════════════════════════════════\n  Net Change in Cash              6.245 SOL\n  Beginning Cash Balance         26.205 SOL\n  Ending Cash Balance            32.450 SOL\n═══════════════════════════════════════════\n```\n\n---\n\n## Trading P&L vs Tax P&L\n\nThese are different numbers and serve different purposes:\n\n| Aspect | Trading P&L | Tax P&L |\n|--------|------------|---------|\n| **Purpose** | Strategy evaluation | Compliance, filing |\n| **Unrealized gains** | Included (mark-to-market) | Excluded (until realized) |\n| **Cost basis method** | Average cost (simple) | FIFO, LIFO, or specific ID (jurisdiction-dependent) |\n| **Timing** | Real-time | At disposal event |\n| **Airdrops** | Valued at receipt | Ordinary income at FMV on receipt |\n| **LP IL** | Tracked as unrealized loss | Not a taxable event until withdrawal |\n\nThe ledger in `scripts\u002Ftrading_ledger.py` tracks realized gains using FIFO by default. For trading P&L, you can overlay mark-to-market valuations on open positions.\n\nSee `references\u002Fplanned_features.md` for detailed worked examples of how the same trades produce different P&L under FIFO vs average cost.\n\n---\n\n## Entity Considerations\n\nTraders operating through an LLC or S-Corp should track additional accounts:\n\n- **Management fees** — if the entity charges a management fee\n- **Distributions** — payments from entity to owner (not the same as withdrawals from a trading account)\n- **Payroll expenses** — S-Corp officer salary\n- **Tax provisions** — estimated quarterly tax payments\n\nThe accounting principles are identical; the chart of accounts simply expands. The scripts in this skill focus on the trading-level ledger, which is the foundation for entity-level reporting.\n\n---\n\n## Quick Start\n\n```python\nfrom trading_ledger import Ledger, Amount\n\nledger = Ledger(base_currency=\"SOL\")\n\n# Fund the account\nledger.record_funding(amount=50.0, memo=\"Initial capital\")\n\n# Buy a token\nledger.record_buy(\n    token=\"BONK\",\n    quantity=100_000,\n    cost_sol=0.5,\n    fee_sol=0.001,\n    memo=\"Entry on volume spike\"\n)\n\n# Sell for profit\nledger.record_sell(\n    token=\"BONK\",\n    quantity=100_000,\n    proceeds_sol=0.8,\n    fee_sol=0.001,\n    memo=\"Target hit\"\n)\n\n# Record staking reward\nledger.record_income(\n    income_type=\"staking\",\n    amount_sol=0.05,\n    memo=\"Epoch 580 rewards\"\n)\n\n# Generate reports\nledger.print_pnl(start=\"2026-02-01\", end=\"2026-02-28\")\nledger.print_balance_sheet(as_of=\"2026-02-28\")\n```\n\nRun the demo script to see a full month of trading activity with all report types:\n\n```bash\npython scripts\u002Ftrading_ledger.py --demo\n```\n\n---\n\n## Use Cases\n\n1. **Track real P&L** — Know exactly how much you made after all fees, not just entry\u002Fexit prices\n2. **Tax preparation** — Hand your accountant a clean ledger with cost basis and realized gains\n3. **Fee analysis** — Discover that gas and priority fees are eating 3% of your gross profits\n4. **Strategy comparison** — Compare net P&L across strategies, not just win rates\n5. **Cash flow planning** — Know if you have enough liquid SOL for the next trade\n6. **Audit trail** — Every number traces back to a dated, memo-tagged journal entry\n\n---\n\n## Prerequisites\n\n- Python 3.10+\n- No external dependencies (the ledger uses only the standard library)\n\n---\n\n## Files\n\n| File | Description |\n|------|-------------|\n| `references\u002Fplanned_features.md` | Chart of accounts, double-entry examples, report formats, trading vs tax P&L |\n| `scripts\u002Ftrading_ledger.py` | Double-entry ledger with P&L, balance sheet, and demo mode |\n\n---\n\n> **Disclaimer**: This skill provides accounting structure and calculations for informational and organizational purposes only. It is not tax advice, legal advice, or financial advice. Consult a qualified tax professional or CPA for guidance on your specific tax obligations. Cryptocurrency tax treatment varies by jurisdiction and changes frequently.\n",{"name":5,"license":15,"metadata":24,"description":7},{"author":25,"version":26,"category":27},"agipro","0.1.0","trading","main","e2c0b5e0b02b3d8ee33c348da5392e885c98757b","skills\u002F04_crypto\u002Ftrade-accounting",0,"https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library","https:\u002F\u002Fgithub.com\u002Ffeliksness","Economics • AI & Computer Vision • FinTech • Software Development • Entrepreneurship | Building ideas into real projects.","2026-10-04 03:14:33",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add feliksness\u002FQuartzite-Prompt-Library --skill trade-accounting",{"tool":42,"command":43},"bunx","bunx skills add feliksness\u002FQuartzite-Prompt-Library --skill trade-accounting",{"tool":45,"command":46},"pnpm","pnpm dlx skills add feliksness\u002FQuartzite-Prompt-Library --skill trade-accounting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_crypto\u002Ftrade-accounting\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Fplanned_features.md","REFERENCE","参考文档",7852,"https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_crypto\u002Ftrade-accounting\u002Freferences\u002Fplanned_features.md",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"scripts\u002Ftrading_ledger.py","SCRIPT","脚本",30693,"https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_crypto\u002Ftrade-accounting\u002Fscripts\u002Ftrading_ledger.py",[63,71,80,88,95,102],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7E55RYQF73KMB8KPSCAKEG1","claude-design","Produce thoughtful, high-fidelity design artifacts in HTML — landing pages, slide decks, interactive prototypes, animated videos, posters, wireframes, and visual explorations. Use whenever the user asks to design, mock up, prototype, visualize, storyboard, or explore UI options — including phrases like \"make a deck\", \"design a landing page\", \"prototype this flow\", \"animate this concept\", \"build a pitch deck\", \"create a poster\", \"visualize this idea\", or \"design something for a brand\". Enforces fact verification (WebSearch before assuming a product exists or its version), the Core Asset Protocol for branded work (logo, product shots, and UI screenshots are first-class, not just colors and fonts), a Design Direction Advisor fallback that offers 3 differentiated directions from 10 design philosophies when the brief is too vague, commits to a visual system up front, presents multiple variations, and avoids AI-design tropes (aggressive gradients, emoji bullets, generic templates).","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F05_design_workflow_specialists\u002Fhtml-artifact-designer\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F05_design_workflow_specialists\u002Fhtml-artifact-designer\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":76,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7E55GTYM1CGKM6Z78DNW9RX","color-expert","Use when working with color naming, color theory, color spaces, color definitions, or any task involving color knowledge - palettes, ramps, gradients, conversions, accessibility, perceptual matching, pigment mixing, print-vs-screen color, CSS color syntax, or historical color terminology. Use this skill whenever the user is choosing, comparing, generating, naming, converting, or explaining colors, even if they do not explicitly ask for \"color theory.\"","CC-BY-4.0","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F05_design_workflow_specialists\u002Fcolor-science-expert\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F05_design_workflow_specialists\u002Fcolor-science-expert\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":84,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7E553X7CWSFW56GE6ASZ4JF","ai-graphic-design","Guide for creating logos, brand identities, and visual assets using AI tools — covers tool selection, prompt engineering, vectorization pipelines, mockups, automation, and IP safety.","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F05_design_workflow_specialists\u002Fai-graphic-design-branding\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F05_design_workflow_specialists\u002Fai-graphic-design-branding\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7E54VW1C902WRM4XJD356J7","vintage","1950s-1990s nostalgia with skeuomorphic touches, grainy textures, retro color palettes, and pixel-style typography.","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_design_style_library\u002Fvintage\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7E54NR98M22FAQ8NXJVRVED","skeumorphism","Real-world mimicry with textured surfaces, 3D effects, and familiar physical metaphors for intuitive digital interfaces.","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_design_style_library\u002Fskeumorphism\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":19},"01M7E54GC2VDE21R2J8RA1X92X","retro","Throwback design with vintage-inspired typography, high-contrast retro palettes, and nostalgic visual elements.","https:\u002F\u002Fgithub.com\u002Ffeliksness\u002FQuartzite-Prompt-Library\u002Fblob\u002Fmain\u002Fskills\u002F04_design_style_library\u002Fretro\u002FSKILL.md",[],[]]