01 / CASE STUDY
Algorithmic prediction-market infrastructure
Kalshi Terminal.
An integrated trading-system architecture connecting market data, momentum evaluation, execution boundaries, position controls, event records and operational diagnosis.
SYSTEM MODEL
Architecture overview
01 / CONTEXT
The problem space
A market signal is only one component of a trading system. The system must identify the correct contract, validate entry conditions, manage order state, track exposure, handle exits and reconcile the final economic outcome.
Failures can arise when market data is stale, runtime configuration differs from displayed settings, fills are confused with submitted orders, or settlement and fees are represented inconsistently. The objective is to make these responsibilities explicit and inspectable.
TECHNICAL DETAIL / 02
Market-data ingestion
The system consumes prediction-market information alongside cryptocurrency reference-price feeds. Development configurations have included BRTI and reference sources such as Coinbase, Kraken, Bitstamp and Gemini.
The architecture distinguishes the reference price used to evaluate direction from the executable price and liquidity available in the prediction market. Directional agreement does not guarantee a favorable contract price.
- Normalize incoming observations
- Track source and timing context
- Treat stale or incomplete inputs as explicit conditions
TECHNICAL DETAIL / 03
Signal processing
The strategy orientation is momentum and trend-following breakouts, with counter-trend entries blocked by design. The system has included a nine-period EMA trend guard and a momentum-thesis guard.
Entry bounds, confirmation cycles, take-profit distance, stop-loss behavior, allocation and expiration protection represent different controls. Keeping them distinct makes each assumption easier to test.
- Entry-price bounds and confirmation cycles
- Trend and thesis guards
- Configurable exit and expiration behavior
TECHNICAL DETAIL / 04
Execution boundary
A signal, submitted order, fill and closed position are different states. The execution layer must preserve those distinctions and avoid treating an intended action as proof that the exchange completed it.
The boundary between signal generation and execution authorization prevents a valid signal from bypassing order controls.
- Explicit order lifecycle
- Validation before execution
- Separate intended actions from exchange-confirmed events
TECHNICAL DETAIL / 05
Position, risk and expiration controls
The system exposes position-sizing and allocation controls alongside trend validation, thesis validation and expiration-related safeguards. Each addresses a different failure mode.
The presence of controls does not prove profitability or guarantee bounded losses in every market condition. Effectiveness must be evaluated against observed execution and realistic failure scenarios.
- Position quantity and allocation constraints
- Trend consistency and thesis invalidation
- Expiration-aware handling
TECHNICAL DETAIL / 06
Trade lifecycle and accounting
Economic results must be reconstructed from actual fills, fees, remaining quantity and settlement events. A partial exit does not necessarily close the whole position, and multiple events can belong to a single economic trade.
The project has included validation of buy/sell/settlement scenarios and review of persistent trade records, to distinguish order activity from final position outcomes.
- Reconcile fills and settlement
- Account for fees and residual quantity
- Distinguish event records from trade-level outcomes
TECHNICAL DETAIL / 07
Operations and shadow/live separation
The system has used Linux and Docker deployment, a web interface and SQLite/JSON-oriented operational records. Logs and persistent events help investigate what the strategy intended, what the runtime did and what the exchange confirmed.
Shadow and live operation must remain distinct. Shadow behavior does not prove equivalent live fills; live operation introduces liquidity, latency, fees and exchange-side state changes.
- Inspect effective runtime configuration
- Trace events through logs and persistent state
- Verify the running deployment after changes
DESIGN RATIONALE
Key decisions
Separate signal from execution
Strategy approval and order authorization are distinct responsibilities, so controls can be reviewed without changing the signal model.
Treat accounting as infrastructure
Credible performance depends on position reconstruction, fees, partial exits and settlement—not just a dashboard counter.
Verify runtime reality
Source edits, images, containers and running configuration are separate states; deployment claims require runtime verification.
VERIFICATION
Evidence and boundaries
Evidence available
- Architecture and runtime/configuration inspection.
- Log analysis and review of persistent trade records.
- Isolated validation of position and settlement-accounting scenarios.
Claims not assumed
- No verified profitability or positive long-term expectancy is claimed.
- Production readiness requires reproducible tests of fills, cancellations, partial fills, fees, settlement and recovery.
- Any performance claim needs a defined dataset, period and evaluation method.
ARCHITECTURE PRINCIPLE
“Separate a market hypothesis from the infrastructure that executes, records and evaluates it.”