Building quantKit -- Why I'm diving deep into stochastic finance
From burnout to breakthrough: Why I'm building quantKit from scratch
Disclaimer: the following post is an organized representation of my research and project notes. It doesn't represent any type of advice, financial or otherwise. Its purpose is to be informative and educational. Backtest results are based on historical data, not real-time data. There is no guarantee that these hypothetical results will continue in the future. Day trading is extremely risky, and I do not suggest running any of these strategies live.
You know me - I hate vendor lock-in. I hate proprietary platforms that force you to think their way. And I really hate paying for tools that don't do exactly what I need them to do. So when I started working through "Stochastic Finance with Python" by Avishek Nag, it wasn't just academic curiosity. It was strategic.
I'm building quantKit because I want complete control over how I research and test trading strategies. But to build something truly useful, you need to understand the mathematical foundations that make quantitative finance actually work. That's where stochastic methods come in.
Of course, none of this excuses my radio silence recently. I have been a terrible content creator and a worse developer. I had so many things happen back to back that crushed my will and determination, planting me firmly in the "burn out" zone. Each time I thought everything was done, something else would happen. Then, when everything was done, I was too shot out to jump back into my work. My mind didn't want to focus, I couldn't force the work ethic, and I rapidly spiraled downward until I hit a ledge.
But it wasn't just exhaustion keeping me away. There's been this nagging feeling I can't shake - that most of the financial trading game is a setup. Like gambling, where the house is designed to win. Every platform wants their cut. Every data provider has restrictive agreements. Every backtesting engine forces you to think their way. And most retail traders? We're just playing at tables where we don't even know the real rules.
That's when the poker analogy really clicked for me...
The Fundamental Truth About Markets (And Poker)
Here's the thing everyone seems to forget: no one can predict the future. Full stop.
Think about Texas Hold'em. Any decent player can calculate basic probabilities like the odds of hitting your flush draw or the probability of pocket aces. But that's just the starting point. The real game is about updating those probabilities in real-time based on how your opponents bet, when they get aggressive, when they get conservative, how often they bluff.
You're not just playing the cards. You're playing probability distributions that constantly shift based on new information and opponent behavior patterns.
Markets work the same way. There is no deterministic behavior in markets with unknown futures. Yet most trading platforms, backtesting engines, and even machine learning approaches treat uncertainty as noise to be filtered out rather than the fundamental nature of what we're trying to model.
This is backwards. Market uncertainty isn't a bug — it's a feature. It's the entire reason opportunities exist in the first place. And maybe, just maybe, if we stop pretending we can eliminate uncertainty and start modeling it properly, we can start figuring out the real rules of the game. Not enough to get kicked out of the casino, but enough to get what we need and walk away.
What Makes Stochastic Finance Different
Most people think quantitative finance is just about crunching numbers. It's not. It's about modeling uncertainty in a way that gives you an edge, like poker players who understand that the math is just the foundation for reading the game.
Here's the thing that clicked for me while working through this material:
Traditional approaches assume you can predict exact outcomes. Stochastic methods assume you can predict probability distributions of outcomes that update based on new information.
That's a massive difference. Instead of asking "what will this stock be worth tomorrow?", you're asking "what's the range of possible values, how likely is each one, and how should I update these probabilities as new information comes in?"
In poker terms: you're not just calculating your hand's strength - you're constantly updating your read on the entire table based on betting patterns, position, and player tendencies. For anyone building trading systems, this is gold.
Markets are fundamentally nondeterministic systems. The same market conditions can produce different outcomes because there are always unknown factors influencing price discovery. Stochastic methods embrace this reality instead of pretending it doesn't exist.
Why This Matters for Strategy Development
When I look at my previous strategies (the momentum systems, the mean reversion plays, the volatility-based approaches), they all work because they capture some aspect of market uncertainty. But most backtesting platforms treat this uncertainty as noise to be filtered out rather than signal to be modeled.
It's like playing poker but only looking at your own cards and ignoring everything else happening at the table.
Stochastic finance gives you the tools to:
Model the randomness directly instead of pretending it doesn't exist
Quantify uncertainty in your forecasts (crucial for position sizing - your "bet sizing" in market terms)
Build systems that adapt to changing market conditions (reading the table)
Generate realistic scenarios for stress testing (playing against different opponent types)
Create synthetic data that captures multiple market regimes your historical data might miss
Take something as basic as calculating returns. Most platforms give you simple percentage returns and call it a day. But there's a reason quants prefer log returns: they have mathematical properties that make them much better for modeling and optimization. When you understand why these choices matter, you build better systems.
The Real Problem with Proprietary Platforms
Here's what really gets me: every backtesting platform makes assumptions about how you should model markets. RealTest assumes certain things about how you want to handle data. WealthLab has its own framework. Sierra Chart has its own approach. They're all good at what they do, but they're thinking for you.
It's like playing poker with someone else's strategy card that they won't let you modify.
Stochastic methods require you to think differently about fundamental concepts:
Deterministic vs. Nondeterministic Systems
Your simple interest calculation? Deterministic. Same inputs always give same outputs.
Stock prices? Nondeterministic. Same market conditions can produce different outcomes.
Most platforms are built for deterministic thinking. They want you to backtest as if the past will repeat exactly. Stochastic approaches assume the past gives you probability distributions, not exact forecasts.
What I'm Building: The Foundation That Actually Makes Sense
quantKit isn't trying to replace every trading platform. It's designed to give you the mathematical tools that most platforms ignore:
Proper uncertainty quantification - Instead of point estimates, get probability distributions
Multiple return calculation methods - Simple, log, multiperiod - each with different mathematical properties
Stochastic process modeling - Build systems that explicitly model randomness
Flexible data handling - Work with any data source without vendor restrictions
Realistic synthetic data generation - Create test scenarios based on actual stochastic processes
Probabilistic backtesting - Test against multiple probable futures, not just one historical path
Adaptive probability updating - Systems that adjust their "read" on market conditions in real-time
The goal isn't to create another black box. It's to give you transparent, mathematically sound tools that you can modify, extend, and understand completely.
Stochastic Methods + Machine Learning = The Future
Here's where this gets really interesting. Stochastic finance isn't competing with machine learning - it's providing the mathematical foundation that makes ML applications to finance more robust and realistic.
Think of it this way: basic poker probabilities are like traditional ML models. But the real edge comes from combining those probabilities with dynamic reads on opponent behavior, position, betting patterns, and meta-game considerations. That's what stochastic methods + ML gives you in trading.
For Simple Strategies:
Even an EMA crossover becomes more powerful when you can:
Generate probability distributions for future crossover events
Size positions based on confidence levels (your "bet sizing")
Test against thousands of statistically valid market scenarios
Adapt to changing market "player types" (trending vs. choppy markets)
For Advanced ML Applications:
Use stochastic processes as feature generators that capture market uncertainty
Train ML models on synthetically generated data that covers multiple market regimes
Build ensemble models where stochastic processes inform the base predictions
Get proper uncertainty quantification around your ML predictions
Create systems that update their "read" on market conditions just like a poker player adjusts to table dynamics
The Key Advantage:
Stochastic methods are less data hungry than pure ML approaches (crucial when clean financial data is expensive), more maintainable (you understand the mathematical relationships), and provide superior uncertainty quantification as a built-in feature rather than an afterthought.
Real-World Applications
Let me give you a concrete example. When I was developing Strategy 12 (the MES futures strategy with a profit factor of 2.03), I was essentially building a system that captured VIX/SPX relationship patterns using linear regression bands. But I was doing it intuitively, not mathematically.
With stochastic methods, you can:
Model the underlying stochastic processes directly using stochastic differential equations
Quantify the uncertainty around your entry and exit signals
Generate multiple scenarios to test your position sizing
Build adaptive systems that adjust to changing volatility regimes (different "table dynamics")
Train ML models on synthetic data that captures regimes your historical data missed
This isn't theoretical bullshit. These are practical tools that make your systems more robust.
The Learning Process
Working through this material has been eye-opening. Chapter 1 alone covers concepts that most trading platforms completely ignore:
Why randomness in markets isn't noise -- it's the fundamental nature of price discovery
How to think about financial instruments in terms of their stochastic properties
Mathematical frameworks for modeling uncertainty that actually work
The beautiful thing about building your own tools is that you understand every assumption being made. No black boxes. No "trust us, this works" algorithms. Just mathematical relationships you can verify and modify.
Where This Is Heading
I'm not abandoning everything else to become a pure quant. But understanding these foundations is making me a better system developer. When you know why log returns behave differently from simple returns, you make better choices about how to handle your data. When you understand the mathematical properties of different stochastic processes, you can design systems that are more aligned with how markets actually behave.
The crypto pivot I have been mentioning? That's partly about escaping restrictive data agreements, but it's also about having clean datasets to test these methods on. Crypto markets are perfect laboratories for stochastic methods because they're highly volatile, relatively new, and not constrained by traditional market structures.
The Bottom Line
Building quantKit isn't just about creating another backtesting tool. It's about building the first platform that properly integrates stochastic methods with modern machine learning techniques, giving users everything from simple probability-enhanced strategies to sophisticated ML systems built on sound mathematical foundations.
Most retail traders use tools built on these principles without understanding them. That's fine for some people, but I want to know exactly what's happening under the hood. More importantly, I want tools that acknowledge the fundamental truth about markets: they're uncertain by nature, and that uncertainty is where the opportunities live.
Just like in poker - the best players don't try to eliminate uncertainty. They embrace it, model it, and use it to their advantage.
If you're tired of being limited by what your platform thinks you should be able to do, this approach is worth considering. The math isn't insurmountable, and the tools you build will be exactly what you need them to be.
Plus, there's something deeply satisfying about solving problems with code that you actually understand, built on mathematical foundations that acknowledge reality instead of pretending it away.
Next week, I'll dive into the probability foundations and start showing some actual code. This is going to be a journey, but I think it's going to be worth it.
Happy hunting.
Feel free to comment below or email me if you need help with anything, wish to criticize, or have thoughts on improvements. You can also DM me or start a chat thread. Red Team members can access this code and more at the private HGT GitHub repo. As always, this newsletter represents refined versions of my research notes. That means these notes are plastic. There could be mistakes or better ways to accomplish what I am trying to do. Nothing is perfect, and I always look for ways to improve my techniques.