qkt
a trading engine infrastructure -- write trading like dsl and plug to mt5 and other adapters
Apr 2026 – Present
QKT — Event-Driven Trading Engine
QKT is an open-source event-driven trading engine designed to let a trading strategy be written once, backtested, and then executed live using the same strategy and engine pipeline.
The project addresses a common problem in algorithmic trading: research and live execution are often implemented in different environments. A strategy may be developed in one framework, backtested in another, and then rewritten for a broker platform. This creates opportunities for differences between what was tested and what actually trades.
QKT uses a small SQL-like strategy language (.qkt) that describes symbols, indicators, conditions, entries, exits, position sizing, and risk rules.
For example:
```haskell STRATEGY ema_cross VERSION 1
DEFAULTS { SIZING = 0.10 }
SYMBOLS gold = BACKTEST:XAUUSD EVERY 5m WARMUP 50 BARS
RULES WHEN ema(gold.close, 9) CROSSES ABOVE ema(gold.close, 21) AND POSITION.gold = 0
THEN BUY gold BRACKET { STOP LOSS BY 1.5, TAKE PROFIT BY 3.0 } ```
The same strategy can then be compiled, backtested, paper traded, or connected to a live venue without rewriting the trading logic.
Core Architecture
QKT is built as a single-threaded, event-driven pipeline:
Tick → Engine → Strategy → Signal → Order → Broker → Trade
The strategy is isolated from broker implementations and communicates through the engine's event and order flow. Deterministic clocks, identifiers, sequencing, and random seeds allow the backtest environment to use the same engine components as live execution rather than maintaining a separate simulation implementation.
Multi-Timeframe Strategies
The DSL supports strategies that combine multiple timeframes and indicators in the same strategy definition.
For example, a strategy can use:
- 4h EMA for the broader trend
- 1h RSI for a pullback condition
- 15m VWAP for entry
- ATR-based volatility regime filtering
- position state and attached stop-loss/take-profit brackets
This allows relatively complex trading logic to remain expressed as a single declarative strategy rather than being spread across application code.
Market & Execution Support
QKT is designed to support multiple asset classes through gateway-based execution:
- CFDs — FX, gold, indices and other instruments through MT5
- Futures — including expiry-aware contracts, rolls, margin and settlement
- Options — including multi-leg structures and implied-volatility analytics
- Perpetuals through venue gateways
The strategy does not communicate directly with a broker. Venue-specific execution is handled by gateway components, allowing the strategy layer to remain independent of the trading venue.
Risk, Execution & Research
The engine models trading costs and execution details including spread, commission, swaps, roll costs, bid/ask behaviour and quantity constraints. Backtest reports provide equity and drawdown curves, Monte Carlo analysis, per-trade risk metrics, Sharpe, Calmar and profit factor.
Strategies can also be deployed and managed through a daemon that supports multiple running strategies, logging, observability, state recovery and graceful shutdown.
Why I Built It
The main idea behind QKT is to reduce the gap between research and execution.
Instead of:
research → rewrite → backtest → rewrite again → broker
QKT aims for:
strategy → backtest → validate → deploy
with the same strategy definition and engine pipeline throughout.
QKT is currently pre-1.0 and actively developed.