A microservice that leverages AI to forecast currency exchange rates by analyzing financial news. The system integrates Meta-LLaMA (LLaMA-3.2-1B-Instruct) for AI predictions and NewsAPI for real-time financial news data.
- Real-time Currency Conversion: Fetch and convert exchange rates between multiple currencies
- AI-Powered Forecasting: Utilize Meta-LLaMA model for exchange rate predictions
- Automated News Analysis: Real-time financial news retrieval and processing with relevancy scoring
- Secure API Management: Protected storage for API credentials
- Ballerina Architecture: Robust microservice structure with error handling and logging
- Historical Data Storage: Systematic storage of AI forecasts and news articles
.
βββ ai_module/
β βββ hf_token.txt # Hugging Face API credentials
β βββ llama_api_server.py # AI prediction service
βββ ballerina_code/
β βββ currency_service.bal # Main Ballerina service
β βββ collected_ai_forecasts/ # Forecast storage
βββ news_api/
β βββ news_token.txt # NewsAPI credentials
β βββ news_api_server.py # News fetching service
βββ collected_news/ # News article storage
- Hugging Face Account
- Create account at Hugging Face
- Request special access for Meta-LLaMA models
- Generate API token
- NewsAPI Account
- Register at NewsAPI
- Obtain API key
- Ballerina Installation
- Follow official Ballerina installation guide
- Required version: 2023R1 or higher
-
Clone Repository
git clone https://github.com/WWI2196/iwb151-fouett-bytes.git cd currency-exchange-prediction -
Install Python Dependencies
pip install torch transformers flask huggingface-hub newsapi-python python-dateutil requests logging
-
Launch AI Service
python ai_module/llama_api_server.py
Runs on port 5001
-
Start News Service
python news_api/news_api_server.py
Runs on port 5002
-
Run Ballerina Service
bal run ballerina_code/currency_service.bal
Important: Once both Python and Ballerina services are running, AI predictions will be automatically saved to the
collected_ai_forecastsfolder in the main directory.
- Place your Hugging Face token in
ai_module/hf_token.txt - Store NewsAPI key in
news_api/news_token.txt
- Modify the model ID in
llama_api_server.pyto use alternative models - Current model: "meta-llama/Llama-3.2-1B-Instruct"
- Configuration: torch.bfloat16, CPU inference, max_tokens=4000
- Articles fetched from last 7 days
- Relevancy scoring based on categories:
- Monetary Policy
- Economic Indicators
- Currency-Specific News
- Market Sentiment
- Geopolitical Events
- Technical Analysis
- NewsAPI service fetches latest financial news
- News data is processed and stored in
collected_news - AI service analyzes news using Meta-LLaMA
- Predictions are stored in
collected_ai_forecasts - Ballerina service orchestrates the entire workflow
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
Distributed under the MIT License. See LICENSE for more information.