FX Tick Move-Occurrence & Regime-Adaptive Clustering
Research code accompanying the Larkin Research Limited working paper
“When, Not Which Way: Move-Occurrence Predictability, Directional Efficiency,
and Regime-Adaptive Clustering in Foreign-Exchange Tick Data” (Larkin & Larkin, 2026).
The code reproduces, from publicly downloadable Dukascopy tick data, every figure
and table in the paper. Three nested questions are studied on EUR/USD and GBP/USD
tick quotes:
- Move occurrence — can the occurrence of an imminent ≥5-pip move within 120 s
be predicted from the trailing 600 s window? (Yes: out-of-sample AUC ≈ 0.85.)
- Move direction — can its direction be predicted? (No: ≤ 0.53 AUC at causal
decision points; an instructive anchor-conditioning artefact gives a spurious 0.82.)
- Monetisation — is the timing signal tradeable direction-agnostically in spot?
(No: tick-accurate breakout straddles lose ≈ 0.35 pip/trade after spread.)
A fourth strand studies online clustering with exponential forgetting: the
prequential fit gain is proportional to the non-stationary (volatility) content of
the representation, replicated across both currencies.
Data
Tick data are not included (and are excluded by .gitignore). They are freely
and publicly downloadable from Dukascopy Bank SA’s historical feed. The scripts read
a local cache laid out as:
<CACHE>/<SYMBOL>/<year>/<month-1:02d>/<day:02d>/<hh>h_ticks.bi5
where the month directory is zero-indexed (June = 05) and each .bi5 is an
LZMA-ALONE stream of 20-byte big-endian records
(uint32 ms-in-hour | uint32 ask | uint32 bid | float32 askVol | float32 bidVol;
price = raw / 100000).
Point the code at your cache via an environment variable (default shown):
# Windows (PowerShell)
$env:DUKASCOPY_CACHE = "C:\path\to\DukascopyCache"
# Linux/macOS
export DUKASCOPY_CACHE=/path/to/DukascopyCache
If unset, it defaults to ~/AppData/Local/StrategySandpit/DukascopyCache.
Requirements
Python 3.9+, with:
pip install numpy scikit-learn matplotlib joblib
Pipeline
| Script |
Purpose |
capture_moves.py |
First-passage move (positive) event extraction; --symbol/--year/--month-dir/--side |
capture_negatives.py |
Non-overlapping no-move (negative) windows |
filter_split.py |
≥500-tick filter; split into price / volume vectors |
cluster_moves.py |
Bayesian GP-mixture clustering of move-window shapes |
classify_vector.py |
Posterior + no-match-gate classification against a saved model |
side_predict.py |
Side-pure occurrence discrimination (bid→bid, ask→ask) |
o2_confound.py |
Time-of-day confound controls (within-hour AUC) |
o3_grid.py / o3_aggregate.py |
Deployment-realistic 60 s grid evaluation; day-block bootstrap |
o1_straddle.py |
Tick-accurate direction-agnostic breakout-straddle simulation |
direction_features.py / o5_direction_grid.py |
17-feature direction battery (anchor vs grid frames) |
o4_directional.py |
Up-precursor-model directional test |
vol_cluster.py |
Volatility-feature regime clustering |
adaptive_classify.py |
Online GMM with exponential forgetting (prequential) |
regime_experiment.py |
Frozen-vs-adaptive α-sweep across pairs and representations |
make_figures.py |
Paper figures from regime_results.json |
discriminate.py, persistence.py, test_2023.py, test_prediction.py |
Earlier-stage discrimination / persistence tests |
A typical run: extract events → filter/split → cluster or discriminate → evaluate.
Most scripts are self-documenting (-h / module docstring). Random seeds are fixed
(seed 0); all evaluation is strictly out-of-sample with scalers fitted on training
data only and every feature computed from information available at the decision time.
Reproducibility & caveats
The data are public and the pipeline is deterministic, so results are independently
reproducible from source. Note the paper’s stated limitations: dealer-aggregated
(indicative) quotes rather than true order-book queues; spread-only costs; two
currency pairs over 2022–2023.
Licence
MIT — see LICENSE. © 2026 Larkin Research Limited.
This code is provided for research and verification. Nothing here constitutes
investment advice or a recommendation regarding any financial instrument.
评论