No description
Find a file
2025-11-28 18:19:30 +00:00
src Added simple API, updated README 2025-11-28 18:19:30 +00:00
tests Simplified api code, corrected tests 2025-11-28 17:39:31 +00:00
.dockerignore Changes to logging and db logic 2025-11-27 17:12:06 +00:00
.env Better error handling, caching and deduplication. Added tests to api and db logic 2025-11-28 15:07:10 +00:00
.env.example Corrected README 2025-11-28 18:04:04 +00:00
.gitignore Initial commit 2025-11-27 14:41:21 +00:00
compose.yml Added simple API, updated README 2025-11-28 18:19:30 +00:00
Containerfile Corrected README 2025-11-28 18:04:04 +00:00
index.js Added simple API, updated README 2025-11-28 18:19:30 +00:00
package.json Better error handling, caching and deduplication. Added tests to api and db logic 2025-11-28 15:07:10 +00:00
README.md Added simple API, updated README 2025-11-28 18:19:30 +00:00

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 point
  • src/bot.js - Bot monitoring logic
  • src/api.js - Uphold API client with rate limiting
  • src/db.js - PostgreSQL DB layer
  • src/logger.js - logging
  • tests/bot.test.js - Test suite

Stopping the Bot

Press Ctrl+C or send SIGTERM for graceful shutdown.

With Docker:

docker compose down

License

MIT