---
title: "Flex Model: an event-driven feature engineering system"
description: "Flex Model is Jane Street's OCaml framework that turns market events into feature vectors for neural-network trading models, replacing a 17k-line monolith where adding one feature touched nineteen files."
url: "https://swe.quest/articles/flex-model-an-event-driven-feature-engineering-system-b101b9ddf0c5a739"
canonical: "https://blog.janestreet.com/flex-model-an-event-driven-feature-engineering-system/"
source: "Jane Street Tech Blog"
published: "2026-10-13"
difficulty: "medium"
kind: "Case study"
reading_minutes: 13
tags: ["functional-programming","system-design","performance","machine-learning","memory-management"]
---

# Flex Model: an event-driven feature engineering system

A post on [Jane Street Tech Blog](https://swe.quest/sources/jane-street.md), published 2026-10-13, 13 min read, Case study. Original: [https://blog.janestreet.com/flex-model-an-event-driven-feature-engineering-system/](https://blog.janestreet.com/flex-model-an-event-driven-feature-engineering-system/)

## Summary

Flex Model is Jane Street's OCaml framework that turns market events into feature vectors for neural-network trading models, replacing a 17k-line monolith where adding one feature touched nineteen files. Incremental was rejected because its cutoffs and update coalescing silently drop history-dependent events. Flex Model instead splits each feature into per-event handlers that update state and eval functions that compute values on demand, giving up runtime graph changes to keep history inside the graph. A startup planner compiles feature dependencies into per-event-kind action lists run without cutoffs, avoiding unpredictable branches and letting teams add new event types without touching the core. The hot path is allocation-free, checked with \[@zero\_alloc\]. Unboxed floats from OxCaml cut tail latency by about 25% in one test replay.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Functional programming](https://swe.quest/tags/functional-programming.md) (Languages)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)

## Prerequisites

- OCaml basics ([easy posts on Functional programming](https://swe.quest/tags/functional-programming.md?difficulty=easy))
- incremental computation
- garbage collection basics ([easy posts on Memory management](https://swe.quest/tags/memory-management.md?difficulty=easy))

## Keywords

Flex Model, Jane Street, OCaml, OxCaml, Incremental, zero\_alloc

## Related posts

- [What the interns have wrought, 2023 edition](https://swe.quest/articles/what-the-interns-have-wrought-2023-edition-f070c30cff9e3c3e.md): Jane Street Tech Blog · 2023-09-12 · Medium · 9 min read · Functional programming, Observability, Developer tools, LLMs, Concurrency
  Three Jane Street intern projects, all in OCaml. The first is an SQL-like temporal query language, parsed with Angstrom and compiled onto a Linear Temporal Logic engine, for finding event sequences in Concord's transaction stream.
- [What the interns have wrought, 2022 edition](https://swe.quest/articles/what-the-interns-have-wrought-2022-edition-0f4dcf7e53f3e8d4.md): Jane Street Tech Blog · 2022-08-25 · Medium · 8 min read · Functional programming, Testing, Performance engineering, Developer tools, Engineering culture
  Three Jane Street intern projects from 2022 show substantial tooling work in OCaml. magic-trace gained a sampling mode that can cover 20 seconds to 20 minutes on Intel or AMD hardware, plus multi-process tracing, CPU-frequency transition reporting and a perf dlfilter backend that speeds trace decoding by 10–50%.
- [The Road to Component Model 1.0](https://swe.quest/articles/the-road-to-component-model-1-0-62b2bd7fd04e618c.md): Bytecode Alliance · 2026-06-08 · Hard · 11 min read · WebAssembly, Runtimes & VMs, Language design, Browsers
  Component Model 1.0 is planned around five workstreams: a lazy ABI that replaces cabi\_realloc-based eager allocation with opaque value handles and inlinable built-ins, native implementation in at least two browser engines, simpler implementation via guest and host C ABIs plus a component-smashing tool, ecosystem and tooling growth, and WIT expressivity features such as optional imports, callbacks, resource subtyping and a map type.
- [What the interns have wrought, 2025 edition](https://swe.quest/articles/what-the-interns-have-wrought-2025-edition-eda7f47e78fb3ca5.md): Jane Street Tech Blog · 2025-08-27 · Hard · 12 min read · Functional programming, Memory management, Query engines, Type systems, Performance engineering
  Jane Street's 2025 intern projects include an index-aware evaluator for JSQL, the company's internal SQL dialect, which over-approximates key ranges from WHERE clauses and specializes execution to Map, Hashtbl or multi-index containers, giving ~700x and ~30x speedups on 3.8M-row benchmarks.
- [Introducing TabFM: A zero-shot foundation model for tabular data](https://swe.quest/articles/introducing-tabfm-a-zero-shot-foundation-model-for-tabular-data-3b60f0bd6faee92a.md): Google Research · 2026-06-30 · Easy · 5 min read · Machine learning, Model training, Analytics & OLAP
  TabFM is a foundation model that treats tabular classification and regression as in-context learning, so it predicts on an unseen table in a single forward pass with no training, hyperparameter tuning or feature engineering.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
