RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Whitepapers · Riptide · Quantitative finance

Exact tick data: market data as small integers

Prices are counted in ticks and sizes in lots, so most market-data arithmetic has one exact integer answer. This paper measures what it costs to get that answer on every machine, against the best C we could write, including hand-written vector intrinsics, and against the usual Python tools.

Version
1.2 (updated 1 December 2026: limitations section retitled; added "Reproduce it yourself")
Date
1 December 2026
Author
Samario Torres, Riptide
Software
Raya main (1 December 2026, the build measured in "Plain Raya integer loops, faster than C"); gcc 13.3.0 and clang 18.1.3 at -O3 -march=native; Python 3.12.3 with NumPy 2.5.5, pandas 3.1.2, polars 2.2.0, numba 0.68.1, SciPy 1.18.1
Download PDFOpen in new tabriptidecompute.com/whitepapers/exact-tick-data

Abstract

On 1 December 2026 Riptide ran six market-data computations on three AWS server CPUs, one thread each, with every input held as integers: prices in ticks, sizes in lots, counts as counts. Each computation was written once as plain Raya loops and measured against plain C, against a C twin of the same byte-limb reformulation Raya uses, against hand-written C vector intrinsics (Arm UDOT/USDOT, AVX-512 VNNI), and against NumPy, pandas, polars, numba and SciPy at their fastest settings. The data are a seeded synthetic data set built to the shapes of real exchange data (random-walk ticks, log-normal lot sizes, Poisson trade arrivals). Every exact implementation, on every CPU, returned the same 64-bit checksum of every output (378 runs, one checksum per case).

Lead–lag correlation. Cross-products of trade counts over 8,640,000 bins of 10 ms ran 2.7–4.1× faster than plain C at 1,024 lags and 1.7–3.1× at 256 lags. Against hand-written intrinsics that share every tap load across 8 lags, plain Raya was 0.94–1.10× as fast at 1,024 lags (a tie), but 0.41–0.83× at 256 lags and 0.19–0.30× at 32 lags. At 1,024 lags it was 2.4–5.1× faster than SciPy's FFT correlation.

P&L distributions, VaR and expected shortfall. The exact distribution of a 2-asset and a 4-asset portfolio's one-minute P&L, built as products of count polynumbers, took 0.014–0.24 ms in plain Raya on the synthetic histograms, 1.1–2.9× faster than the best of plain C and a C byte-limb twin (no intrinsics version was written for this case). For 4 assets this times the final product of the two pair products, which are built once during data preparation. Splitting the counts into byte limbs took 1.1–1.9× as long as the product for 2 assets and 37–70% of it for 4 assets; including it, Raya was 0.62–1.30× the best C's speed. VaR and expected shortfall at 97.5% come out as exact rationals; Monte Carlo with 10 million draws took 1.19–1.32 s and its expected shortfall was off by 0.042–0.044% (median of 10 seeds), up to 0.11%.

Where float goes wrong. Over 200,000 sampled windows, the float64 rolling variance was correctly rounded on under 1% of windows by every float method measured: pandas, polars, prices relative to a reference, Welford's update and a two-pass computation per window. Their worst errors ranged from 7.9 × 10⁻¹³ (polars on relative prices) to 2.3 × 10⁻³ (pandas on absolute prices). The exact path is integer sums and one division.

Where Raya is not faster. Hand-written intrinsics beat plain Raya for weighted volume at price at every window (0.44–0.81×), and Raya's byte-limb split for that case was slow enough to dominate. Rolling window sums ran at 0.17–0.51× of C and top-of-book features at 0.30–0.96×; numba and polars on 64-bit integers were faster than Raya on both. SciPy's FFT built the 4-asset P&L distribution 1.7–3.6× faster than Raya, but only 41–47% of its counts were exact.

The numbers in this paper are from the synthetic data set. The same tests were also run on public exchange data (Binance Vision [8], licensed for non-commercial use, so its measurements are not published here): every exact implementation gave the same checksums, the lead–lag and volume-at-price ratios were similar, and on the P&L products plain Raya was behind the best C on Graviton4 and Zen 4 and the FFT's lead was larger.

