A small brain that never clocks out.
Nocturne runs one loop, over and over, a few seconds apart. Here is what happens on every tick, how it decides, and what keeps it safe.
The loop
Sense
Each tick gathers prices, recent headlines and a per-ticker sentiment read across the watchlist.
Reason
Signals, the portfolio and the active strategy go into a prompt. Qwen returns a structured decision per name.
Act
Risk limits are enforced, then buys and sells apply to the paper ledger. Cash is never allowed to go negative.
Log
The market view, every decision and the resulting equity are appended to the live feed for anyone to audit.
The decision, as data
The model is asked for one JSON object. It is validated before it can touch the ledger, so the shape of a decision is always the same.
{
"marketView": "one-line read on the tape",
"decisions": [
{
"ticker": "NVDAx",
"action": "BUY | SELL | HOLD",
"sizePct": 12,
"confidence": 0.72,
"rationale": "why, in one or two sentences"
}
]
}Strategy presets
One switch changes both the risk limits and the tone of the prompt. The numbers below are the live limits enforced by each preset.
Conservative
Capital preservation first. Small, diversified positions.
- Max per name
- 20%
- Max per trade
- 10%
- Min confidence
- 60%
Balanced
Measured growth. Acts when signals align.
- Max per name
- 35%
- Max per trade
- 20%
- Min confidence
- 50%
Aggressive
Momentum-friendly. Decisive on strong signals.
- Max per name
- 60%
- Max per trade
- 35%
- Min confidence
- 40%
Safety
Paper-trading by default
Nocturne trades simulated capital. It places no real orders and touches no real funds.
Validated model output
Every response is parsed against a strict schema. Malformed or low-confidence calls are dropped, not executed.
Enforced risk limits
Per-name exposure and per-trade size are capped by the active strategy before anything reaches the ledger.
Always demoable
Prices, news, sentiment and the model each have a built-in fallback, so the loop runs with zero API keys.
Six tokenized US equities, configurable in one file.
Original code, open-source libraries, re-skinned as a night theme.