douiebyossef/crypto-portfolio-tracker
Crypto portfolio tracker that can checks your wallets across multiple blockchains and give you the total value in your proffered currency
๐ 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:
CLI mode:
Telegram bot mode:
โจ 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
- Clone the repository:
git clone https://github.com/douiebyossef/crypto-portfolio-tracker.git
cd crypto-portfolio-tracker- Install dependencies:
pip install -r requirements.txt- 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 --webThen open your browser to http://127.0.0.1:8000
CLI Interface
For a quick command-line view:
python main.pyYou can easily navigate between portfolios by using different config files.
python main.py --config jones_portfolio.jsonTelegram Bot Interface
Start the Telegram bot:
python main.py --botYou can also run both web and bot interfaces simultaneously:
python main.py --web --botTo set up the Telegram bot:
- Create a new bot with @BotFather on Telegram
- 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:
- 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:
- Generate SSL certificate and key:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365- 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 verboseLogs 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:
- Open Google Sheets
- Go to Extensions > Apps Script
- Paste the code above
- Replace
NODE_IPwith your server address - Replace
BASE64(YOURUSER:YOURPASS)with your base64 encoded credentials - 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?)