What this lets you do

  • Get one answer on every machine. Integer ticks and lots, integer sums and one division at the end give the same VWAP, variance, smoothed volume, correlation and risk number on Arm and x86, in C, Raya, NumPy or numba.
  • Write the loop plainly and get vector speed. Plain Raya loops were 1.7–4.1× faster than the same loops in plain C for lead–lag at 256 and 1,024 lags, and matched hand-written intrinsics at 1,024 lags, without intrinsics in the source.
  • Read VaR and expected shortfall from an exact distribution instead of estimating them. For independent legs, the product of their P&L polynumbers is the portfolio's distribution; the tail is read from its coefficients, with no sampling noise.
  • Know which windows your float pipeline gets wrong. Every float variance method measured missed the correctly rounded value on nearly every window; the size of the miss ranged over nearly ten orders of magnitude depending on the method.
Bar chart of plain Raya's speed relative to the best C implementation measured (plain C, a byte-limb C twin or hand-written intrinsics, whichever was fastest) for eleven market-data cases on AWS Graviton4, Intel Sapphire Rapids and AMD EPYC Zen 4. Lead–lag at 1,024 lags is 1.10×, 0.97×, 0.94×; at 32 lags 0.30×, 0.19×, 0.28×; P&L for 2 assets 1.71×, 2.93×, 1.60×.
Figure 1. Plain Raya against the best C measured on each CPU (log scale). Above 1× Raya is faster. Lead–lag and depth are compared with hand-written intrinsics; P&L with plain C and the byte-limb twin; rolling and book with plain C.

Results

Lead–lag cross-correlation

The question a lead–lag study asks: when one instrument trades, how many trades of the other follow, bins later? With and the trade counts per 10 ms bin over one day (8,640,000 bins), the exact cross-products are for . In the synthetic data the two arrival streams are independent, so this is a speed and exactness test, not a lead–lag finding.

Table 1. Lead–lag cross-products over one day, milliseconds per call, one thread. "Best C" is the fastest of the C columns (gcc or clang); the limb split is reported separately and not included in the Raya column.
LagsCPURayaRaya limb splitPlain CC byte-limb twinC intrinsicsC intrinsics, 8 lags per passSciPy autoSciPy FFTRaya vs best CRaya vs plain C
32Graviton437.49.3250.937.031.511.127.97680.30×1.36×
32Sapphire Rapids35.86.0932.949.847.56.9056.51,1510.19×0.92×
32EPYC Zen 425.97.1034.423.524.67.1690.09730.28×1.33×
256Graviton41059.3332229525086.72237760.83×3.06×
256Sapphire Rapids1306.1122239737953.84521,1520.41×1.71×
256EPYC Zen 490.27.1116219320757.27209600.63×1.79×
1,024Graviton43149.321,2911,1629993447717671.10×4.11×
1,024Sapphire Rapids2246.149261,6181,5422181,1541,1490.97×4.13×
1,024EPYC Zen 42437.116477738002299719640.94×2.67×

SciPy's auto method chose direct summation in float64 at 32 and 256 lags and the FFT at 1,024 lags; with these small counts every float64 result rounded to the exact integer. On Graviton4 SciPy auto was faster than plain Raya at 32 lags (27.9 against 37.4 ms).

Weighted volume at price

The trades, summed by price tick, form a polynumber : the coefficient at tick is the traded volume at that price (5,799 ticks wide, up to 11,053,344 lots at one tick). A centred triangular smoothing with int8 weights that peak at the middle of the window gives .

