Skip to content

AsOf Joins

Coral.AsOf provides point-in-time joins for ordered time-series data. Each row in the left frame is matched to the most recent prior (or equal) row in the right frame based on a sorted key column.

This is the standard "as-of" semantics used in financial tick alignment, sensor fusion, and any pipeline where observations arrive at irregular intervals and must be joined without lookahead.

module Coral.TradeQuoteAsOf
import Coral.AsOf (asof_join)
import Coral.Frame (from_columns)
import Coral.Io (read_parquet)
export (main)
def main() -> Frame = {
trades = read_parquet("trades.parquet")
quotes = read_parquet("quotes.parquet")
asof_join(trades, quotes, on: "timestamp")
}

The on parameter names the sorted key column. Both frames must be sorted on that column before the join.

  • direction: "backward" (default, most recent prior), "forward" (nearest future), "nearest".
  • tolerance: optional maximum distance between matched keys.
  • by: optional grouping columns for partitioned as-of joins (e.g., join within each ticker symbol).