Why We Use Finite State Machines Instead of Neural Networks
Deep learning is powerful, but it's also opaque. Here's why we chose deterministic logic over black-box AI for systematic trading.
The Siren Song of AI
Everyone wants AI in their trading system. It's sexy. It's cutting-edge. It promises superhuman returns.
It's also completely wrong for systematic trading.
Don't get me wrong—I have a PhD in machine learning. I've published papers on deep reinforcement learning for portfolio optimization. I know the math.
And that's precisely why we don't use it at Evidfi.
The Problem with Neural Networks
Neural networks are universal function approximators. They can learn almost any pattern. But they come with fatal flaws for trading:
1. Unexplainable Decisions
# Black box
model.predict(market_data)
>>> array([0.87]) # Buy signal
# Why 0.87? 🤷
Good luck explaining to your investors (or regulators) why the model bought $50M of SPX futures.
2. Undefined Behavior
What happens when:
- The market enters a regime not in your training data?
- A flash crash occurs?
- Your model sees NaN values?
Nobody knows. Not you, not the model, not even the researchers who built it.
3. Training-Serving Skew
Your model was trained on historical data with:
- Specific market regimes
- Particular volatility ranges
- Known correlations
What happens when those assumptions break? The model breaks.
Enter Finite State Machines
A finite state machine (FSM) is:
- Deterministic: Same input → Same output, always
- Auditable: Every transition is logged
- Bounded: Limited states → Predictable behavior
- Testable: You can enumerate every possible path
Here's Optophi's core FSM:
IDLE ──vol_compression──> ACCUMULATE ──position_filled──> MONITORING
↑ │
│ │
└────position_closed────< UNWIND <──exit_signal─────────────┘
A Real Example
Let's walk through a trade:
State: IDLE
Input: Vol compression detected (realized vol < 10th percentile)
Logic:
if (vol < threshold && correlation_regime === "stable") {
if (risk_checks_pass() && liquidity_adequate()) {
transition_to(ACCUMULATE);
}
}
Why this works: Every condition is explicitly checked. No hidden layers, no activation functions, no mystery math.
State: ACCUMULATE
Input: Order fills coming in
Logic:
while (position < target && market_open) {
if (slippage > max_slippage || volatility_spike()) {
abort();
transition_to(IDLE);
}
continue_accumulating();
}
transition_to(MONITORING);
Why this works: We know exactly when to abort. No "confidence scores" or "model uncertainty."
State: MONITORING
Input: Real-time market data
Logic:
if (vol_expansion() || stop_loss_hit() || time_exit()) {
transition_to(UNWIND);
} else if (contract_violation()) {
emergency_exit();
transition_to(IDLE);
}
Why this works: Every exit condition is pre-defined and tested. We've simulated thousands of scenarios.
Comparing Approaches
| Neural Network | Finite State Machine |
|---|---|
| "The model says buy" | "Vol < 10th percentile AND correlation stable AND risk checks pass" |
| Can't explain why | Every decision is auditable |
| Undefined on new data | Defined for all inputs |
| Requires retraining | Logic updates are explicit |
| Black box | Glass box |
But What About Alpha?
"If FSMs are so simple, how do you generate alpha?"
The alpha isn't in complexity—it's in correctness.
Our edge comes from:
- Better data (validated through contracts)
- Better execution (deterministic, low-latency)
- Better risk management (no undefined behavior)
We're not trying to predict the future. We're engineering a system that behaves correctly in all futures.
The Philosophical Difference
Traditional quant:
"Train a model to predict returns. Hope it generalizes. Pray it doesn't blow up."
Evidfi:
"Define the conditions for a trade. Verify those conditions hold. Execute atomically."
One approach is probabilistic. The other is programmatic.
Guess which one lets you sleep at night?
When ML Makes Sense
To be fair, we do use machine learning—just not for execution decisions:
- Feature engineering: PCA for dimensionality reduction
- Regime detection: Clustering for market states
- Data validation: Anomaly detection for bad ticks
But the final decision to trade? That's pure logic.
Conclusion
Deep learning has revolutionized computer vision, NLP, and game playing. But systematic trading isn't Go or ImageNet.
In trading:
- You can't retrain on production failures
- Explainability is regulatory requirement
- Undefined behavior costs real money
So we use the right tool for the job: deterministic logic in a finite state machine.
It's not sexy. It's not cutting-edge AI.
But it works.
Interested in our FSM implementation? Access our technical architecture docs or schedule a deep-dive session.
About the Author
Dr. Sarah Chen, Chief Technology Officer
Related Insights
Data Contracts: Why Type Safety Matters in Trading
Exploring how we apply software engineering principles to market data validation, eliminating a major source of systematic risk.
Jan 22, 2024 • 4 min readIntroducing Optophi: The Future of Systematic Trading
How we built a deterministic execution engine that replaces probability with proof in financial markets.
Jan 15, 2024 • 3 min read