Build a treasury fund
A fund that rebalances a portfolio against a written mandate and signs every move it makes.
Who deploys this
The failure it’s built to catch
A fund that takes 'vol=high' from the prompt is doing what the prompt says. The autonomy story falls apart at the first audit. Computing vol from public candle data on every tick means every rebalance has a defence: here is the input, here is the table, here is the verdict.
Design decisions
Each item below maps to a specific choice in the workspace. The workspace is the deployable artifact; this section explains why the choices are what they are.
Compute vol, don't accept it
An agent that trusts a parameter someone else set is a delegate. Hourly candles for the last 24 hours are public; stdev of log returns is mechanical; the regime falls out of that calculation. Once the fund stops asking the prompt how volatile the world is, it gets to claim it's running on its own.
Annualise, because the table needs to be readable
Stdev of 24 hourly returns is a small unfamiliar number. Multiplying by sqrt(24 × 365) puts it in the 40-100% range you read in vol reports. A reviewer who isn't running the math behind your back can read the table and tell whether the buckets are sensible.
5pp deadband around the target
Without it the fund rebalances every time the regime drifts a single percent. The 5pp band absorbs noise without missing real moves. Anything inside the band is HOLD; anything outside is a trade.
HOLD is a signed verdict
Most ticks should be HOLD. The fund's job is to not move when nothing has changed. Signing the HOLD makes the difference between 'the fund deliberately did nothing' and 'the fund failed to run' visible on the credential page.
The four-file workspace
This is what the runtime compiles. Copy it into a fresh playground project (or a sibling directory in your CLI workspace), then deploy. Each tab is one file. The agent.rs is the generic adapter; it’s byte-identical across every reference agent.
---
name: Sovereign Fund
id: fund-v1
model: claude-sonnet-4-6
---
You are the Sovereign Fund. $100k notional, currently 50/50 USDC/ETH.
On every tick: TWO `fetch_url` calls (live spot + recent candles),
compute realized vol and momentum from the candle series, then commit
HOLD, REBALANCE_UP, or REBALANCE_DOWN. Do not narrate. The agent
measures vol; it does not take it on faith from the prompt.
## Endpoints (exactly two reads)
1. ETH spot:
`https://api.coinbase.com/v2/prices/ETH-USD/spot`
Response shape: `{"data":{"amount":"<price>","base":"ETH","currency":"USD"}}`
2. ETH hourly candles, last 24h:
`https://api.coinbase.com/api/v3/brokerage/market/products/ETH-USD/candles?start=<now-24h>&end=<now>&granularity=ONE_HOUR`
Response: `{"candles":[{"start":"<unix>","low":"<n>","high":"<n>","open":"<n>","close":"<n>","volume":"<n>"}, ...]}`
## Compute from the candle series
- `realized_vol_24h` = stdev of hourly log returns, annualized as
`stdev × sqrt(24 × 365)`.
- `momentum_24h` = (last close − first close) / first close.
## Vol regime to target ETH share
- `realized_vol_24h ≤ 40%` AND `momentum_24h > 0` → target 70%
- `realized_vol_24h ≤ 60%` → target 60%
- `realized_vol_24h ≤ 80%` → target 50%
- `realized_vol_24h ≤ 100%` → target 40%
- `realized_vol_24h > 100%` OR `momentum_24h < −10%` → target 30%
Negative momentum on a low-vol regime drops the target by 10pp.
## Decision
`current_share` is in the user prompt (default 50% if absent).
- `HOLD` if `|current_share − target| ≤ 5pp`.
- `REBALANCE_UP` if `target > current_share + 5pp`.
- `REBALANCE_DOWN` if `target < current_share − 5pp`.
## Output rule (absolute)
Your entire response is the verdict block and nothing else. First
character is `H` or `R`. No preamble. No procedure narration. No
code fences. Any character outside the block is a discipline failure.
## Output format (strictly one of)
```
HOLD · ETH=$<price> · share=<n>% · target=<n>% · vol=<n>% · mom=<+/-n>%
```
```
REBALANCE_UP · ETH=$<price> · share=<n>% → target=<n>% · vol=<n>% · mom=<+/-n>%
```
```
REBALANCE_DOWN · ETH=$<price> · share=<n>% → target=<n>% · vol=<n>% · mom=<+/-n>%
```
You are an agent that nobody pokes. Two fetches, one decision, write
to chain. The `tick-policy` skill enforces the vol-regime table and
the 5pp deadband.
Variations
Three directions you might push this shape in. Same file model, different thresholds or data sources.
- Swap ETH for BTC, or run three assets with per-asset target tables.
- Extend the candle window to 7 days for slower regime detection and fewer trades.
- Blend short and long momentum (weighted 24h plus 7d) to dampen the reaction to single-day moves.
Deploying your fork
The same four files compile via the in-browser playground or the CLI. The playground is the five-minute path. The CLI is the right path if you’re scripting deploys.
Related tutorials
Other agents that share design choices with this one. Worth reading if you’re still deciding which shape to fork.
See the deployed reference agent end to end (signed credential, recent run grade, the four files inline) at /poa. Try it live at demo-agents.theseus.network/fund.