SIDE PROJECT · CURRENT
KTrader
A trading research and execution system with blind analysis, deterministic risk limits, and an immutable decision record.
Prove on a broker paper account, run on a live prediction market.
13 symbols, 8 open positions maximum. Nothing reaches real money on a hunch.
7% × price × (1 − price). The edge floor is five points in the tails, eight mid-book.
83 tests across both lanes. Four artifact kinds, append-only.
THE REASONING
Quote blindness enforcement and forbidden payload keys
The research pass never receives a quote. It returns a probability range, evidence with source URLs and timestamps, counterevidence, a dated catalyst, an invalidation condition, and a freshness deadline. Only after that does the server fetch the live book.
Enforcement runs in code rather than prompt instructions. A recursive key scan walks the whole research pack and throws if any key matches the lane's forbidden pattern. The prediction lane rejects bid, ask, price, value, pnl, exposure, balance, and notional. The equities lane rejects average entry, unrealized, realized, profit, loss, buying power, portfolio value, equity, cash, and account id.
The same scan runs again on the sealed pack, so a later edit cannot smuggle the price back in.
Deterministic trading guards: spread, concentration, and drawdown
Quote: the order price has to sit inside the live spread, and the live reference no more than five cents from the sealed dossier. A wide spread needs high conviction. A closed or halted market never passes.
Concentration: eight open positions is the ceiling and resting orders count toward it. A new bet is refused when another market in the same correlation group already carries exposure, so a second leveraged fund cannot be bought while one is held. Re-entry: exiting a market stores the evidence fingerprint that closed it, and research predating the exit, or hashing to the same evidence, cannot buy back in.
Drawdown: five percent daily loss, or twenty percent off the phase high water mark, freezes new buys. Exits still work. Resuming needs a message from me, matched on the exact sender, not a model decision.
Options entry: eight to forty five days to expiry, a quote no older than sixty seconds, a spread inside twenty percent of the midpoint, a premium capped as a fraction of equity, and a limit price rounded to the contract's real tick. Options exit: fifty percent down, one hundred percent up, or seven days to expiry, run by a deterministic monitor.
Cash flow: equity is adjusted for external cash flows before any drawdown math runs, and the original funding deposit is bound by activity id so it is never double counted. Without that a deposit reads as profit and the drawdown guard silently loosens.
Execution message validator and numeric literal allowlist
The failure mode is a model writing a clean summary of a trade that did not happen the way the summary says, and that summary being the only thing anyone reads.
So the message is composed from the execution record, then checked by a deterministic validator before it can be sent. The validator allowlists every numeric literal in the record facts and rejects any number outside that set. It also requires the action, symbol, and status verbatim, four lines maximum, and no em dashes. A failure gets exactly one bounded correction attempt, then the validator runs again on the corrected text.
Integration seam testing across 83 boundary test cases
Failures in agent architectures typically occur at the boundaries between components rather than within them. Old research attached to a new decision. A retry that becomes a duplicate. A quote that moved after approval. A polished message reporting an action the venue never confirmed. Each of those is a named, testable boundary here.
The 83 tests across both lanes aim at those seams: tampered payloads, stale and cross-lane parents, quote drift, correlated exposure, weak re-entry evidence, retry idempotency, lease overlap, and messages containing numbers no record supports.
Guard triggers represent intended policy enforcement rather than errors; holds are surfaced alongside fills in the execution log. A guard firing constantly indicates that model calibration or threshold tuning needs adjustment.
Half-Kelly position sizing and exchange fee adjustment
Server code takes the blind probability estimate and the live price, subtracts the venue fee, and computes a half-Kelly stake, which is half the bet size that would maximize long-run growth at the stated edge.
The fee is seven percent of price times one minus price, per contract. It bites hardest mid-book. The probability used is the adverse end of the estimate range, never the midpoint: a yes bet sizes off the low bound, a no bet off the high bound. That costs stake on good bets, and it is the trade I want, because a wide range would otherwise become a bigger position.
The edge floor is five points in the tails and eight points mid-book, stricter mid-book because that is where a model's calibration is worst. Contract count is the stake divided by the fee-adjusted price, rounded down. Anything below the minimum stake becomes a hold rather than a bet too small to matter after fees.
SHA-256 artifact sealing and lineage validation
Each artifact is serialized as canonical JSON with sorted keys, hashed with SHA-256, and frozen. Validation recomputes the hash and walks every parent reference. It refuses a tampered payload, a stale artifact past its freshness deadline, a parent hash that no longer matches, a parent from the other lane, and a lineage cycle. The store is append-only.
Each step verifies parent hashes directly rather than relying on context memory. The critic cannot cite research without providing a matching hash, and order execution requires an independently verified decision record. Deriving the client order ID from the decision hash and action index guarantees idempotent retries.