Projects
Captain Whiskers: a trading agent that optimizes portfolios with a quantum circuit and signs them with post-quantum crypto
Abstract. Captain Whiskers was my entry to the LabLab AI Trading Agents hackathon: an autonomous on-chain trading agent that fuses five ideas which normally never appear in the same sentence — variational-quantum portfolio optimization, on-chain agent identity (ERC-8004), a hard risk-limit router, Gemini-driven trade signals, post-quantum digital signatures (CRYSTALS-Dilithium), and an eleven-node Byzantine-fault-tolerant verification layer. This is the architecture, the actual math behind the quantum and consensus pieces, and an honest accounting of which parts were production-grade and which were a 48-hour demo holding the line.
Keywords: portfolio optimization, VQE/QAOA, Byzantine fault tolerance, post-quantum cryptography, autonomous agents.
1. The premise (and the cat)
Every trading-agent demo claims to be autonomous and trustworthy. I wanted to actually stress both words: make the optimization step quantum, and make the trust layer survive both Byzantine nodes and a future quantum adversary. The agent is named Captain Whiskers because if you are going to put a quantum optimizer behind a crypto-signed trading loop, you might as well admit the whole thing is a little absurd and give it a face.
2. The optimization core: portfolios as a quantum problem
The classical starting point is Markowitz mean-variance optimization [1]. Given expected returns and covariance , you want weights that maximize return for a given risk appetite :
The interesting move is discretizing this into a binary asset-selection problem and casting it as a QUBO — Quadratic Unconstrained Binary Optimization:
which maps directly onto an Ising Hamiltonian a quantum device can minimize. Captain Whiskers uses a variational quantum approach in the VQE/QAOA family [2, 3]: prepare a parameterized state , measure the expected energy , and let a classical optimizer push downhill. It is a hybrid loop — quantum proposes, classical disposes.
Is this faster than a classical solver at hackathon scale? Honestly, no — at a handful of assets a classical optimizer wins every time. The value was building the interface correctly so the quantum subroutine is a drop-in that gets more interesting as problem size and hardware both grow. That distinction — interface now, advantage later — became a small research thread of its own on training-horizon effects in LLM-assisted quantum portfolio optimization, which is the part of this work I am still developing.
3. The trust layer: Byzantine fault tolerance
A trading agent that can move funds needs verification you cannot quietly corrupt. The eleven-node layer runs Byzantine-fault-tolerant agreement in the PBFT tradition [4]. The governing inequality is the one every BFT system lives by: to tolerate malicious nodes you need
With nodes, the system tolerates Byzantine actors and still reaches correct consensus on whether a proposed trade is valid. Eleven was chosen precisely so the math gives a comfortable margin rather than a knife-edge.
4. The crypto layer: signing for a future that has quantum computers
Here is the self-aware joke in the architecture: I used a quantum optimizer and defended against quantum attackers. Trade authorizations are signed with CRYSTALS-Dilithium [5], the lattice-based scheme NIST standardized as FIPS 204 for post-quantum digital signatures. Classical ECDSA signatures are breakable by a sufficiently large quantum computer running Shor's algorithm; Dilithium's security rests on lattice problems believed hard even for quantum adversaries. If you are going to take quantum speedups seriously enough to optimize with them, you should take quantum threats seriously enough to sign against them.
5. Identity and risk: the unglamorous glue
- ERC-8004 on-chain identity gives the agent a verifiable, portable identity so its actions are attributable on-chain rather than trust-me-bro.
- Gemini-driven signals generate candidate trades from market context — the "what should we consider" step, deliberately kept upstream of the risk gate.
- RiskRouter enforces hard position and exposure limits before anything reaches signing. This is the most important and least exciting component: the LLM proposes, the RiskRouter has veto power, and veto power beats cleverness in anything touching money.
6. What was real, what was theater
In the spirit of not lying with a demo:
- Real: the QUBO formulation and variational loop, the BFT agreement logic and its guarantee, the Dilithium signing, the risk-limit gate.
- Scaffolded for the clock: end-to-end on-chain settlement was demoed rather than battle-tested, and the quantum optimization ran at toy scale where it does not beat classical solvers.
- The honest takeaway: the contribution was composition — showing these five layers can be wired into one coherent agent with the trust and risk boundaries in the right places. The individual pieces are known; putting them in the same loop, with the LLM firmly behind a risk gate, was the interesting part.
It is a hackathon project. It is also the most fun I have had drawing a boundary between "the clever part" and "the part that is allowed to touch money," which, increasingly, I think is the actual job.
References
- Markowitz, H. (1952). Portfolio Selection. Journal of Finance, 7(1).
- Peruzzo, A., et al. (2014). A Variational Eigenvalue Solver on a Photonic Quantum Processor. Nature Communications, 5, 4213.
- Farhi, E., Goldstone, J., & Gutmann, S. (2014). A Quantum Approximate Optimization Algorithm. arXiv:1411.4028.
- Castro, M., & Liskov, B. (1999). Practical Byzantine Fault Tolerance. OSDI '99.
- National Institute of Standards and Technology (2024). FIPS 204: Module-Lattice-Based Digital Signature Standard (CRYSTALS-Dilithium).