A simple demonstration of scheduling Python scripts with Windows Task Scheduler.
32 lines of Python code + 4 lines of batch = automated market data collection
- Opens an LSEG session
- Retrieves market data (IBM.N, MSFT.O - closing prices)
- Saves to CSV with today's date
- Runs daily via Windows Task Scheduler
├── lseg_market_data_example.py Main script (32 lines)
├── run_market_data.bat Batch wrapper (4 lines)
├── TASK_SCHEDULER_SETUP.md How to schedule it
├── IMPLEMENTATION_GUIDE.md Quick start guide
├── PRODUCTION_CHECKLIST.md What to add before production
└── README.md This file
pip install lseg-datacd C:\path\to\files
python lseg_market_data_example.pyOutput:
Session opened
Data saved to market_data_20260804.csv
Done
- Open Task Scheduler:
taskschd.msc - Create task to run
run_market_data.bat - Set trigger: Weekly, weekdays, 7:00 AM
- See
TASK_SCHEDULER_SETUP.mdfor details
Check that market_data_20260804.csv was created
Instrument,Identifier,TR.PriceClose
IBM,IBM.N,180.45
MSFT,MSFT.O,425.30
Python Script:
- Simple, readable, 32 lines
- Opens LSEG session → retrieves data → saves CSV → closes session
- Returns 0 (success) or 1 (error)
- Perfect for beginners to understand the pattern
Batch File:
- Change to script directory
- Run Python script
- Return exit code
That's it!
✓ Minimal code - easy to understand ✓ No dependencies beyond LSEG library ✓ No configuration files or frameworks ✓ Ready to run in 5 minutes ✓ Shows you exactly what's needed ✓ Perfect for learning
This is intentionally bare minimum. See PRODUCTION_CHECKLIST.md for:
- Proper logging to file
- Better error handling
- Data validation
- Configuration file
- Monitoring/alerts
- Credentials management
- Retry logic
- Unit tests
- Documentation/runbook
Upgrade each item as needed for your production system.
- Learn: Understand this simple version first
- Test: Run it manually several times
- Schedule: Get it working in Task Scheduler
- Enhance: Add items from production checklist
- Monitor: Set up alerts and tracking
| File | Read When |
|---|---|
IMPLEMENTATION_GUIDE.md |
First - quick 2-minute overview |
TASK_SCHEDULER_SETUP.md |
Ready to schedule the task |
PRODUCTION_CHECKLIST.md |
Moving to production |
Most users add these first:
- Logging to file (see
PRODUCTION_CHECKLIST.md) - Better error handling (try/except/finally)
- Configuration file (externalize instrument list)
- Email alerts on failure
- LSEG Issues: Check LSEG Data Library docs
- Task Scheduler Issues: See
TASK_SCHEDULER_SETUP.mdtroubleshooting - Python Issues: Standard Python debugging
Daily Trigger (7:00 AM)
↓
Windows Task Scheduler
↓
run_market_data.bat
↓
lseg_market_data_example.py
↓
[Open LSEG Session]
↓
[Get IBM.N, MSFT.O prices]
↓
[Save market_data_20260804.csv]
↓
[Close Session]
↓
Exit Code 0 (success)
market_data_20260804.csv (Date-stamped CSV file)
Just one file - simple and predictable.
- Test manually first before scheduling
- Check Task Scheduler History tab to see if task ran
- Add logging as first enhancement
- Start simple and add features as needed
- Keep it in version control once you understand it
Version: 1.0 (Bare Minimum Example)
Complexity: Beginner-friendly
Time to production: 30 minutes minimum, then enhance as needed