Financial Data: Market Data, ETF Data & Analytics
Engineering for mission-critical capital markets systems. Build high-frequency market data pipelines, ETF constituent weight rebalancing, investment portfolio reconciliation (T+1/T+2), risk metrics (Sharpe, Drawdowns, VWAP), and SEC EDGAR financial ingestion.
1. Financial Data Engineering Fundamentals
Domain KnowledgeFinancial engineering requires blending deep domain concepts (asset classes, order book depths, trade settlement horizons, corporate actions) with high-throughput distributed systems. Unlike standard web analytics, financial data requires zero tolerance for missing ticks, deterministic reconciliation between trades and custodians, and point-in-time correctness for quantitative modeling.
Asset Classes
Equities (Stocks), Fixed Income (Bonds, Treasuries), Foreign Exchange (FX), Commodities, ETFs, and Derivatives (Options, Futures, Swaps).
Order Book Depths
Level 1 (Top of Book: Best Bid/Ask), Level 2 (Market Depth: Top 5-10 price levels), and Level 3 (Full Order Book: Every individual limit order).
Settlement Timelines
Trade Date (T) vs Settlement Date (T+1 under current US rules, historically T+2). Cash flows, margin requirements, and custodian clearing.
Corporate Actions
Stock splits (e.g. 10-for-1), reverse splits, cash dividends, stock dividends, mergers, and spin-offs requiring backward historical price adjustment.
Market Data: Real-Time Ticks, Historical Bars & Intraday Feeds
Market data is generated continuously by global electronic exchanges (NYSE, NASDAQ, CME, LSE, NSE). Data arrives as raw execution ticks or quote updates with nanosecond precision timestamps.
Tick-Level Data Structure
Timestamp (epoch nanoseconds), Ticker / ISIN, Trade Price, Trade Volume, Exchange Code, Sale Condition Flags, Bid/Ask quotes at execution.
OHLCV Candlestick Aggregation
Consolidating millions of raw trade ticks into time-bucketed intervals (1s, 1m, 5m, 1h, 1d): Open, High, Low, Close, and cumulative Volume.
Consolidated Feeds vs Direct Feeds
Consolidated feeds (e.g. SIP in the US) merge data from all exchanges. Direct feeds provide lower latency directly from individual matching engines.
Adjusted vs Unadjusted Prices
Backtesting algorithmic models requires dividing historical prices by cumulative split factors and subtracting dividend payouts to eliminate false returns.
ETF Data: Constituents, Weightings & NAV Arbitrage
Exchange Traded Funds (ETFs) represent a basket of underlying securities. Ingesting ETF data requires tracking daily basket files (PCFs), constituent weighting rebalancing, indicative intraday values (iNAV), and premiums/discounts relative to Net Asset Value.
Portfolio Composition File (PCF)
Published daily by ETF issuers. Lists the exact constituent shares required for an Authorized Participant (AP) to create or redeem ETF creation units.
Indicative NAV (iNAV)
Calculated every 15 seconds during trading hours using live constituent prices, giving investors an intraday benchmark of fair basket value.
Premium / Discount to NAV
Calculated as ((Market Price - Official NAV) / Official NAV) * 100. Large spreads signal liquidity dislocation or arbitrage opportunities.
Index Tracking Error
Standard deviation of excess returns between the ETF portfolio and its underlying benchmark index (e.g. S&P 500, MSCI Emerging Markets).
Investment Data: Positions, Holdings & Custodian Feeds
At institutional asset managers (e.g. XXX), investment data pipelines track portfolios comprising billions of dollars across thousands of instruments. These systems reconcile internal order management systems (OMS) against external custodian bank records.
Holdings vs Transactions
Transactions capture point-in-time trade events (Buy, Sell, Dividend, Fee). Holdings reflect snapshot balances (quantity, cost basis, unrealized gain) at market close.
Custodian Data Feeds
Nightly batch files (SWIFT MT535/MT540 statements or proprietary SFTP CSVs) from State Street, BNY Mellon, or JPMorgan documenting cleared cash and securities.
3-Way Reconciliation Pipeline
Matching Internal Accounting Ledger vs OMS Trade Executions vs Custodian Records to flag discrepancies in trade quantities, pricing, or currency FX rates.
Cash Movement & Margin
Tracking unsettled cash, collateralized lending balances, derivative variation margin calls, and multi-currency FX balances.
Financial Analytics: VWAP, TWAP, Sharpe & Volatility
Transforming raw tick and position data into decision-grade risk and performance metrics. Below are standard metrics computed across financial data pipelines.
Volume-Weighted Average Price (VWAP)
VWAP = ∑(Price × Volume) / ∑(Volume) over a trading day. Serves as a trading benchmark to assess institutional execution efficiency.
Sharpe Ratio & Sortino Ratio
Sharpe measures risk-adjusted return: (Return - RiskFreeRate) / AnnualizedVolatility. Sortino penalizes only downside volatility.
Rolling Historical Volatility
Standard deviation of daily log returns over an N-day window (e.g. 30, 90, 252 days) annualized by multiplying by √252.
Maximum Drawdown (MDD)
The maximum observed percentage drop from a portfolio's historical peak NAV to a subsequent trough before a new peak is achieved.
import math
from pyspark.sql import SparkSession
from pyspark.sql import functions as F
from pyspark.sql.window import Window
spark = SparkSession.builder.appName("FinancialRiskAnalytics").getOrCreate()
def compute_daily_vwap(trades_df):
"""Computes daily VWAP per ticker."""
return trades_df.groupBy("trade_date", "ticker").agg(
(F.sum(F.col("price") * F.col("volume")) / F.sum("volume")).alias("vwap"),
F.sum("volume").alias("total_volume"),
F.first("price").alias("open_price"),
F.max("price").alias("high_price"),
F.min("price").alias("low_price"),
F.last("price").alias("close_price")
)
def compute_rolling_volatility_and_sharpe(daily_returns_df, risk_free_rate: float = 0.045):
"""
Computes 30-day rolling annualized volatility and Sharpe ratio.
Annualization factor for trading days: sqrt(252).
"""
window_30d = Window.partitionBy("portfolio_id").orderBy("trade_date").rowsBetween(-29, 0)
metrics_df = daily_returns_df.withColumn(
"daily_return",
(F.col("nav") - F.lag("nav", 1).over(Window.partitionBy("portfolio_id").orderBy("trade_date"))) /
F.lag("nav", 1).over(Window.partitionBy("portfolio_id").orderBy("trade_date"))
).withColumn(
"mean_daily_return", F.avg("daily_return").over(window_30d)
).withColumn(
"std_daily_return", F.stddev("daily_return").over(window_30d)
).withColumn(
"annualized_volatility", F.col("std_daily_return") * F.lit(math.sqrt(252))
).withColumn(
"annualized_return", F.col("mean_daily_return") * F.lit(252)
).withColumn(
"sharpe_ratio",
(F.col("annualized_return") - F.lit(risk_free_rate)) / F.nullif(F.col("annualized_volatility"), 0)
)
return metrics_df
2. Global Investment Banking Market Data Platform Blueprint
Production BlueprintBelow is the production blueprint powering real-time equity/ETF feeds, automated NAV reconciliation, and compliance reporting based on Pranay Sarode's 9-stage architecture.
Lab 03: Multi-Asset Portfolio NAV & Drawdown Engine
Ingest Daily Closing Prices & Positions
Extract daily closing market prices for a portfolio of 50 equities and ETFs via Yahoo Finance / Alpha Vantage API into S3.
Reconcile Corporate Actions & Splits
Check for stock splits and dividend declarations; apply backward price adjustment multipliers to maintain continuous return series.
Compute Portfolio NAV & Asset Allocation
Using PySpark, calculate daily total portfolio NAV, cash ratio, equity weighting percentages, and high-water mark.
Generate Risk Report
Output maximum drawdown, 30-day volatility, and Sharpe ratio tables, exporting results to a Power BI / dashboard-ready view.
3. Financial Data Engineering Interview Questions
Capital Markets Prep
Answer: Backtesting requires bi-temporal data modeling. You must track two distinct timestamps:
1. event_time: The historical timestamp when the market event or financial filing period ended (e.g. Q2 2026 ended on June 30).
2. knowledge_time: The exact moment our data system actually learned of the data (e.g. SEC 10-Q filing published on August 8 at 16:05).
A backtest as-of July 15 must filter strictly on knowledge_time <= '2026-07-15'. Using Q2 numbers before August 8 introduces fatal
lookahead bias, leading to unrealistic backtest performance that collapses in live production.
Answer: On Trade Date (T), an order executes, establishing contractual obligation. On Settlement Date (T+1), legal ownership of shares and cash transfer occurs via the clearinghouse (e.g. DTCC). In data engineering, pipelines must maintain dual position balances: Trade-Date Positions (used by portfolio managers for active trading decisions and market exposure) and Settled Positions (used by custody, accounting, and compliance to calculate collateral, cash interest, and regulatory leverage).
4. Related Tracks
Explore Next🌊 Streaming
Kafka tick streams, broker partitioning, and Spark Structured Streaming.
Go to Streaming →🏛️ Data Platforms
Kimball star schema for trade analytics, Delta Lake time travel, and Snowflake.
Go to Data Platforms →🤖 AI / ML
Quantitative feature engineering, price prediction, and financial MLOps.
Go to AI / ML →⚡ Engineering
Python API ingestion, SQL window functions, and PySpark skew mitigation.
Go to Engineering →