Orderflow is a serious Python toolkit for market microstructure research, tick-data reshaping, backtesting, and PostgreSQL storage.
orderflow.corefor shared config, exceptions, and pathsorderflow.datafor ingestion and bar compressionorderflow.marketfor auctions, DOM, profiles, and market utilitiesorderflow.analysisfor statistics, regimes, and simulationorderflow.backtesterfor the backtest engine (BacktestEngine), exits and execution models (orderflow.backtestingis a legacy re-export)orderflow.storagefor database loaders and CLI entry pointsorderflow.visualizationfor plotting helpers
From the parent repo: pip install --no-deps -e vendor/Orderflow (editable — a plain install copies the
package into site-packages and your edits here stop reaching the runners). Tests: pytest tests/.
BacktestEngine.runpairs signal sides with entry ticks by position and raisesValueErroron duplicate signalIndex, a signalIndexmissing fromdata, signals out of tick order, or duplicatedataIndex— each used to shift every later trade onto the wrong side without an error.- The per-tick session functions of
volume_profile/vwap, the bar-id assigners ofcompressorandfind_stacked_imbalancesrun Numba kernels and keep their original Python loop beside them (_<name>_py,_compute_*_bar_ids_py,_detect) as the reference. Kernel and loop must stay bit-identical:tests/test_session_kernels.py,tests/test_bar_id_kernels.pyandtests/test_footprint_kernel.pycompare them on random tapes, so a behaviour change goes into both. A kernel only takes the input it is known to reproduce (the session functions: a pandas frame with a float64Price, an int64 or float64Volumeand stringSessionTypelabels); any other input runs the loop and returns, raises, prints and warns as it always did, in minutes instead of seconds on a full file. A kernel runs on a thread of its own, compilednogil(orderflow.core._kernel_calls.run_kernel), while the caller's thread moves the loop'stqdmbar and stays free for signals: Ctrl-C raisesKeyboardInterruptwithin milliseconds and the kernel stops. get_daily_session_moving_POC:Prev_POCis the POC of the session that just ended, whatever the gap (Sunday's session carries Friday's); 0 only on the first session of the frame.get_volume_profile_areas(VA_Areas): the first tick of the frame, and the first tick after each RTH→ETH reset, seed the POC; value-area expansion steps over zero-volume price levels. Labels arePO/VA/na(POisPOCtruncated by the 2-character label array).
