Skip to content

Repository files navigation

LSEG Market Data Automation - Bare Minimum Example

A simple demonstration of scheduling Python scripts with Windows Task Scheduler.

32 lines of Python code + 4 lines of batch = automated market data collection

What This Does

  1. Opens an LSEG session
  2. Retrieves market data (IBM.N, MSFT.O - closing prices)
  3. Saves to CSV with today's date
  4. Runs daily via Windows Task Scheduler

Files

├── 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

Quick Start (5 minutes)

1. Install

pip install lseg-data

2. Test Script

cd C:\path\to\files
python lseg_market_data_example.py

Output:

Session opened
Data saved to market_data_20260804.csv
Done

3. Schedule It

  • Open Task Scheduler: taskschd.msc
  • Create task to run run_market_data.bat
  • Set trigger: Weekly, weekdays, 7:00 AM
  • See TASK_SCHEDULER_SETUP.md for details

4. Verify

Check that market_data_20260804.csv was created

Example Output

Instrument,Identifier,TR.PriceClose
IBM,IBM.N,180.45
MSFT,MSFT.O,425.30

Code Overview

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!

Why This Example?

✓ 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

What's Missing (For Production)

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.

Next Steps

  1. Learn: Understand this simple version first
  2. Test: Run it manually several times
  3. Schedule: Get it working in Task Scheduler
  4. Enhance: Add items from production checklist
  5. Monitor: Set up alerts and tracking

Key Files to Read

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

Common Next Additions

Most users add these first:

  1. Logging to file (see PRODUCTION_CHECKLIST.md)
  2. Better error handling (try/except/finally)
  3. Configuration file (externalize instrument list)
  4. Email alerts on failure

Support

  • LSEG Issues: Check LSEG Data Library docs
  • Task Scheduler Issues: See TASK_SCHEDULER_SETUP.md troubleshooting
  • Python Issues: Standard Python debugging

Example Architecture

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)

Files Generated at Runtime

market_data_20260804.csv  (Date-stamped CSV file)

Just one file - simple and predictable.

Tips

  • 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

About

Learn how to automate Python scripts that retrieve LSEG data using Workspace Desktop Sessions, batch files, and Windows Task Scheduler.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages