TradeViora AcademyLearn. Analyze. Practice. Trade Smarter.
Menu

FREE FINANCIAL EDUCATION

Event-driven and vectorized reconciliation

Match a vectorized return calculation to an explicit event-processing convention.

0%

What you will learn

Prerequisites: Track cash, positions and price changes over discrete intervals.

Mechanism and decision rules

An event-driven engine updates state as data, decisions, orders and fills occur. A vectorized calculation can represent the same simplified model, but only when its array alignment reproduces those transitions. Define whether a target position belongs to the interval starting at a timestamp or the one ending there. Multiplying a newly chosen position by a return that has already occurred creates a different, potentially noncausal model.

The following tape assumes all target decisions were available before their stated boundary quote, immediate fills at that supplied quote, fixed share counts, no costs and no orders at the final boundary. It is a bookkeeping test, not a realistic live fill assumption. For interval i, vectorized P&L is target shares during that interval times the price change from its start to its end. An independent cash-and-holdings replay should reach the same equity and exposure path.

Worked example · synthetic data

Hypothetical boundary prices are 100, 110, 99 and 108.9. Targets for the three following intervals are 0, 1 and 0 shares. Vectorized P&L is 0×10+1×(−11)+0×9.9=−11. Starting with cash 1,000, the event replay buys one share at 110 and sells it at 99, ending flat with cash 989. The first interval’s gain of 10 occurred while the target was zero. Assigning the later one-share target to that earlier interval would credit a gain the stated strategy did not hold exposure to earn.

Failure modes and limits

Agreement on final profit alone is weak: two errors can cancel. Compare cash, quantity, fills, fees and marked equity after each event, including warm-up and final-boundary behavior. A vectorized approximation may not express partial fills, concurrent orders or stateful margin logic. When those features matter, keep the event model as the specified reference rather than forcing the two implementations to agree by deleting inconvenient events.

Practice case

Use new boundary prices 50, 55, 52 and 54, with interval targets 1, 1 and 0 shares. Initial cash is 500 and all earlier toy assumptions remain. Calculate vectorized P&L and replay the necessary buys and sells. Explain whether a trade is needed at the middle boundary where the target remains one share.

Reveal the worked answer

Vectorized P&L is 1×5+1×(−3)+0×2=+2. Buy one share at 50, leaving cash 450; retain it at 55; sell at 52, ending flat with cash 502. No trade is needed at the unchanged one-share target. Treating a persistent target as a fresh purchase at every boundary would accumulate an unintended second share and violate the target-position model.

Check your understanding

Which position earns an interval’s price change?


Explanation

Array alignment must match the event timeline and information availability.

What is worked terminal cash?


Explanation

Buying at 110 and selling at 99 produces a loss of 11.

Does a repeated one-share target require another one-share purchase?


Explanation

Targets specify desired total holdings; orders implement only the difference from current holdings.

Sources and next steps

The lesson, calculations and synthetic cases are original educational material. References explain underlying contract or chart conventions; none validates the profitability of a trading rule. Actual contract specifications, settlement obligations and charges must be checked before trading.

Explore OHLCV data in the chart lab · Explore volume-at-price and TPO data · Practice library