Beancount.io LogoBeancount.io

Cryptocurrency Portfolio Tracking

Complete guide to setting up and managing cryptocurrency portfolios in Beancount.io, including multi-exchange tracking, cost basis calculations, and performance analysis.

Cryptocurrency Portfolio Tracking with Beancount.io

Managing a cryptocurrency portfolio across multiple exchanges, wallets, and DeFi protocols can be challenging. This comprehensive guide shows you how to set up and maintain accurate cryptocurrency portfolio tracking using Beancount.io's powerful plain-text accounting system.

Explore a live cryptocurrency example ledger:

Why Traditional Portfolio Trackers Fall Short

Common Problems with Crypto Portfolio Tools

  • Limited Exchange Support: Many tools don't support all exchanges or DeFi protocols
  • Inaccurate Cost Basis: Simplified FIFO/LIFO calculations miss complex scenarios
  • Missing Transactions: API limitations and manual entry gaps
  • No Customization: Fixed categories and reporting structures
  • Privacy Concerns: Sharing API keys with third-party services
  • Vendor Lock-in: Proprietary data formats and limited export options

Beancount.io Advantages

  • Complete Control: Own your data in plain-text format
  • Unlimited Customization: Create any account structure you need
  • Precise Cost Basis: Lot-based tracking with specific identification
  • Multi-Protocol Support: Handle any exchange, wallet, or DeFi protocol
  • Transparent Calculations: See exactly how numbers are computed
  • Future-Proof: Plain-text format ensures long-term accessibility

Setting Up Your Crypto Portfolio Structure

Basic Account Hierarchy

Start with a comprehensive account structure that reflects your crypto ecosystem:

; Exchange Accounts - Organized by Platform
1970-01-01 open Assets:Crypto:Coinbase:USD
1970-01-01 open Assets:Crypto:Coinbase:BTC
1970-01-01 open Assets:Crypto:Coinbase:ETH
1970-01-01 open Assets:Crypto:Coinbase:ADA
 
1970-01-01 open Assets:Crypto:Binance:USD
1970-01-01 open Assets:Crypto:Binance:BTC
1970-01-01 open Assets:Crypto:Binance:ETH
1970-01-01 open Assets:Crypto:Binance:BNB
 
1970-01-01 open Assets:Crypto:Kraken:USD
1970-01-01 open Assets:Crypto:Kraken:BTC
1970-01-01 open Assets:Crypto:Kraken:ETH
 
; Wallet Accounts - Organized by Type
1970-01-01 open Assets:Crypto:Wallet:Ledger:BTC
1970-01-01 open Assets:Crypto:Wallet:Ledger:ETH
1970-01-01 open Assets:Crypto:Wallet:MetaMask:ETH
1970-01-01 open Assets:Crypto:Wallet:MetaMask:USDC
1970-01-01 open Assets:Crypto:Wallet:TrustWallet:BNB
 
; DeFi Protocol Accounts
1970-01-01 open Assets:DeFi:Uniswap:ETH-USDC-LP
1970-01-01 open Assets:DeFi:Compound:cUSDC
1970-01-01 open Assets:Staking:Ethereum:ETH
1970-01-01 open Assets:Staking:Cardano:ADA
 
; Income Tracking
1970-01-01 open Income:Crypto:Staking:ETH
1970-01-01 open Income:Crypto:Staking:ADA
1970-01-01 open Income:Crypto:Mining:BTC
1970-01-01 open Income:Crypto:Airdrops
1970-01-01 open Income:Crypto:DeFi:Yield
1970-01-01 open Income:CapitalGains:Crypto
 
; Expense Tracking
1970-01-01 open Expenses:Crypto:Fees:Trading
1970-01-01 open Expenses:Crypto:Fees:Network
1970-01-01 open Expenses:Crypto:Fees:Withdrawal

Commodity Definitions with Metadata

Define your cryptocurrencies with rich metadata for better tracking:

1970-01-01 commodity BTC
  name: "Bitcoin"
  asset-class: "cryptocurrency"
  sector: "digital-currency"
  price-source: "coinbase"
  website: "https://bitcoin.org"
 
1970-01-01 commodity ETH
  name: "Ethereum"
  asset-class: "cryptocurrency"
  sector: "smart-contract-platform"
  price-source: "coinbase"
  website: "https://ethereum.org"
 