Table 2. Weighted volume at price, milliseconds per call. "incl. split" adds the time to split into byte limbs to Raya's time.
WindowCPURayaRaya limb splitPlain CC byte-limb twinC intrinsicsC intrinsics, 8 outputs per passnumbaSciPy autoRaya vs best Cincl. split
16 ticksGraviton40.02770.1920.01930.02210.0170.01220.01960.09380.44×0.06×
16 ticksSapphire Rapids0.02330.1820.0220.03010.01990.01120.02210.05550.48×0.05×
16 ticksEPYC Zen 40.02160.1870.01450.02890.0170.01130.01410.04850.52×0.05×
64 ticksGraviton40.03990.1930.07480.04350.03730.02040.0750.1320.51×0.09×
64 ticksSapphire Rapids0.03190.180.08140.02970.02980.02590.07430.06520.81×0.12×
64 ticksEPYC Zen 40.03160.1860.05610.0250.0240.02150.06090.07830.68×0.10×
256 ticksGraviton40.08620.1920.290.1290.1090.06680.2870.3080.77×0.24×
256 ticksSapphire Rapids0.06540.180.3230.06130.04530.03620.3250.1470.55×0.15×
256 ticksEPYC Zen 40.07020.1860.2280.05610.05510.040.2070.1590.57×0.16×

P&L distribution, VaR and expected shortfall

Each leg's one-minute P&L over 44,640 minutes (positions of 10 BTC, 300 ETH, 6,000 SOL and 1,000 BNB, worth $0.90–0.96 million each at the start) was binned once to $10 and counted, giving one polynumber of counts per leg. Assuming the legs are independent, the portfolio's P&L distribution is the product of those polynumbers. The 4-asset product is (BTC × ETH) × (SOL × BNB); only the final product is timed, because the two pair products are built once during data preparation; its counts sum to 44,640⁴ = 3,970,971,258,716,160,000 (every combination of four minutes), below 2⁶³.

Table 3. Building the exact P&L distribution, milliseconds per call (for 4 assets, the final product of the two precomputed pair products). No intrinsics version was written for this case.
PortfolioCPURayaRaya limb splitPlain CC byte-limb twinnumbaSciPy direct (int64)SciPy FFTFFT counts exactRaya vs best Cincl. split
BTC + ETHGraviton40.02560.02840.05280.04370.04910.1530.0494100.0%1.71×0.81×
BTC + ETHSapphire Rapids0.01420.02630.04970.04160.05030.1350.05100.0%2.93×1.03×
BTC + ETHEPYC Zen 40.01820.02850.0290.03280.0330.1860.0434100.0%1.60×0.62×
4 assetsGraviton40.2380.0880.2980.6580.2730.7050.066746.5%1.25×0.92×
4 assetsSapphire Rapids0.1170.0820.2570.7130.2730.6260.067440.7%2.21×1.30×
4 assetsEPYC Zen 40.1490.08770.1630.5270.190.8790.057640.7%1.10×0.69×

The exact 97.5% VaR and expected shortfall are $1,900 and $2,270.23 for BTC + ETH and $3,050 and $3,647.28 for the 4-asset portfolio. SciPy's FFT counts for 4 assets were off by up to 6, and differed between Graviton4 and the two x86 CPUs, but the expected shortfall computed from them matched the exact value to about 1 part in 10¹⁴. SciPy's auto method chose direct float64 summation for this case; its counts were exact on Graviton4 and 97.4% exact on the x86 CPUs, where the largest sums pass 2⁵³.

Table 4. Monte Carlo against the exact distribution (independent draws per leg; the standard empirical estimator, the mean of the largest 2.5% of losses; 10 seeds; AWS Graviton4).
PortfolioDrawsTime (median)ES error, median of 10 seedsES error, worst seedVaR across seeds
BTC + ETH1 million122 ms0.09%0.20%$1,890–1,900
BTC + ETH10 million1.19 s0.04%0.11%$1,900
4 assets1 million134 ms0.10%0.21%$3,040–3,050
4 assets10 million1.32 s0.04%0.11%$3,050

Rolling VWAP and variance

Over 2,000,000 trades, each window of trades needs , , and ; VWAP and variance follow from them.

