The monitoring system continuously tracks exchange rates and sends notifications when optimal rates are detected. It uses Alpha Vantage API for real-time forex data and implements rate limiting to stay within API constraints. It is hosted on cron-job.org and runs every 60 minutes.
Each monitoring job execution is logged in MongoDB Atlas with the following structure:
{
"timestamp": "<UTC timestamp when job started>",
"status": "<completed|error>",
"message": "<descriptive message>",
"alerts_processed": "<number of alerts processed>",
"results": [
{
"alert_id": "<alert_id>",
"status": "<notification_sent|rate_not_optimal|error>",
"current_rate": "<rate>",
"error": "<error message if status is error>"
}
],
"duration_seconds": "<execution time in seconds>"
}
- Rate Limiting: Implements a sliding window rate limiter for Alpha Vantage API (5 calls per minute)
- Lock Mechanism: Prevents multiple monitoring processes from running simultaneously.
- Sentiment Analysis: Analyzes news sentiment to assist rate optimization decisions, with news fetch done using Perplexity.AI
- Email Notifications: Sends HTML-formatted alerts when optimal rates are detected, through Gmail SMTP
- Error Handling: Comprehensive error handling and logging for debugging, so the user never encounters an
Internal Server Error
adapted from MelodySyncer
Rate is considered optimal when either:
- Current rate is better than 7-day average by more than 1 standard deviation
- Rate is moderately good (>0.5 std dev better than average) AND news sentiment is positive
Use git clone
pip install -r requirements.txt
Copy the .env.example
file to .env
and fill in the values.
# API Configuration
# Required: Contact [email protected] for backend API credentials
API_PASSWORD=your_api_password_here
# Clerk Authentication Configuration
# Required: Sign up at https://clerk.dev to obtain credentials
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key_here
CLERK_SECRET_KEY=your_clerk_secret_key_here
python main.py
This will start the app on http://localhost:8000.
- conceptualized and developed at buildspace nights & weekends s5