1970-01-01 commodity ADA
  name: "Cardano"
  asset-class: "cryptocurrency"
  sector: "smart-contract-platform"
  price-source: "binance"
  website: "https://cardano.org"
 
1970-01-01 commodity DOT
  name: "Polkadot"
  asset-class: "cryptocurrency"
  sector: "interoperability"
  price-source: "kraken"
  website: "https://polkadot.network"

Multi-Exchange Portfolio Tracking

Recording Purchases Across Exchanges

Track the same cryptocurrency across different exchanges with precise cost basis:

; Bitcoin purchases on different exchanges
2024-01-15 * "Buy BTC on Coinbase"
  Assets:Crypto:Coinbase:BTC      1.0 BTC {45000.00 USD}
  Assets:Crypto:Coinbase:USD  -45000.00 USD
  Expenses:Crypto:Fees:Trading    50.00 USD
  Assets:Crypto:Coinbase:USD     -50.00 USD
 
2024-01-20 * "Buy BTC on Binance"
  Assets:Crypto:Binance:BTC       0.5 BTC {46000.00 USD}
  Assets:Crypto:Binance:USD   -23000.00 USD
  Expenses:Crypto:Fees:Trading    25.00 USD
  Assets:Crypto:Binance:USD      -25.00 USD
 
2024-01-25 * "Buy BTC on Kraken"
  Assets:Crypto:Kraken:BTC        0.8 BTC {44000.00 USD}
  Assets:Crypto:Kraken:USD    -35200.00 USD
  Expenses:Crypto:Fees:Trading    30.00 USD
  Assets:Crypto:Kraken:USD       -30.00 USD

Cross-Exchange Transfers

Track transfers between exchanges while maintaining cost basis:

2024-02-01 * "Transfer BTC from Coinbase to Ledger"
  Assets:Crypto:Coinbase:BTC      -0.5 BTC {45000.00 USD}
  Assets:Crypto:Wallet:Ledger:BTC  0.5 BTC {45000.00 USD}
  Expenses:Crypto:Fees:Withdrawal  0.0005 BTC {45000.00 USD}
  Assets:Crypto:Coinbase:BTC      -0.0005 BTC {45000.00 USD}

Arbitrage Opportunities

Track arbitrage trades between exchanges:

2024-02-10 * "Arbitrage: Buy ETH on Binance, Sell on Coinbase"
  ; Buy on Binance
  Assets:Crypto:Binance:ETH       10 ETH {2500.00 USD}
  Assets:Crypto:Binance:USD   -25000.00 USD
  Expenses:Crypto:Fees:Trading    25.00 USD
  Assets:Crypto:Binance:USD      -25.00 USD
 
  ; Sell on Coinbase (higher price)
  Assets:Crypto:Coinbase:ETH     -10 ETH {2500.00 USD}
  Assets:Crypto:Coinbase:USD   25800.00 USD
  Expenses:Crypto:Fees:Trading    30.00 USD
  Assets:Crypto:Coinbase:USD     -30.00 USD
  Income:Crypto:Arbitrage       745.00 USD

Advanced Cost Basis Management

Lot-Based Tracking

Beancount.io's lot-based system provides precise cost basis tracking:

; Multiple purchases at different prices
2024-01-01 * "BTC Purchase Lot 1"
  Assets:Crypto:Coinbase:BTC  1.0 BTC {40000.00 USD}
  Assets:Crypto:Coinbase:USD -40000.00 USD
 
2024-02-01 * "BTC Purchase Lot 2"
  Assets:Crypto:Coinbase:BTC  1.0 BTC {45000.00 USD}
  Assets:Crypto:Coinbase:USD -45000.00 USD
 
2024-03-01 * "BTC Purchase Lot 3"
  Assets:Crypto:Coinbase:BTC  1.0 BTC {50000.00 USD}
  Assets:Crypto:Coinbase:USD -50000.00 USD

Specific Identification Method

Sell specific lots for optimal tax management:

; Sell highest cost basis lot first (tax loss harvesting)
2024-04-01 * "Sell BTC Lot 3 for tax optimization"
  Assets:Crypto:Coinbase:BTC    -1.0 BTC {50000.00 USD}
  Assets:Crypto:Coinbase:USD   48000.00 USD
  Expenses:Crypto:Fees:Trading    50.00 USD
  Assets:Crypto:Coinbase:USD     -50.00 USD
  Expenses:CapitalLoss:Crypto   2000.00 USD  ; Realized loss

