Algo Strategy Design
From hypothesis to code: signal generation, execution logic, and state management.
Market makers, dark pools, HFT en hoe de markt echt werkt.
What Makes a Strategy "Algorithmic"?
An algorithmic strategy is a set of rules that can be expressed precisely enough for a computer to execute without human intervention. The key word is precisely - "buy when it looks bullish" is not algorithmic. "Buy when the 20 EMA crosses above the 50 EMA and RSI is above 50" is algorithmic.
Every algo strategy has three core components:
- Signal generation: What conditions trigger a trade?
- Execution logic: How is the trade placed? (Order type, size, timing)
- State management: What is the current position? What are the open orders? What's the P&L?
The Hypothesis-First Approach
Every strategy should start with a hypothesis about why it should work:
- Bad: "I'll use RSI and MACD because they're popular indicators."
- Good: "After a strong trend day, the market tends to mean-revert in the first hour of the next session. I'll fade the gap if it's larger than 1 ATR."
The hypothesis should describe a market behavior you're exploiting, not just a combination of indicators. Indicators are tools to measure the behavior - they're not the behavior itself.
Signal Generation
The signal module answers: "Should I be long, short, or flat right now?"
- Entry signals: Conditions that trigger opening a new position.
- Exit signals: Conditions that trigger closing an existing position (take profit, stop loss, time-based exit, signal reversal).
- Filter signals: Conditions that must be true for entry signals to be valid (e.g., "only trade during high-volume hours").
Execution Logic
The execution module translates signals into actual orders:
- Order type selection: Limit orders for better fills but risk of non-execution. Market orders for guaranteed fills but slippage.
- Position sizing: How much to allocate based on risk parameters.
- Order management: Cancelling stale orders, adjusting stops, scaling in/out.
- Timing: Execute immediately on signal? Wait for confirmation? Use TWAP (Time-Weighted Average Price) to spread execution?
State Management
State management is the most underestimated component. Your bot must always know:
- Current position (long, short, flat, and exact size)
- Open orders (pending limits, stops)
- Account balance and available margin
- Recent fills and their prices
- Error state (is the connection healthy? Are there unresolved errors?)
Common Strategy Archetypes
| Type | Logic | Edge source |
|---|---|---|
| Trend following | Buy when price is trending up, sell when trending down | Markets trend more than random walk predicts |
| Mean reversion | Buy when price is below fair value, sell when above | Overreactions revert to the mean |
| Momentum | Buy recent winners, sell recent losers | Winners tend to keep winning (short-term) |
| Market making | Place bids and asks, profit from the spread | Providing liquidity earns the spread |
| Statistical arbitrage | Exploit price relationships between correlated assets | Mispricings between related instruments |
The Development Pipeline
- 1. Hypothesis: Define the market behavior you're exploiting.
- 2. Backtest: Test on historical data with realistic assumptions.
- 3. Paper trade: Run live on testnet/paper account for weeks.
- 4. Small live: Deploy with minimal capital to validate execution.
- 5. Scale: Gradually increase size as confidence grows.
- 6. Monitor: Continuously track performance and compare to backtest expectations.
Skipping steps in this pipeline is how people lose money. Each step catches different types of problems.
Practice
Exercise
Write a complete strategy specification (not code, just the plan) that includes:
- Hypothesis: What behavior are you exploiting?
- Entry signal: Exact conditions
- Exit signal: Take profit, stop loss, time exit
- Filters: When NOT to trade
- Position sizing: How much per trade
- Expected characteristics: Win rate, average R, max drawdown
Key Takeaways
- Algo strategies need: signal generation, execution logic, state management.
- Start with a hypothesis about market behavior, not indicator combinations.
- State desync is the most dangerous bug - always reconcile with the exchange.
- Follow the pipeline: hypothesis → backtest → paper → small live → scale.
- Every strategy archetype exploits a specific market inefficiency.
Marktstructuur en deelnemers
Financiële markten bestaan uit verschillende deelnemers met verschillende doelen: retailtraders, institutionele beleggers, market makers, hedgefondsen en centrale banken.
Marktmicrostructuur
- Market makers: Bieden liquiditeit door continu koop- en verkoopprijzen te quoteren.
- Dark pools: Privé-handelsplatformen waar grote orders worden uitgevoerd zonder de openbare markt te beïnvloeden.
- HFT: High-frequency trading gebruikt snelheid als competitief voordeel.
Belangrijkste punten
- Begrijp wie de andere deelnemers zijn en wat hun motivaties zijn.
- Market makers verdienen aan de spread, niet aan richting.
- Institutionele orders bewegen markten — retail volgt meestal.
- Marktstructuur beïnvloedt hoe en wanneer je orders worden uitgevoerd.
Les afgerond
Je hebt afgerond: Algo Strategy Design.