Table 5. Rolling window sums, milliseconds per call (all four sums and the variance numerator). Rolling sums are not a kernel shape, so the two Raya runs (kernels on and off) execute the same code; their times varied by up to 2× between runs and the faster is shown.
WindowCPURayaFaster Cnumbapolars (Int64)NumPy cumsumpandas (float64)polars (float64)Raya vs C
100 tradesGraviton411.65.675.766.8832.012060.30.49×
100 tradesSapphire Rapids12.16.086.3611.651.816741.70.50×
100 tradesEPYC Zen 425.54.805.097.3223.412844.50.19×
1,000 tradesGraviton411.75.416.096.9032.012060.90.46×
1,000 tradesSapphire Rapids12.26.226.5312.151.415942.10.51×
1,000 tradesEPYC Zen 430.75.374.697.3323.013045.60.17×
Table 6. Rolling variance in float64 against the exact value correctly rounded (200,000 sampled windows; errors relative to the exact value). The shares are identical on all three CPUs and the worst errors agree to at least 6 significant digits.
MethodTime, 100 trades (ms)Variance not correctly rounded, 100 / 1,000 tradesWorst variance error, 100 / 1,000 trades
pandas rolling().var(), absolute prices120–167100% / 100%2.3 × 10⁻³ / 1.3 × 10⁻⁴
polars rolling_var, absolute prices41.7–60.3100% / 100%2.0 × 10⁻⁹ / 1.8 × 10⁻⁹
pandas, prices relative to the first trade32.2–39.599.999% / 99.999%3.0 × 10⁻⁷ / 3.3 × 10⁻⁸
polars, prices relative to the first trade34.4–46.499.375% / 99.496%7.9 × 10⁻¹³ / 8.8 × 10⁻¹³
Welford, add/remove updates (numba)4.54–5.11100% / 100%7.4 × 10⁻⁴ / 1.6 × 10⁻⁴
Two-pass per window (numba)225–29199.999% / 99.997%2.0 × 10⁻¹⁰ / 2.0 × 10⁻¹¹
Exact integer sums, one division (C)4.80–6.080% / 0%0 / 0
Two bar charts for 100-trade windows. Left: the share of windows where each float64 variance method does not return the correctly rounded value, 99.375% for polars on relative prices and 99.999–100% for the others. Right: the worst relative error on a log scale, from 7.9 × 10⁻¹³ (polars, relative prices) to 2.3 × 10⁻³ (pandas, absolute prices).
Figure 2. Rolling variance in float64, six methods, against the exact value correctly rounded.

The float64 VWAP was not correctly rounded on 93.1% of 100-trade windows and 47.4% of 1,000-trade windows, in both pandas and polars, with worst errors of 3.5 × 10⁻¹⁵ and 4.3 × 10⁻¹⁶. pandas' rolling var keeps running sums and updates them as each value enters and leaves the window; on absolute prices the variance is a small difference of large sums, which is where it loses digits (the classical analyses are Welford [2], Chan, Golub and LeVeque [3] and Higham [7]). Subtracting a reference price and computing each window twice both shrink the error; neither makes the result correctly rounded. The two-pass method was also the slowest, 2.3–3.2 s per call for 1,000-trade windows.

Top-of-book features

For each of 20,000,000 best-bid/offer updates: the queue-imbalance numerator and denominator (, ), the microprice numerator , and the spread . Every value fits well inside 2⁵³, so one float64 division of the numerator by the denominator is already correctly rounded; this case is about speed, not exactness.

Table 7. Top-of-book features, milliseconds per call (Raya: the faster of two identical runs).
CPURayaFaster Cnumbapolars (Int64)NumPypandas (Int64)Raya vs C
Graviton411139.437.528.474.180.30.35×
Sapphire Rapids98.594.595.084.42702960.96×
EPYC Zen 413239.533.853.090.91000.30×

Method