FIFO vs LIFO Tracking

Implement different cost basis methods:

; FIFO Sale (First In, First Out)
2024-05-01 * "FIFO Sale - Sell oldest BTC first"
  Assets:Crypto:Coinbase:BTC    -0.5 BTC {40000.00 USD}
  Assets:Crypto:Coinbase:USD   26000.00 USD
  Expenses:Crypto:Fees:Trading    30.00 USD
  Assets:Crypto:Coinbase:USD     -30.00 USD
  Income:CapitalGains:Crypto    6000.00 USD  ; 52000 - 20000 = 6000
 
; LIFO Sale (Last In, First Out) - if using different method
2024-05-01 * "LIFO Sale - Sell newest BTC first"
  Assets:Crypto:Coinbase:BTC    -0.5 BTC {45000.00 USD}
  Assets:Crypto:Coinbase:USD   26000.00 USD
  Expenses:Crypto:Fees:Trading    30.00 USD
  Assets:Crypto:Coinbase:USD     -30.00 USD
  Income:CapitalGains:Crypto    3500.00 USD  ; 26000 - 22500 = 3500

Portfolio Performance Analysis

Price Tracking Setup

Set up automated price feeds for accurate valuation:

; Daily price updates
2024-01-15 price BTC 45000.00 USD
2024-01-15 price ETH 2500.00 USD
2024-01-15 price ADA 0.50 USD
 
2024-01-16 price BTC 46000.00 USD
2024-01-16 price ETH 2550.00 USD
2024-01-16 price ADA 0.52 USD

Portfolio Allocation Tracking

Use Beancount.io's reporting features to analyze allocation:

; Query for portfolio allocation by asset
SELECT
  account,
  sum(position) as balance,
  value(sum(position)) as market_value
WHERE account ~ "Assets:Crypto"
GROUP BY 1
ORDER BY market_value DESC

Performance Metrics

Track key performance indicators:

; Total portfolio value query
SELECT
  sum(value(position)) as total_portfolio_value
WHERE account ~ "Assets:Crypto"
 
; Realized gains/losses
SELECT
  sum(position) as realized_gains
WHERE account ~ "Income:CapitalGains:Crypto"

Staking and DeFi Integration

Staking Rewards Tracking

Record staking rewards with proper income recognition:

2024-01-31 * "ETH Staking Rewards - January"
  Assets:Staking:Ethereum:ETH     0.08 ETH {2500.00 USD}
  Income:Crypto:Staking:ETH     200.00 USD
 
2024-01-31 * "ADA Staking Rewards - January"
  Assets:Staking:Cardano:ADA      25 ADA {0.50 USD}
  Income:Crypto:Staking:ADA      12.50 USD

DeFi Yield Tracking

Track complex DeFi positions:

2024-02-01 * "Uniswap LP Position"
  Assets:Crypto:Wallet:MetaMask:ETH    -10 ETH {2500.00 USD}
  Assets:Crypto:Wallet:MetaMask:USDC -25000 USDC
  Assets:DeFi:Uniswap:ETH-USDC-LP      100 UNI-V2-ETH-USDC {500.00 USD}
 
2024-02-28 * "Uniswap LP Rewards - February"
  Assets:Crypto:Wallet:MetaMask:UNI    50 UNI {8.00 USD}
  Income:Crypto:DeFi:Yield           400.00 USD

Automated Portfolio Management

API Integration Setup

Connect with exchange APIs for automated data import:

# Example configuration for exchange API integration
exchanges:
  coinbase:
    api_key: "your_api_key"
    api_secret: "your_api_secret"
    passphrase: "your_passphrase"
  binance:
    api_key: "your_api_key"
    api_secret: "your_api_secret"

Automated Reconciliation

Set up automated balance verification:

; Balance assertions for automated verification
2024-01-31 balance Assets:Crypto:Coinbase:BTC    2.5 BTC
2024-01-31 balance Assets:Crypto:Binance:ETH    15.0 ETH
2024-01-31 balance Assets:Crypto:Kraken:ADA   1000.0 ADA

Price Feed Automation

Configure automated price updates:

; Price feed configuration
plugin "beancount.plugins.auto_accounts"
plugin "beancount.plugins.forecast"
 
