A robust, automated system for collecting and processing bond data from multiple sources to generate comprehensive analysis and reports.
This system automates the daily collection of financial market data from three distinct sources, processes it according to financial analysis rules, and generates standardized outputs. Each data source has its own workflow with built-in error handling, retry mechanisms, and notification systems.
-
Market Data Terminal
- Connects to financial data terminal
- Fetches yield data for configured bonds
- Uses provider's Python API
-
National Data Source
- Monitors Office 365 inbox for emails from the national exchange
- Downloads and processes daily report attachments
- Extracts relevant trading data
-
Company Data
- Processes daily company Excel reports
- Extracts and saves relevant datasets for further processing
-
Automated Data Collection
- Single command to run all workflows
- Individual workflow execution option
- Automatic retry on failures
-
Robust Error Handling
- Three retry attempts with configurable intervals
- Detailed error logging
- Email notifications for persistent failures
-
Data Processing
- Standardized data formats
- Source tracking and prioritization
- Data validation at each step
-
Monitoring & Notifications
- Uses Office 365 for email monitoring and notifications
- Configurable notification recipients
- Detailed logging of all operations
- Python 3.7+
- Market data terminal installed locally
- Microsoft Office 365 account with appropriate permissions
- Git (for version control)
pip install -r requirements.txt
-
Market Data Terminal
- Local installation
- Default connection settings
-
Microsoft Office 365
- Azure App Registration
- Required permissions:
- Mail.Read
- Mail.Send
- Mail.ReadWrite
bond-data-collection/
├── README.md
├── requirements.txt
├── .env # Configuration file (not in version control)
├── .env.example # Example configuration template
├── src/
│ ├── run_all.py # Master workflow orchestrator
│ ├── config.py # Configuration management
│ ├── utils.py # Common utilities
│ ├── get_yields_terminal.py # Market data collection
│ ├── get_national_email.py # National data source processing
│ ├── get_company_daily.py # Company data processing
│ └── bonds.json # Bond configuration
├── output/ # Data output directory
└── logs/ # Log files directory
- Copy
.env.example
to.env
cp .env.example .env
- Configure environment variables:
# Market Data Terminal Configuration
BLOOMBERG_HOST=localhost
BLOOMBERG_PORT=8194
# Microsoft 365 Configuration
O365_CLIENT_ID=your_client_id
O365_CLIENT_SECRET=your_client_secret
# Error Notification Configuration
[email protected]
[email protected]
# File Paths
COMPANY_DAILY_PATH=/path/to/daily/report.xlsx
BONDS_JSON_PATH=src/bonds.json
# Output Configuration
OUTPUT_DIR=output
LOGS_DIR=logs
Configure target financial instruments in the bonds.json file.
python src/run_all.py
python src/get_yields_terminal.py # Market data only
python src/get_national_email.py # National data source only
python src/get_company_daily.py # Company data only
Each workflow generates:
- CSV data files with standardized formats
- Detailed log files
- Error notifications (if needed)
- Open Task Scheduler
- Create Basic Task
- Set trigger to Daily
- Action: Start a program
- Program/script:
python
- Arguments:
path/to/src/run_all.py
Add to crontab:
0 9 * * 1-5 cd /path/to/project && python src/run_all.py
- Check log files in
logs/
directory - Monitor error notifications
- Review output CSV files
The system includes comprehensive error handling:
-
Retry Logic
- Configurable retry attempts per operation
- Configurable intervals between attempts
- Automatic notification on final failure
-
Data Validation
- Input file existence checks
- Data format validation
- Output data verification
-
Error Notifications
- Sent via Office 365
- Include error details
- Sent to multiple recipients
-
Credentials
- Store in
.env
file - Never commit to version control
- Use secure storage in production
- Store in
-
Office 365
- Use App Registration
- Implement least privilege access
- Regular credential rotation
-
Data Protection
- Secure file permissions
- Clean up temporary files
- Encrypt sensitive data
- Monitor log files
- Check error notifications
- Verify data output
- Review system performance
- Check disk space
- Backup configuration
- Rotate log files
- Update dependencies
- Review access credentials
-
Data Terminal Connection
- Verify Terminal is running
- Check connection settings
- Review logs
-
Email Processing
- Check O365 credentials
- Verify email format
- Review attachment names
-
Company Data
- Verify file path
- Check Excel format
- Validate sheet names
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This project is not affiliated with any financial data provider or exchange. Names of specific services are the property of their respective owners.