Everything below is computed in integers and is exact by construction; each step states the bound that keeps it inside 64 bits.

  1. Integers once. Prices are converted to ticks (0.01 for spot trades, 0.1 for the book), sizes to lots, each conversion checked to land on the grid. No floating point touches the data after that.
  2. Rolling sums. Running sums over the window add the newest trade and subtract the one leaving. Prices are taken relative to the first trade, so and the variance numerator stay below 2⁶³; the exact variance is that numerator over , and the exact VWAP is , a rational. One division at the end gives the correctly rounded float64 if one is needed.
  3. Lead–lag as an FIR. The cross-products are an FIR filter loop with one instrument's counts as 16-bit taps and the other's as the signal. The signal is split into two byte limbs, , and two byte-FIR passes give , exact in 64 bits. The non-synchronous lead–lag literature (Hayashi and Yoshida [5]) works on the same cross-products; the FFT route is the Cooley–Tukey transform [4].
  4. Volume at price. is split into byte limbs (three here, since ), each limb is filtered by the int8 weights, and the results are shifted and added. The true sums are below 2⁶³, so the 64-bit sum is exact.
  5. P&L distributions as polynumber products. Each leg's histogram of binned P&L is a polynumber of counts; the product of two such polynumbers counts every pair of outcomes, so it is the distribution of the sum under independence, the same convolution Panjer's recursion [6] evaluates for aggregate losses. The counts are split into byte limbs and each limb pair is one byte polynumber product; the results are shifted and added. VaR and expected shortfall at 97.5% are read from the exact counts with the discrete form of Acerbi and Tasche [1], including the fractional share of the bin at the quantile, as exact rationals.
  6. The compiler. Plain Raya compiled ahead of time recognises the FIR loop and the byte polynumber product and runs a kernel chosen for the CPU (Arm UDOT/USDOT on Graviton4; AVX-512 VNNI VPDPWSSD and VPDPBUSD on the x86 CPUs), as described in "Plain Raya integer loops, faster than C". The run trace confirmed a kernel ran for every lead–lag, depth and P&L case. Rolling sums and book features are not kernel shapes. The byte-limb split is done in plain Raya before the timed loop and timed separately.
  7. The C baselines. Plain C is the same loop on int64. The byte-limb twin is the same reformulation as Raya's, written as plain C on uint8 limbs with int32 accumulators flushed to int64 inside a proven bound, so gcc and clang can vectorise it themselves. The intrinsics versions are hand-written: lead–lag splits the int16 taps into an unsigned low byte and a signed high byte and uses UDOT and USDOT on Arm, or uses VPDPWSSD on 16-bit pairs on x86; depth uses USDOT or VPDPBUSD. Each has a register-blocked form in which 8 lags (or 8 outputs) share every tap (or weight) load. All C versions are compiled with gcc and with clang and checked against the plain loop's checksum before timing.
  8. The Python baselines. NumPy, numba and SciPy direct summation on int64 are exact; SciPy auto and the FFT run in float64 and their results are compared with the exact values. The float variance baselines are pandas and polars on absolute and on reference-relative prices, Welford's add/remove update and a two-pass computation per window (numba).
  9. Checking. Every exact implementation prints a wrapping 64-bit checksum, folded across output arrays; all of them agreed on every case and CPU. Float results are compared with exact values computed in Python integers and fractions.

Setup

  • Machines: AWS EC2 us-west-2, one thread each: c8g.2xlarge (AWS Graviton4, Neoverse V2), c7i.2xlarge (Intel Xeon Platinum 8488C, Sapphire Rapids), c7a.2xlarge (AMD EPYC 9R14, Zen 4). Ubuntu 24.04.
  • Compilers: gcc 13.3.0 and clang 18.1.3 at -O3 -march=native.
  • Python: 3.12.3 with NumPy 2.5.5, pandas 3.1.2, polars 2.2.0, numba 0.68.1, SciPy 1.18.1 (recorded on each machine).
  • Timing: best of 5 blocks of at least 60 ms per call; Monte Carlo timed per run (median of 10 seeds). The weighted-volume group on the two x86 CPUs was rerun in one later session on the same machines so that every column of that table comes from one session.
  • Data: the synthetic set has 2,000,000 trades for the rolling case, two independent Poisson arrival streams for lead–lag, 20,000,000 book updates and four random-walk minute price series of 44,641 closes; it is seeded and reproducible.
  • Cost: about $2 of EC2 time for the runs reported here.

Limitations and next steps

