|
1 | | -# RabbitAssets |
| 1 | +# RabbitAssets 🐰📈 |
| 2 | + |
| 3 | +A high-performance asset price monitoring system built with Bun that tracks cryptocurrency, stock, and fiat currency prices across multiple exchanges and exports metrics in OpenMetrics format for Prometheus. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 🚀 Blazing Fast - Built with Bun for optimal performance |
| 8 | +- 📊 Multi-Exchange Support - Binance, Kraken, Coinbase, RabbitStocks, and Fiat currencies |
| 9 | +- 🌍 Multi-Currency Portfolio - Automatic currency conversion with real-time forex rates |
| 10 | +- 🎯 OpenMetrics Export - Prometheus-compatible metrics endpoint |
| 11 | +- 🔄 Real-time Updates - WebSocket connections for live price updates |
| 12 | +- 👥 Multi-Owner Support - Track assets for multiple portfolio owners |
| 13 | +- 🐳 Docker Ready - Easy deployment with Docker and Docker Compose |
| 14 | +- 🔐 Bearer Authentication - Optional token-based API security |
| 15 | +- 📈 Portfolio Analytics - Value breakdowns, currency distribution, and asset percentages |
| 16 | + |
| 17 | +## Supported Exchanges |
| 18 | + |
| 19 | +- [**RabbitStocks**](https://github.com/Rabbit-Company/RabbitStockAPI) - Stock market data |
| 20 | +- **Binance** - Cryptocurrency prices via WebSocket |
| 21 | +- **Kraken** - Cryptocurrency prices via WebSocket |
| 22 | +- **Coinbase** - Cryptocurrency prices via WebSocket |
| 23 | +- [**Fiat**](https://github.com/Rabbit-Company/RabbitForexAPI) - Forex currency conversion rates |
| 24 | + |
| 25 | +## Quick Start |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | + |
| 29 | +Docker and Docker Compose |
| 30 | + |
| 31 | +### Configuration |
| 32 | + |
| 33 | +Create a `config.json` next to `docker-compose.yml` file: |
| 34 | + |
| 35 | +```json |
| 36 | +{ |
| 37 | + "server": { |
| 38 | + "host": "0.0.0.0", |
| 39 | + "port": 3000, |
| 40 | + "token": null |
| 41 | + }, |
| 42 | + "logger": { |
| 43 | + "level": 3 |
| 44 | + }, |
| 45 | + "assets": [ |
| 46 | + { |
| 47 | + "symbol": "EUR", |
| 48 | + "quantity": 1500, |
| 49 | + "exchange": "fiat", |
| 50 | + "currency": "USD", |
| 51 | + "owner": "default" |
| 52 | + }, |
| 53 | + { |
| 54 | + "symbol": "EUR", |
| 55 | + "quantity": 430, |
| 56 | + "exchange": "fiat", |
| 57 | + "currency": "EUR", |
| 58 | + "owner": "ziga" |
| 59 | + }, |
| 60 | + { |
| 61 | + "symbol": "UBNT", |
| 62 | + "quantity": 3.624, |
| 63 | + "exchange": "rabbitstocks", |
| 64 | + "currency": "EUR", |
| 65 | + "owner": "default" |
| 66 | + }, |
| 67 | + { |
| 68 | + "symbol": "UBNT", |
| 69 | + "quantity": 1.31, |
| 70 | + "exchange": "rabbitstocks", |
| 71 | + "currency": "EUR", |
| 72 | + "owner": "ziga" |
| 73 | + }, |
| 74 | + { |
| 75 | + "symbol": "NET", |
| 76 | + "quantity": 4.5, |
| 77 | + "exchange": "rabbitstocks", |
| 78 | + "currency": "EUR", |
| 79 | + "owner": "default" |
| 80 | + }, |
| 81 | + { |
| 82 | + "symbol": "WISEl", |
| 83 | + "quantity": 4, |
| 84 | + "exchange": "rabbitstocks", |
| 85 | + "currency": "EUR", |
| 86 | + "owner": "default" |
| 87 | + }, |
| 88 | + { |
| 89 | + "symbol": "BTC", |
| 90 | + "quantity": 0.043212, |
| 91 | + "exchange": "binance", |
| 92 | + "currency": "USD", |
| 93 | + "owner": "default" |
| 94 | + }, |
| 95 | + { |
| 96 | + "symbol": "BTC", |
| 97 | + "quantity": 0.0003167, |
| 98 | + "exchange": "binance", |
| 99 | + "currency": "USD", |
| 100 | + "owner": "ziga" |
| 101 | + }, |
| 102 | + { |
| 103 | + "symbol": "ETH", |
| 104 | + "quantity": 0.64232, |
| 105 | + "exchange": "coinbase", |
| 106 | + "currency": "USD", |
| 107 | + "owner": "default" |
| 108 | + }, |
| 109 | + { |
| 110 | + "symbol": "SOL", |
| 111 | + "quantity": 0.16, |
| 112 | + "exchange": "coinbase", |
| 113 | + "currency": "USD", |
| 114 | + "owner": "default" |
| 115 | + }, |
| 116 | + { |
| 117 | + "symbol": "XMR", |
| 118 | + "quantity": 2.54, |
| 119 | + "exchange": "kraken", |
| 120 | + "currency": "USD", |
| 121 | + "owner": "default" |
| 122 | + } |
| 123 | + ] |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +### Running with Docker Compose |
| 128 | + |
| 129 | +```bash |
| 130 | +docker-compose up -d |
| 131 | +``` |
| 132 | + |
| 133 | +### Manual Docker Run |
| 134 | + |
| 135 | +```bash |
| 136 | +docker run -d \ |
| 137 | + --name rabbitassets \ |
| 138 | + -p 3000:3000 \ |
| 139 | + -v $(pwd)/config.json:/usr/src/app/config.json \ |
| 140 | + rabbitcompany/rabbitassets:latest |
| 141 | +``` |
| 142 | + |
| 143 | +## API Endpoints |
| 144 | + |
| 145 | +### GET `/metrics` |
| 146 | + |
| 147 | +OpenMetrics format endpoint for Prometheus scraping. |
| 148 | + |
| 149 | +### GET `/v1/assets` |
| 150 | + |
| 151 | +JSON API endpoint returning all asset metrics. |
| 152 | + |
| 153 | +Example response: |
| 154 | + |
| 155 | +```json |
| 156 | +[ |
| 157 | + { |
| 158 | + "symbol": "BTC", |
| 159 | + "quantity": 0.043212, |
| 160 | + "currentPrice": 45000.5, |
| 161 | + "value": 1944.56, |
| 162 | + "currency": "USD", |
| 163 | + "owner": "default" |
| 164 | + }, |
| 165 | + { |
| 166 | + "symbol": "ETH", |
| 167 | + "quantity": 0.64232, |
| 168 | + "currentPrice": 2500.75, |
| 169 | + "value": 1605.48, |
| 170 | + "currency": "USD", |
| 171 | + "owner": "default" |
| 172 | + } |
| 173 | +] |
| 174 | +``` |
0 commit comments