Convert Multi-Currency Payments to USD With As-Of FX Rates

Last updated: November 29, 2026

Quick Overview

Given a payments DataFrame (created_at, currency, amount_minor) and irregular FX rate snapshots (currency, effective_at, usd_per_unit), convert each payment using the latest rate at or before its timestamp and produce a daily total payment volume table in USD by currency.

PayPal
Data Manipulation (SQL/Python)
Data Engineer
PayPal
November 29, 2026
Data Engineer
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given a payments DataFrame (created_at, currency, amount_minor) and irregular FX rate snapshots (currency, effective_at, usd_per_unit), convert each payment using the latest rate at or before its timestamp and produce a daily total payment volume table in USD by currency.

Total payment volume is PayPal's headline metric and it is reported in USD across hundreds of currencies. The interviewer checks that you use an as-of join rather than an exact-date join, handle currencies with different minor-unit digits, and surface stale or missing rates instead of hiding them.

What the Interviewer Expects
  • Use merge_asof with by=currency and direction=backward
  • Sort both frames by their time keys before the as-of join
  • Convert minor units using per-currency decimal digits
  • Set a staleness tolerance and report payments without a rate
  • Pivot to day by currency with a total column
Key Topics to Cover
pandas merge_asof
time series joins
currency conversion
pivot tables
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Should finance use the rate at payment time or at settlement time?
  • How would you do the same as-of join in SQL?
  • How do you handle a currency that PayPal starts supporting midway through the period?
  • How would you reconcile this total with the ledger's own USD figures?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

amount_minor is an integer in each currency's minor unit: two decimals for most, zero for JPY, three for KWD. FX snapshots arrive at irregular times, not daily, so an exact join on date would miss o...

Approach

Split out USD, merge_asof the rest onto rate snapshots grouped by currency, looking backward for the latest snapshot at or before created_at, with a tolerance. Convert minor to major units by curr...


Submit Your Answer
Markdown supported

Related Questions