The limits of these results, each with its cause and, where one is planned, the next step.

  • Lead–lag at 32 and 256 lags: 0.19–0.30× and 0.41–0.83× of hand-written intrinsics. Cause: under investigation. The hand-written version shares every tap load across 8 lags; whether the compiler's kernel does the equivalent at small lag counts is being checked.
  • Weighted volume at price: 0.44–0.81× of hand-written intrinsics, and 0.05–0.24× including the limb split. Cause: the register-blocked intrinsics share each weight load across 8 outputs; and the byte-limb split is written in the benchmark as general list-building code that allocates, which costs more than the filter itself.
  • Rolling window sums: 0.17–0.51× of C; numba and polars on Int64 were also faster than Raya. Cause: a running sum is not a kernel shape, so Raya's own code generator runs it, and its 64-bit scalar loops are slower than gcc's, clang's and LLVM's (numba); why EPYC Zen 4 is slowest is under investigation.
  • Top-of-book features: 0.30–0.96× of C; polars on Int64 was the fastest implementation on Graviton4 and Sapphire Rapids, and numba matched or beat C. Cause: element-wise 64-bit arithmetic is not a kernel shape.
  • numba beat Raya on rolling sums, book features and the 16-tick volume window. Cause: numba compiles through LLVM, as clang does; those cases run in Raya's own code generator, not a kernel.
  • P&L: the byte-limb split is costly (1.1–1.9× the product for 2 assets, 37–70% of it for 4 assets). Including it, Raya was 0.62–1.30× of the best C. No intrinsics C version was written for this case, so the comparison is against plain C and the byte-limb twin only. Cause: the split is the same general list-building code as above.
  • SciPy's FFT built the 4-asset P&L distribution 1.7–3.6× faster. Cause: an FFT costs against for the direct product. Only 41–47% of its counts were exact and they differed between CPU families, though the expected shortfall was unaffected at this size.
  • The fast path needs a Raya build. The kernels run only in ahead-of-time Raya programs; there is no Python binding yet, which is where most quant research happens. Cause: not built yet.
  • CPUs only. Cause: GPU batch versions of these computations were not part of this campaign.
  • Independence. The P&L product assumes the legs move independently; real portfolios need historical scenarios, which are exact integer sums in the same framework. Cause: not measured here.

Reproduce it yourself

Run kits/exact-tick-data from the public riptide-reproduce repository: one command, a few minutes on a laptop, public software only. It reproduces how often pandas, polars and two-pass float64 return the correctly rounded rolling variance, and exact lead–lag products against SciPy's FFT; the same exact sums in plain Raya 0.4.0 loops print the same checksums. Every baseline's value and its error against the exact answer are printed and saved to errors.csv, and the exact results print the same hash on every machine: if your float hash differs from ours or a colleague's, that is precision drift in your pipeline.

References

  1. C. Acerbi and D. Tasche, "On the coherence of expected shortfall", Journal of Banking & Finance 26(7), 2002, 1487–1503. doi:10.1016/S0378-4266(02)00283-2
  2. B. P. Welford, "Note on a method for calculating corrected sums of squares and products", Technometrics 4(3), 1962, 419–420. doi:10.1080/00401706.1962.10490022
  3. T. F. Chan, G. H. Golub and R. J. LeVeque, "Algorithms for computing the sample variance: analysis and recommendations", The American Statistician 37(3), 1983, 242–247. doi:10.1080/00031305.1983.10483115
  4. J. W. Cooley and J. W. Tukey, "An algorithm for the machine calculation of complex Fourier series", Mathematics of Computation 19, 1965, 297–301. doi:10.1090/S0025-5718-1965-0178586-1
  5. T. Hayashi and N. Yoshida, "On covariance estimation of non-synchronously observed diffusion processes", Bernoulli 11(2), 2005, 359–379. doi:10.3150/bj/1116340299
  6. H. H. Panjer, "Recursive evaluation of a family of compound distributions", ASTIN Bulletin 12(1), 1981, 22–26. doi:10.1017/S0515036100006796
  7. N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed., SIAM, 2002.
  8. Binance Vision public data, data.binance.vision (CC BY-NC-SA 4.0).

Working with Riptide

Riptide works with a small number of teams. Each engagement starts with 4 weeks inside your systems, learning how your models, data and infrastructure work. Only then does Riptide apply its software to them. Contact samario@riptidecompute.com or riptidecompute.com/evaluate.

Date and version

Version 1.2, 1 December 2026. Updated 1 December 2026: limitations section retitled. Updated 1 December 2026: added "Reproduce it yourself".