No description
| src | ||
| tests | ||
| .dockerignore | ||
| .env | ||
| .env.example | ||
| .gitignore | ||
| compose.yml | ||
| Containerfile | ||
| index.js | ||
| package.json | ||
| README.md | ||
Uphold Price Alert Bot
Requirements
- Node.js >= v20
- Docker & Docker Compose (optional)
- PostgreSQL (optional, runs in-memory without it)
Quick Start
1. Install Dependencies
npm install
2. Run the Bot
With default parameters:
node index.js
or
npm start
With custom parameters:
node index.js --pairs BTC-USD,ETH-USD --interval 5000 --threshold 0.01
or
npm start -- --pairs BTC-USD,ETH-USD --interval 5000 --threshold 0.01
With environment file:
node --env-file=.env.example index.js
3. Run with Docker Compose (includes PostgreSQL)
cp .env.example .env
# Edit .env with your settings
# POSTGRES_USER=uphold
# POSTGRES_PASSWORD=uphold
# POSTGRES_DB=uphold_db
# PAIRS=BTC-USD,ETH-USD
# INTERVAL=5000
# THRESHOLD=0.01
# Start services
docker compose up -d --build
# View logs
docker compose logs -f bot
Configuration
| Parameter | Flag | Environment | Default | Description |
|---|---|---|---|---|
| Pairs | -p, --pairs |
PAIRS |
BTC-USD |
Comma-separated currency pairs |
| Interval | -i, --interval |
INTERVAL |
5000 |
Check interval in milliseconds |
| Threshold | -t, --threshold |
THRESHOLD |
0.01 |
Alert threshold percentage |
| Stats | --stats |
STATS |
false |
Show performance statistics |
Database Setup (Optional)
The bot runs in-memory mode by default. To persist alerts:
# Set DATABASE_URL
export DATABASE_URL="postgres://user:password@localhost:5432/uphold_db"
# Run the bot
node index.js
The alerts table is created automatically on first run.
Running Tests
npm test
Example Output
[INFO] Uphold price alert bot starting...
[INFO] [WATCHING] BTC-USD, ETH-USD | Every 5000ms | Threshold 0.01%
[INFO] [BTC-USD] Initial price: 42350.50
[INFO] [ETH-USD] Initial price: 2245.75
[INFO] [ALERT] BTC-USD UP 0.0125% (42350.50 → 42355.79)
[INFO] [DB] Event saved for BTC-USD
Architecture
index.js- Entry pointsrc/bot.js- Bot monitoring logicsrc/api.js- Uphold API client with rate limitingsrc/db.js- PostgreSQL DB layersrc/logger.js- loggingtests/bot.test.js- Test suite
Stopping the Bot
Press Ctrl+C or send SIGTERM for graceful shutdown.
With Docker:
docker compose down
License
MIT