pandas, Polars and DuckDB all have an as-of join; it isn't q's secret. What's different in q: aj is two primitives you already know. group finds each symbol's rows once; bin finds the latest quote at or before each trade. Ties, early trades and unknown symbols all fall out of those two. The price is a sort that bin trusts and never checks: drop it and, on the lesson's data, you get a different table, silently.
Article 3 of 5: https://nandan.me/writing/the-as-of-join/