gittech. site

for different kinds of informations and explorations.

Crypto DCA Analyzer

Published at
3 days ago

Crypto DCA Calculator

A Python tool for analyzing Dollar Cost Averaging (DCA) investment strategies for cryptocurrencies. Supports multiple trading pairs, custom buy frequencies, and provides detailed performance metrics and visualizations.

CLI Example DCA Analysis Example

πŸš€ Features

βœ… Fetch historical price data from various exchanges (default: Binance)
βœ… Multi-asset DCA simulation with custom allocations
βœ… Flexible investment schedules (daily, weekly, biweekly, monthly)
βœ… In-depth performance analysis per asset
βœ… Comprehensive portfolio metrics with Fear Index tracking
βœ… Visual insights via price and P&L charts
βœ… Intuitive CLI output with progress indicators

πŸ›  Requirements

Install the following dependencies:

pip install -r requirements.txt
pandas>=2.1.0
matplotlib>=3.8.0
ccxt>=4.1.13
rich>=13.7.0
numpy>=1.24.0

🎯 Usage

Basic DCA for a single pair

python dca_btc.py --daily-investment 10 --pairs BTC/USDT:100

Multi-asset DCA with custom allocations

python dca_btc.py --daily-investment 100 --pairs BTC/USDT:80 ETH/USDT:20

Weekly investment

python dca_btc.py --daily-investment 100 --pairs BTC/USDT:60 ETH/USDT:30 SOL/USDT:10 --buy-period 1w

Advanced options

python dca_btc.py --start-date 2020-01-01 --end-date 2023-12-31 --daily-investment 100 \
                  --pairs BTC/USDT:50 ETH/USDT:30 DOT/USDT:20 \
                  --exchange binance --buy-period 2w

πŸ“Œ Arguments

| Argument | Description | | -- | | | --start-date | Start date in YYYY-MM-DD format | | --end-date | End date in YYYY-MM-DD format | | --last-days | Number of recent days to analyze | | --daily-investment | Daily investment amount in USD | | --exchange | Exchange to fetch data from (default: Binance) | | --pairs | Trading pairs with allocation percentages (e.g., BTC/USDT:80 ETH/USDT:20) | | --buy-period | Investment frequency (1d=daily, 1w=weekly, 2w=biweekly, 1m=monthly) | | --plot-type | Chart output: 'all', 'total', or 'both' |

πŸ“Š Output & Reports

1️⃣ Console Summary

Each run provides a detailed breakdown of your investments:

  • πŸ“Š Total Invested & Current Value
  • πŸ”’ Accumulated Crypto Amounts
  • πŸ“ˆ Net Profit/Loss & PNL%
  • πŸ›‘ Fear Index (days in negative returns)
  • πŸ’΅ Cost Basis vs. Market Price
  • πŸ“‰ Historic Highs & Lows with Dates

2️⃣ Visual Reports (Saved to /dca/ directory)

  • Individual Asset Performance Charts πŸ“Š
  • Total Portfolio Performance Graph πŸ“ˆ
  • Investment vs. Market Trends πŸ”

πŸ“ Example Commands

Invest $100 daily, 80% BTC & 20% ETH

python dca_btc.py --daily-investment 100 --pairs BTC/USDT:80 ETH/USDT:20

Weekly $500 DCA across 3 assets

python dca_btc.py --daily-investment 500 --pairs BTC/USDT:50 ETH/USDT:30 SOL/USDT:20 --buy-period 1w

Monthly $1000 BTC investment

python dca_btc.py --daily-investment 1000 --pairs BTC/USDT:100 --buy-period 1m

Generate only the total portfolio chart

python dca_btc.py --daily-investment 200 --pairs BTC/USDT:40 ETH/USDT:40 SOL/USDT:20 --plot-type total

🀝 Contributing

Pull requests and contributions are welcome! Feel free to open issues for improvements.

πŸ“œ License

This project is open-source under the MIT License.