Pradyot Bathuri

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 μ\mu and covariance Σ\Sigma, you want weights ww that maximize return for a given risk appetite qq:

maxw  μw    qwΣw.\max_{w}\; \mu^\top w \;-\; q\, w^\top \Sigma w.

The interesting move is discretizing this into a binary asset-selection problem and casting it as a QUBO — Quadratic Unconstrained Binary Optimization:

minx{0,1}n  xQx,\min_{x \in \{0,1\}^n}\; x^\top Q\, x,

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 ψ(θ)|\psi(\boldsymbol{\theta})\rangle, measure the expected energy ψ(θ)Hψ(θ)\langle \psi(\boldsymbol{\theta})| H |\psi(\boldsymbol{\theta})\rangle, and let a classical optimizer push θ\boldsymbol{\theta} 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 ff malicious nodes you need

n3f+1.n \ge 3f + 1.

With n=11n = 11 nodes, the system tolerates f=3f = 3 Byzantine actors and still reaches correct consensus on whether a proposed trade is valid. Eleven was chosen precisely so the math gives a comfortable f=3f=3 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

6. What was real, what was theater

In the spirit of not lying with a demo:

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

  1. Markowitz, H. (1952). Portfolio Selection. Journal of Finance, 7(1).
  2. Peruzzo, A., et al. (2014). A Variational Eigenvalue Solver on a Photonic Quantum Processor. Nature Communications, 5, 4213.
  3. Farhi, E., Goldstone, J., & Gutmann, S. (2014). A Quantum Approximate Optimization Algorithm. arXiv:1411.4028.
  4. Castro, M., & Liskov, B. (1999). Practical Byzantine Fault Tolerance. OSDI '99.
  5. National Institute of Standards and Technology (2024). FIPS 204: Module-Lattice-Based Digital Signature Standard (CRYSTALS-Dilithium).

Code: github.com/pbathuri/LABLAB-Hackathon