GitHunt

๐Ÿš€ Crypto Portfolio Tracker

A powerful and elegant solution for tracking your crypto portfolio across multiple blockchains in real-time. Get instant visibility into your total holdings, asset distribution, and individual wallet balances - all in one place.

Dashboard mode:

Portfolio Dashboard

CLI mode:

Portfolio CLI

Telegram bot mode:

Portfolio Telegram Bot

โœจ Features

  • Multi-Chain Support: Track wallets across different blockchains simultaneously
  • Interactive Dashboard: Beautiful visualization of your portfolio distribution
  • Flexible Display: Choose between CLI or Web interface
  • Customizable Base Currency: View your portfolio in your preferred currency

๐Ÿ”— Supported Blockchains

See explorers for supported blockchains.

You can easily add your own explorers by adding a new file in the explorers directory.

Just track the API that the explorer provides and make the same request.

๐Ÿ› ๏ธ Installation

  1. Clone the repository:
git clone https://github.com/douiebyossef/crypto-portfolio-tracker.git
cd crypto-portfolio-tracker
  1. Install dependencies:
pip install -r requirements.txt
  1. Create your configuration file config.json:
{
    "currency": "USD",
    "wallets": {
        "btc": ["your-btc-wallet-address"],
        "eth": ["your-eth-wallet-address"],
        "sol": ["your-solana-wallet-address"]
    },
    "api_keys": {
        "coinmarketcap": "your_coinmarketcap_api_key",
    }
}

You can get your (100% FREE) coinmarketcap api key from here.

๐Ÿš€ Usage

Web Interface

Start the web dashboard:

python main.py --web

Then open your browser to http://127.0.0.1:8000

CLI Interface

For a quick command-line view:

python main.py

You can easily navigate between portfolios by using different config files.

python main.py --config jones_portfolio.json

Telegram Bot Interface

Start the Telegram bot:

python main.py --bot

You can also run both web and bot interfaces simultaneously:

python main.py --web --bot

To set up the Telegram bot:

  1. Create a new bot with @BotFather on Telegram
  2. Add your bot token to config.json:
{
    "api_keys": {
        "telegram": "your_telegram_bot_token"
    }
}

Security Features

Authentication

To enable authentication for the web dashboard and REST API:

  1. Add authentication settings to your config.json:
{
    "auth": {
        "username": "admin",
        "password": "your_secure_password",
        "enabled": true
    }
}

When enabled, you'll be prompted for credentials when accessing:

  • Web dashboard
  • REST API endpoints

HTTPS Support

To enable HTTPS for the web interface:

  1. Generate SSL certificate and key:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
  1. Add SSL settings to your config.json:
{
    "ssl": {
        "enabled": true,
        "certfile": "cert.pem",
        "keyfile": "key.pem"
    }
}

The web interface will automatically use HTTPS when SSL is enabled.

Logging

Control logging verbosity using the --log-level argument:

python main.py --log-level debug   # Most verbose
python main.py --log-level info    # Default
python main.py --log-level warning # Less verbose
python main.py --log-level error   # Least verbose

Logs are written to both console and portfolio.log file.

๐ŸŽฏ Key Components

  • Portfolio Management: Handles wallet balance fetching and total value calculations
  • Price Fetching: Real-time cryptocurrency price updates
  • Interactive Dashboard: Built with Plotly for beautiful data visualization
  • REST API: Full-featured API for portfolio data access

๐Ÿ”Œ API Endpoints

You can surf to http://127.0.0.1:8000/docs to get a full Swagger UI of the API.

Endpoint Description
GET /portfolio/total Get total portfolio value
GET /portfolio/currency/{currency} Get details for specific currency
GET /portfolio/wallet/{address} Get specific wallet details
GET /portfolio/total/detailed Get complete portfolio breakdown

Google Sheet Integration (Google Apps Script)

You can integrate your portfolio with Google Sheets using this Apps Script:

function fetchPortfolioTotalValue() {
  var url = "https://NODE_IP/portfolio/total";
  
  var options = {
    "headers": {
      "Authorization": "Basic BASE64(YOURUSER:YOURPASS)"
    },
    // 'validateHttpsCertificates' : false // Prevents the script from stopping on HTTPS errors
  };
  
  var response = UrlFetchApp.fetch(url, options);
  var status = response.getResponseCode();
  var content = response.getContentText();
  
  console.log("Status: " + status);
  console.log("Content: " + content);
  
  if (status === 200) {
    var data = JSON.parse(content);
      console.log("Total: " + data.total + " " + data.currency);
    return data.total;
  } else {
    console.log("Failed with status: " + status);
    return null;
  }
}

To use:

  1. Open Google Sheets
  2. Go to Extensions > Apps Script
  3. Paste the code above
  4. Replace NODE_IP with your server address
  5. Replace BASE64(YOURUSER:YOURPASS) with your base64 encoded credentials
  6. Use =fetchPortfolioTotalValue() in any cell

Note: If using self-signed SSL certificates, uncomment the validateHttpsCertificates line.

๐ŸŽจ Dashboard Features

  • Portfolio Distribution Chart: Interactive donut chart showing asset allocation
  • Detailed Breakdown Table: Complete listing of all wallets and balances
  • Responsive Design: Works seamlessly on desktop and mobile

๐Ÿ›ก๏ธ Security

  • No private keys required
  • Read-only wallet access
  • Local configuration storage

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built with FastAPI, Plotly, and Rich
  • Special thanks to all contributors

๐Ÿ“ TODO

  • Security Enhancements
    • Add authentication to dashboard and REST API
    • Add HTTPS support
    • Add API key management
  • Integrations
    • Google Sheets integration for portfolio tracking
  • System Improvements
    • Add proper logging
    • Add error tracking and monitoring
  • Documentation
    • Add deployment guides (Dockerize?)
douiebyossef/crypto-portfolio-tracker | GitHunt