; Automated price fetching
2024-01-01 custom "price-source" BTC "coinbase"
2024-01-01 custom "price-source" ETH "coinbase"
2024-01-01 custom "price-source" ADA "binance"

Tax Optimization Strategies

Tax Loss Harvesting

Implement systematic tax loss harvesting:

; Identify positions with unrealized losses
2024-12-15 * "Tax loss harvesting - Sell ADA at loss"
  Assets:Crypto:Binance:ADA      -1000 ADA {0.60 USD}
  Assets:Crypto:Binance:USD       450.00 USD
  Expenses:Crypto:Fees:Trading      5.00 USD
  Assets:Crypto:Binance:USD        -5.00 USD
  Expenses:CapitalLoss:Crypto     150.00 USD  ; Realized loss
 
; Repurchase after wash sale period (31 days)
2025-01-16 * "Repurchase ADA after wash sale period"
  Assets:Crypto:Binance:ADA      1000 ADA {0.45 USD}
  Assets:Crypto:Binance:USD     -450.00 USD
  Expenses:Crypto:Fees:Trading     5.00 USD
  Assets:Crypto:Binance:USD       -5.00 USD

Long-term vs Short-term Gains

Track holding periods for tax optimization:

; Use metadata to track purchase dates
2024-01-01 * "BTC Purchase - Long-term hold" ^long-term-btc
  Assets:Crypto:Coinbase:BTC  1.0 BTC {40000.00 USD}
  Assets:Crypto:Coinbase:USD -40000.00 USD
 
; Sell after one year for long-term capital gains treatment
2025-01-02 * "BTC Sale - Long-term capital gains" ^long-term-btc
  Assets:Crypto:Coinbase:BTC    -1.0 BTC {40000.00 USD}
  Assets:Crypto:Coinbase:USD   55000.00 USD
  Income:CapitalGains:LongTerm 15000.00 USD

Reporting and Analytics

Portfolio Summary Reports

Generate comprehensive portfolio reports:

-- Portfolio allocation by cryptocurrency
SELECT
  commodity,
  sum(position) as total_units,
  value(sum(position)) as market_value,
  value(sum(position)) / (
    SELECT value(sum(position))
    FROM positions
    WHERE account ~ "Assets:Crypto"
  ) * 100 as allocation_percentage
WHERE account ~ "Assets:Crypto"
GROUP BY commodity
ORDER BY market_value DESC;

Performance Analytics

Track portfolio performance over time:

-- Monthly portfolio performance
SELECT
  year(date) as year,
  month(date) as month,
  value(sum(position)) as portfolio_value
WHERE account ~ "Assets:Crypto"
GROUP BY year, month
ORDER BY year, month;

Income Analysis

Analyze income sources:

-- Income breakdown by source
SELECT
  account,
  sum(position) as total_income
WHERE account ~ "Income:Crypto"
GROUP BY account
ORDER BY total_income DESC;

Best Practices and Tips

1. Consistent Recording

  • Record transactions immediately after execution
  • Use standardized transaction descriptions
  • Include transaction hashes in metadata

2. Regular Reconciliation

  • Verify balances weekly across all platforms
  • Use balance assertions to catch discrepancies
  • Monitor for missing transactions

3. Backup and Security

  • Regularly backup your Beancount files
  • Use version control (Git) for change tracking
  • Encrypt sensitive data

4. Documentation

  • Document your account structure decisions
  • Maintain notes on complex transactions
  • Keep records of API configurations

5. Tax Preparation

  • Generate reports quarterly for tax planning
  • Maintain detailed records for audit purposes
  • Consult with tax professionals for complex situations

Conclusion

Effective cryptocurrency portfolio tracking requires precision, consistency, and the right tools. Beancount.io provides the flexibility and power needed to manage complex crypto portfolios across multiple exchanges, wallets, and DeFi protocols.

Key benefits of using Beancount.io for crypto portfolio tracking:

  • Complete Data Ownership: Your data in plain-text format
  • Precise Cost Basis: Lot-based tracking with specific identification
  • Unlimited Flexibility: Custom account structures and reporting
  • Tax Optimization: Advanced strategies for minimizing tax liability
  • Future-Proof: Open format ensures long-term accessibility

Start with a basic setup and gradually expand your tracking as your portfolio grows in complexity. The investment in proper setup will pay dividends in accurate reporting, tax optimization, and portfolio insights.

Ready to take control of your cryptocurrency portfolio? Get started with Beancount.io today.