How it works

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

01

Sense

Each tick gathers prices, recent headlines and a per-ticker sentiment read across the watchlist.

02

Reason

Signals, the portfolio and the active strategy go into a prompt. Qwen returns a structured decision per name.

03

Act

Risk limits are enforced, then buys and sells apply to the paper ledger. Cash is never allowed to go negative.

04

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.

Watchlist
AAPLxTSLAxNVDAxMSFTxSPYxCOINx

Six tokenized US equities, configurable in one file.

Built with
Next.js App RouterTypeScriptTailwind CSSFramer Motionlightweight-chartsQwen (DashScope)TanStack QueryZod

Original code, open-source libraries, re-skinned as a night theme.