Friday, October 16, 2026

Your Database remembers the wrong past

 Bitemporal data, backtests, and the importance of remembering what we knew.

IMAGINE A STORY: 

Arjun is a quantitative researcher. One Monday morning, he builds a model using a company's financial data. The backtest looks promising, and he's happy with the results.

A few months later, his team revisits the model. Someone asks a simple question:

“Would the model have made the same decisions if we'd run it back then?”

Arjun opens his database. The numbers look right. But something bothers him.

Let's rewind.

On April 15, his data vendor reports that a company earned ₹1,000 crore in annual revenue. Arjun's system picks up the number, and his model uses it on April 20.

On May 10, the vendor corrects the figure. The actual revenue was ₹950 crore.

Arjun updates the database. After all, why keep an incorrect number when you know the right one?

But now, when he tries to reproduce his April 20 backtest, the database gives him ₹950 crore.

That's not what his model saw back then.

His database knows the latest version of the truth, but it has forgotten its own past.


And Arjun has a problem. Did his model perform well because of a genuinely useful signal, or because the historical data now contains information that wasn't available at the time?

This is where a seemingly mundane database design decision becomes important.

In quantitative finance, we don't just need to know what a number is. Sometimes, we need to know when that number was true and when we knew about it.

The first is called valid time: the period to which a fact applies. The second is transaction time: when that fact entered our system and, eventually, when it was superseded.

Together, these form the foundation of bitemporal data storage.

For Arjun, preserving both timelines means he can retrieve the latest revenue figure while still reconstructing what his system knew on April 20. He can investigate old decisions, reproduce historical research, and reduce the risk of look-ahead bias.

Of course, bitemporal storage isn't free. It adds complexity, requires careful handling of historical versions, and consumes more storage. Not every application needs it.

But when your business depends on understanding the past accurately, deleting history can be a costly shortcut.

Arjun's mistake wasn't correcting a number. It was assuming that correcting the present meant rewriting the past.

Sometimes, the most important thing a database can remember isn't just what happened. It's what it knew when it happened.

A little about implementation

Technically, bitemporal storage can be implemented by maintaining four timestamps: valid_from, valid_to, system_from, and system_to. Each correction creates a new version of the record instead of overwriting the old one. The previous version is marked as superseded in system time, while its valid-time period can remain unchanged. This allows us to query both the latest accepted value and the version our system knew at a particular point in time.


Finance, Through an Engineer’s Eyes

I’m an engineer by profession, curious about finance, and currently working my way through the CFA curriculum. Somewhere along the way, I became fascinated by the intersection of these worlds: how financial systems work, what we often overlook about money, and how software can help solve problems that have existed in the industry for years.

This blog is where I explore those ideas.

Some posts will be about building software to solve practical problems in finance. Others will explore everyday financial concepts, common misconceptions, or interesting things I encounter while studying for the CFA. And occasionally, I’ll write about something that simply catches my attention.

I want to approach these topics through stories rather than textbooks. A problem I encountered, a question that bothered me, an idea that finally clicked, or a piece of software that made me see something differently. My hope is to make these subjects interesting, relatable, and perhaps a little easier to understand.

There are already excellent books, courses, and resources for learning finance. This blog isn't an attempt to replace them. It's a place to share my own journey of figuring things out, connecting ideas, and exploring what happens when an engineer looks at financial problems.

A note on writing: I use ChatGPT to refine the language and correct grammar in my posts. The experiences, ideas, and perspectives I share are my own; AI is simply a tool I use to communicate them more clearly.

Disclaimer: Everything here reflects my personal experiences, learning, and opinions. Nothing on this page should be taken as investment advice or a recommendation to buy or sell any financial instrument. Please do your own research and consult qualified professionals when making financial decisions.

If you're curious about finance, enjoy understanding how things work, or like seeing how technology can solve real-world problems, I hope you'll find something interesting here.

Your Database remembers the wrong past

  Bitemporal data, backtests, and the importance of remembering what we knew. IMAGINE A STORY:  Arjun is a quantitative researcher. One Mond...