Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- run: pip install ruff && ruff check --select F,E9 console tools
# Every first-party script must at least parse.
- run: for f in console/frontend/*.js traders-desk/desktop/plugin.js; do node --check "$f"; done
- run: for f in install.sh console/start.sh tools/sync-live.sh bin/is-enabled.sh; do bash -n "$f"; done
- run: for f in install.sh adapters/dsh/install-dsh.sh console/start.sh console/service-linux.sh bin/setup-python.sh tools/sync-live.sh bin/is-enabled.sh bin/register-mcp.sh; do bash -n "$f"; done
# The vendored bundles are what was recorded (a hand edit or a half-applied upgrade fails here), and the
# generated preload list follows the module graph.
- run: python tools/vendor-sums.py --check
Expand Down
72 changes: 72 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,54 @@ All notable changes to this project are documented here. Format: [Keep a Changel

## [Unreleased]

### Changed

- **The replay strip is a glass capsule** (30 Oct), the operator's pick of two designs. One frosted
pill, about 430 px: the scrubber is its top edge (white playhead, the range's first and last bar fade
in on hover), Play is the one bright control and turns into Pause, back-to-start and next-bar flank
it as icons, the cursor time reads as date over clock (still the door to the calendar), a ring beside
"N bars left" fills as this replay advances, and the speed is a chip that opens the same menu. The
speed menu and the calendar take the same glass. Everything the strip did still works: seek on
release, Start bar, the drag handle and its saved spot, the paper broker's replay price. Icon-only
buttons carry names for screen readers; focus is visible; the count has a fixed width so the pill
does not wobble during playback. In a narrow Hermes pane the words "bars left" drop and the number
and ring stay. Verified in Chromium at 1150, 620 and 420 px, dark and light. Eight tests in
`test_replay.py`.

### Fixed

- **The chart sprang back to its right edge after a drag, in replay and out** (30 Oct). Two faults in
`nudgeChart()` (app.js): its repaint dispatched a window `resize`, and the resize handler called
`nudgeChart()` again — an endless loop, measured at 140 view resets in 10 idle seconds; and each
reset re-applied `getVisibleRange()`, which Vela caps at the newest bar in whole bars, so the space
the operator had dragged in was thrown away and the zoom crept. The handler now ignores synthetic
resizes (`isTrusted`), and the repaint is Vela's `panBy(0)`: same zoom, same position, full redraw.
Verified in Chromium: 0 resets idle; a drag into empty space or history stays put, in replay too
(stepping or playing while looking at older candles leaves the view alone); the canvas still
repaints after a panel flip and a window resize.
- **Long tick-store windows came back short and slow** (30 Oct): `fxticks.bars` grew its window a day
per pass from a 0.4x guess, re-reading every hour on every pass and giving up after 60. On a two-year
store 500 x 4h returned 404 bars in 12 s and 500 x D returned 186 in 67 s, with no sign anything was
missing. The window is now sized once from the timeframe (1.5x the trading time plus a long weekend,
one wider pass for holidays, never before the store's first day): 500 and 500, in 0.8 s and 4.9 s.
Same bars as before wherever the old walk did reach. Weekends cost one stat instead of 24.
- **The hour cache held raw ticks**: 4,096 decoded hours of a busy pair ran to gigabytes. Each hour is
now packed as at most 60 minute bars (~4 KB), so 20,000 hours stay under ~80 MB. The docstring's
promise of an on-disk `fx/bars-v1` cache, which never existed, is gone, along with the unused
`TRADERS_FX_BARS`.
- **One truncated hour sank the whole request**: a download cut off mid-write left a half gzip that
raised inside `bars()`, so the provider dropped the store and went to the network. Unreadable hours
are now skipped and counted (`unreadable_hours` in the meta). `tools/fx-fetch.py` writes each hour to a
`.part` file and renames it, so it no longer leaves them.
- **`tools/fx-fetch.py` cached hours that were not final**: the walk ended at the current hour (cached
half-full for good), and a 404 the feed had simply not published yet became a permanent `.empty` hole.
It now stops at the last complete hour and marks a 404 empty only once it is a day old.
- **The Data tab could read "Reading the tick store…" forever**: `fxdata.status()` returned early when
the network cache folder did not exist and dropped the `ticks` block, which is exactly the case for an
operator who has only run `fx-fetch.py`. One shape always now, plus a `yahoo` flag. The card's Yahoo
line follows the server instead of a constant, and it re-reads the store on every visit.
- **CI was red on `main`**: an unused `import json` in `tools/fx-fetch.py` failed the ruff gate.

### Added

- **A Data tab in the desk sheet** (21 Oct), so the source is visible instead of inferred: it reads
Expand Down Expand Up @@ -133,10 +181,34 @@ All notable changes to this project are documented here. Format: [Keep a Changel

### Fixed

- **`TRADERS_AGENT_ALLOWED_HOSTS` was an undocumented change to who can write.** Measured, not inferred: with a
name on the list, a request carrying it from loopback is handed the POST token and `POST /api/broker` answers
**200**. That is the intended trade (`tailscale serve` terminates here, so your phone arrives as 127.0.0.1),
but it means every device on that tailnet can approve paper orders, drive the chart and run Pine **with
`ALLOW_LAN` unset** — and the variable appeared in no document at all, while the README's `ALLOW_LAN` row
still promised "LAN peers get a read-only console", which stopped describing this path. The README now carries
the variable, says plainly that each name is a full-trust door, and corrects the `ALLOW_LAN` row; three live-socket
tests pin the token, the write and the still-refused unknown name (removing the name from the allowlist fails two
of them). No behaviour changed — only what the repository admits to.
- **The package README documented an install that is no longer the short one** (`./console/start.sh` + `./install.sh`,
with no mention of `--all`); it now leads with `./install.sh --all`.

- **The README still claimed Linux-only.** macOS support shipped on 13 Oct (`docs/MACOS.md`, the repo venv,
`console/service-macos.sh` behind launchd), so the OS row, the service section and the platform bullet now
say Linux + macOS, name the launchd counterpart of the systemd unit, and link the Mac setup. Windows stays
out of scope, and `docs/HANDOFF.md`'s operator line now names both machines.
- **`./install.sh --all`, the one-command install**, plus the two pieces it is made of. `bin/setup-python.sh` gives the console and the
agent a python with the `mcp` client: `uv` when it is on PATH (5.6 s against 286 s for pip in the same slow sandbox), else
`python3.11+ -m venv` + pip; a python you already have that imports `mcp` is left alone. It asks for Python 3.12, then 3.13, then
3.11, never "the newest": a bare `>=3.11` once made uv choose a 3.14 release candidate whose pydantic could not import (found by
running it, held by a test). `console/service-linux.sh` is the systemd counterpart of `service-macos.sh` (user unit
`traders-agent.service`; a detached console where there is no systemd user session, said plainly; an already-running console, or the
developer's `luxalgo-web.service`, is left alone). `--setup-python` and `--service` run each step alone. Nothing about what the
plugin does changes; a plain `./install.sh` behaves as before. Tests: `test_fast_install`.
- **DeepSeek Harness adapter** (`adapters/dsh/install-dsh.sh`): installs the desk skill and registers the `traders-chart` MCP server for
dsh. `--mcp-file` merges the entry into a JSON file you name (other servers kept, backup made, invalid JSON refused), `--doctor`
runs a real MCP handshake (56 tools) and checks the console, `--uninstall` undoes it. The Hermes pane stays Hermes-only. Not yet
tried against a real dsh install.

### Changed

Expand Down
52 changes: 48 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,33 @@ MCP server) in one local web app — your chat session is left exactly where it
| | |
|---|---|
| **Hermes Desktop** | v0.21.3 or newer (the plugin uses the `sidebar.nav` + `routes` contribution areas) |
| **Python** | 3.11+ with the `mcp` client: `pip install mcp` (a venv is fine — point `PY=` at it) |
| **Python** | 3.11+ with the `mcp` client. `./install.sh --all` (or `./bin/setup-python.sh`) makes a `.venv` with it; or `pip install mcp` yourself and point `PY=` at it |
| **Network** | for LuxAlgo's MCP endpoint and the Binance data feed; with no market feed the chart stays empty (`chart_state` says `bars None`). The chart engine and Pine runtime are served locally |
| **Node 20+** *(optional)* | for [Edge Stats](#edge-stats--how-often-did-it-actually-happen) (`./install.sh --with-edge`, ~300 MB) and the prop-firm simulator (`./install.sh --with-prop`, ~10 MB) — both LuxAlgo engines, both local. Without them everything else works and each sheet says what is missing |
| **Preview resizer** *(optional)* | `libvips` (or ImageMagick, or `ffmpeg`) — see [Catalogue previews](#catalogue-previews-are-kept-on-your-machine). With none of them the console still shows every preview, just at the catalogue's original size |
| **OS** | Linux (built and verified on Omarchy / Arch + Hyprland) or **macOS** — Macs need the one-time venv + the launchd service; see [`docs/MACOS.md`](docs/MACOS.md). Windows is out of scope. |

## Install

**One command** (Linux and macOS; about a minute with [uv](https://docs.astral.sh/uv/), a few without it):

```bash
git clone --depth 1 https://github.com/godzillacode0000/tradersagent-plugin
cd tradersagent-plugin
./install.sh --all
```

`--all` installs the plugin and the desk skill, makes a python with the `mcp` client (`bin/setup-python.sh`: uv when
it is on PATH, else `python3.11+ -m venv` + pip; it leaves a python you already have alone), installs the console as a
service (systemd user unit on Linux, LaunchAgent on macOS, a detached process where neither exists), registers the
chart's MCP server with Hermes, and waits until the console answers. Then, in Hermes Desktop: reload the plugins and
click the **Trader's Agent** row. Measured on a clean machine: clone 1.5 s, `./install.sh` 0.25 s, console up in 1.6 s;
the dependency step is the long one (`uv pip install mcp` 5.6 s against 286 s for pip in the same slow sandbox).
Optional extras stay separate: `--with-edge` (~300 MB), `--with-backtest` (~840 MB). Add `--no-mcp` to skip the
registration. Re-running is safe.

The same steps by hand:

```bash
git clone https://github.com/godzillacode0000/tradersagent-plugin
cd tradersagent-plugin
Expand Down Expand Up @@ -393,6 +412,25 @@ tick — measured 37-156 ms on the wire for `add` / `market` / `apply`, ~65-80 m
healthy, 2 s if it drops) and the file bridge is untouched, so an older view still works. The bridge
is still not a headless renderer: with no view attached, commands fail fast and say so.

### Using it from the DeepSeek Harness (dsh)

The chart pane is Hermes-only, but the desk is not: the same MCP server (56 tools) and the same skill work from dsh,
and the agent drives the console's chart exactly as it does from Hermes. Open `http://127.0.0.1:8787/` in a browser tab
to watch it.

```bash
./console/start.sh # the console must be running
./adapters/dsh/install-dsh.sh --mcp-file PATH # PATH: the JSON file where your dsh lists MCP servers
./adapters/dsh/install-dsh.sh --doctor # skill, launcher, a real MCP handshake, the console
```

It copies the skill to `~/.agents/skills/trader-desk` (`--skills-dir` or `DSH_SKILLS_DIR` to change it) and writes a
stdio entry into the file you name (it runs `console/mcp/server.py` with `PY`, the repo's `.venv` or a python that has the `mcp` client, same order as `bin/register-mcp.sh`; else `uvx fastmcp run`; `--venv` forces a private venv),
keeping your other servers and a `.bak-traders` copy. Without `--mcp-file` it prints the entry for you to paste.
`PORT=9000` points the entry at a console on another port. It reads nothing from dsh itself and writes nowhere else, so
check your dsh's own docs for the config path. Not verified against a real dsh install yet: the handshake is tested with
the MCP client, and dsh's skill and config locations are as reported by third-party dsh plugins.

## Screenshots

| | |
Expand Down Expand Up @@ -447,8 +485,8 @@ bin/ register-mcp.sh (the MCP registration on its own) · is-enabl
| `LUXALGO_CONSOLE` | `http://127.0.0.1:8787` | where the MCP server, `trader-chart` and `library-indicator` find the console (set it with `hermes mcp add … --env LUXALGO_CONSOLE=http://127.0.0.1:9000` when `PORT` is not 8787) |
| `TRADER_CONSOLE_TOKEN_FILE` | `~/.local/state/traders-agent/console.token` | the POST token the console mints and the MCP server and CLI read |
| `TRADERS_AGENT_WORKDIR` | `~/Projects/luxalgo-web` if it exists, else `console/agents` | the folder the in-app study bridge runs the agent CLI in (never taken from a request) |
| `TRADERS_AGENT_ALLOW_LAN` | unset | with `--host 0.0.0.0`, non-loopback peers may receive the POST token — i.e. they can DRIVE the console, not just read it. Unset, a non-loopback peer can read but every write is refused |
| `TRADERS_AGENT_ALLOWED_HOSTS` | unset | comma-separated extra hostnames/IPs treated as "this machine" by the Origin check (e.g. a tailscale name, so a page served over it can drive the console). It widens who may act through a browser page — add only names you control |
| `TRADERS_AGENT_ALLOW_LAN` | unset | with `--host 0.0.0.0`, let peers that reach the console **from their own address** receive the POST token; without it they get a read-only console. It does **not** govern a caller arriving through a local reverse proxy — see the row below |
| `TRADERS_AGENT_ALLOWED_HOSTS` | unset | comma-separated extra `Host` names this console answers to, for a local reverse proxy that forwards the public name (`tailscale serve` does). **Every name you add here is a full-trust door:** the proxy terminates on this machine, so the caller arrives on loopback, is handed the POST token and can write — approve paper orders, drive the chart, run Pine — with `ALLOW_LAN` unset. Only add names that resolve to this machine inside an access-controlled network, and read it as “everyone on that tailnet is me”. Any other name is still refused |
| `TRADER_PAPER_FILE` | `~/.local/state/traders-agent/paper.json` | the paper account (use another path for a second test console) |
| `LUXALGO_AGENTS_DIR` | `console/agents` | runtime state: chart bridge files, study threads, shots |
| `HERMES_CLI` | `hermes` on `PATH` | CLI the in-app study bridge shells out to |
Expand Down Expand Up @@ -492,6 +530,12 @@ it from `http://127.0.0.1:8787/api/library/thumb`: **~5 ms warm instead of ~2 s*
- **The bridge is not a headless renderer.** `trader-chart` and the MCP tools only take effect while
a chart view is mounted (the Hermes pane or a browser tab); with none attached they fail fast with
"no chart view attached" rather than hanging. Commands are pushed, so a view answers in tens of ms.
- **Reaching the console through a proxy widens who can write.** The trust model is “a loopback caller is
the human at this machine”. A local reverse proxy (`tailscale serve`) makes every device on that network a
loopback caller, so `TRADERS_AGENT_ALLOWED_HOSTS` turns that network into the trusted set — the approve
brake on paper orders is then only as strong as the network's own access control. Pinned by
`console/backend/tests/test_allowed_hosts_env.py`, which asserts an allowlisted name both receives the token
and writes.
- **One console per machine** on one port. No real orders and no brokerage account exist: the only trading is a
**simulated Binance spot paper account** (`broker_*`), where the agent can only propose and you approve. The account
and the journal its fills keep (win rate, profit factor, the realised curve) are one surface — ⋯ → **Trader's desk**.
Expand Down Expand Up @@ -523,7 +567,7 @@ python3 -m compileall console/backend

The suite is stdlib-only on purpose — the study store, the chat bridge, the chart bridge and the push
channel are covered without a browser, a network, or the app — and the MCP tool layer runs against a
stub console. about 1,130 tests; the MCP ones skip themselves when `fastmcp` is absent (CI sets
stub console. about 1,314 tests (81 files, 9 skipped on 30 Oct); the MCP ones skip themselves when `fastmcp` is absent (CI sets
`TRADER_CHART_REQUIRE_MCP=1` so they cannot silently skip there).

CI (`.github/workflows/ci.yml`) has three jobs: the plugin harness (Node 20 — the real plugin first,
Expand Down
Loading
Loading