Flat Files Data Guide – Filtering by exchange_symbol (Isolating Instruments from OHLCV Data)
Flat Files contain multiple instruments in a single file, even when scoped to one exchange. To analyze a specific asset (e.g., SWVL, TSM), you must filter by exchange_symbol.
This guide shows how to properly isolate and export specific instruments.
🧠 Understanding the Data Structure
Each row represents one instrument (symbol) for a given time period.
Sample Data
🔑 Key Columns
id_exchange→ Exchange (e.g.,IEXG)exchange_symbol→ Instrument (e.g., SWVL, TSM, GLL)time_period_start/end→ Candle intervalprice_open/high/low/close→ OHLC pricesvolume_traded,trades_count→ activity
❗ Why Filtering is Helpful
Even though the file is:
It still contains multiple exchange_symbol values (SWVL, TSM, GLL, etc.)
👉 Without filtering, you are analyzing multiple instruments mixed together, which leads to incorrect results.
🔍 Step 1: Load the Data
🐍 Python (Pandas)
🎯 Step 2: Filter by a Single exchange_symbol
📁 Step 3: Save to a New File
👉 This creates a new file containing only SWVL data
🔢 Step 4: Filter Multiple Symbols
Save multiple-symbol dataset
🔄 Step 5: (Optional) Automate Per-Symbol Export
Split the file into one file per symbol:
👉 Output:
⚠️ Common Mistakes
❌ Forgetting quotes for strings
Wrong:
Correct:
❌ Not saving the output
print(filtered)# only displays
👉 You must use:
to_csv()
❌ Wrong delimiter
Wrong:
Correct:
💡 Best Practices
- Always filter before analysis
- Use
.isin()for multiple symbols - Save filtered outputs for reuse
- Validate results using
.unique()
🎯 Key Takeaway
Each Flat File is:
One exchange → Many symbols → One time interval
👉 Filtering by exchange_symbol is a helpful first step before any meaningful analysis.
