AnyFinancial
Any AnyFinancial task runs as three phases. Identify where the request sits,
run the phases it needs in order, and load the phase's SKILL.md(s).
The Three Phases
Phase 1 — Prepare the Data. Get the data the task needs, from one of two
sources:
- Hosted datasets — historical bars and reference data for backtests and
research. Flow is catalog → schema → query. Load
data/SKILL.md.
- Real-time / API data — recent/realtime provider APIs, split by market:
realtime-api-data/us/SKILL.md (US) and realtime-api-data/cn/SKILL.md (CN),
entry at realtime-api-data/SKILL.md.
Phase 2 — Analyze the Data. Write the code and compute the result: derive
indicators, run event-driven backtests, evaluate signals, measure risk. Load
backtesting/SKILL.md (with data/SKILL.md for the bars it consumes). This is
where strategy logic and metric computation live.
Phase 3 — Generate the Report. Turn the analysis into a delivered report:
- Templates — reusable finance report structures (statement/valuation/
company/industry). Load
financial-templates/SKILL.md. If no template
fits, you (or the user) may use your own structure — but every report,
templated or not, MUST use the Kami style (report-style/README.md).
- Price charts — when the report shows a traded instrument's price over
time (OHLCV, candlestick, equity curve, backtest markers, RSI/MACD panes),
render with TradingView Lightweight Charts via
financial-charts/SKILL.md.
Keep ECharts only for generic charts (heatmap, pie, bar, scatter, treemap,
dashboards).
- Form is always Kami, and reports are delivered as uploaded HTML artifacts
(see HTML Artifact Output below).
Route First
Match the user's intent to a phase, then load that phase's SKILL.md.
| User intent |
Phase |
Load next |
| Discover/read hosted historical data, pull bars into a backtest cache, validate coverage |
1 · Prepare (hosted) |
data/SKILL.md |
| Latest quote, recent bar, current/recent market snapshot, point fundamentals, provider news |
1 · Prepare (real-time/API) |
realtime-api-data/SKILL.md |
| US direct/recent market data |
1 · Prepare (real-time/API · US) |
realtime-api-data/us/SKILL.md |
| CN direct/recent market data, CN A-shares, CN valuation/financials/universe/news |
1 · Prepare (real-time/API · CN) |
realtime-api-data/cn/SKILL.md |
| Backtest, simulate strategy, evaluate signal, Sharpe/drawdown, out-of-sample validation, historical strategy performance |
2 · Analyze |
backtesting/SKILL.md (+ data/SKILL.md) |
| Financial statement analysis structure, valuation framework, company/industry research outline, finance-specific report pattern |
3 · Report (template) |
financial-templates/SKILL.md |
| Any report styling / HTML output form |
3 · Report (style) |
report-style/README.md |
| Candlestick, OHLCV, price+volume, indicator overlays, backtest buy/sell markers, equity curve, RSI/MACD panes |
3 · Report (price chart) |
financial-charts/SKILL.md |
Phase Rules
- Phase 1 (Prepare). Hosted-data access (
data/SKILL.md) follows catalog ->
schema -> query and is primarily used to prepare or inspect data for later
phases. Real-time/API data is for recent/realtime provider APIs, split into US
(realtime-api-data/us/SKILL.md) and CN (realtime-api-data/cn/SKILL.md). Do
not present recent/realtime data from memory.
- Phase 2 (Analyze). Backtesting/analysis (
backtesting/SKILL.md) consumes
Phase 1 bars and uses the local historical data service and NautilusTrader
workflow. Never present a return without drawdown, trade count, costs, and
in-sample vs out-of-sample status.
- Phase 3 (Report). Financial Templates are internally documented
frameworks, not API calls; label them as templates unless populated with
verified data. If no template fits, use your own structure — but the report
form is always Kami (
report-style/). Price/OHLCV charts use
financial-charts/ (TradingView Lightweight Charts); generic charts use
ECharts.
- AnyFinancial is self-contained. US real-time/API data behavior is documented
and executable under
realtime-api-data/us/ and realtime-api-data/scripts/;
CN real-time/API data is documented under realtime-api-data/cn/.
Composition Patterns
Each pattern threads the three phases: Prepare → Analyze → Report.
Strategy evaluation (backtest report)
- Prepare:
data/SKILL.md for historical bars.
- Analyze:
backtesting/SKILL.md — run in-sample and out-of-sample.
- Report: Kami-styled HTML with costs/limitations; render the price series
and trade markers with
financial-charts/SKILL.md, the equity curve as a
line/area chart.
Recent market data lookup
- Prepare:
realtime-api-data/SKILL.md, then the US or CN sub-skill; query
the provider API and record timestamps/source fields.
- Report: if the snapshot renders as HTML, use Kami; use
financial-charts/SKILL.md for any price/OHLCV chart.
Template-driven analysis
- Analyze/Report:
financial-templates/SKILL.md, choose the matching
template; keep placeholders if no verified data source is available and do
not invent figures.
- If no template fits, use your own structure — but keep the Kami form
(
report-style/).
HTML Artifact Output (Phase 3 — all reports)
Any task that produces a report, analysis, dashboard, chart, or backtest
result for the user MUST render the HTML report and upload it to the
Artifact Store, then reference it in the final chat with a
<rebyte-artifacts> tag containing only the file name (not a path, not
inline HTML). An un-uploaded local file is never delivered to the user.
<rebyte-artifacts>aapl_sma_backtest_20260705.html</rebyte-artifacts>
Every HTML report MUST be styled with the Kami design system — no
exceptions. The report's content comes from Phases 1–2; its form is
always Kami: warm parchment canvas (#f5f4ed, never pure white), single
ink-blue accent (#1B365D), serif-led hierarchy (one serif, weight 500, no
bold/italic), warm grays only, and editorial whitespace.
A report artifact is two parts: the shared Kami style and a content
template. The shared style is report-style/styles.css + report-style/ report.css; the content template (the report HTML) holds only content and
structure and links those two stylesheets — it carries no inline CSS and
no duplicated Kami tokens. styles.css loads before report.css. To restyle
every report, edit the shared CSS once, never a template. The full mandate,
palette, class list, and link-vs-bundle wiring live in
report-style/README.md (alongside report-style/CHEATSHEET.md and
report-style/design.md) — read it before building any report.
Rules:
- Build the HTML in the working directory (
/code/), then upload it to the
Artifact Store before ending the turn. The full upload flow (auth, signed
upload URLs, PUT, and the mandatory instruction tag) is documented in
the top-level CLAUDE.md under Artifact Store. In short:
- Ensure
AUTH_TOKEN and API_URL are set (see CLAUDE.md →
Rebyte API Authentication).
POST $API_URL/api/artifacts/upload-url with the file(s) and
contentType: "text/html".
PUT each HTML file to its signed uploadUrl.
- Follow the returned
instruction — emit each delivered file in a
<rebyte-artifacts> tag.
- File name is kebab- or snake-case, ends in
.html, is unique per run
(include ticker/run-name and an ISO date). Do not reuse a name across runs.
- The chat body may contain a short markdown summary of findings, but the
full HTML report is delivered ONLY as an uploaded artifact. Do not paste
<html>…</html> or long report HTML inline.
- One
<rebyte-artifacts> tag per delivered file; emit multiple tags if a
task produces multiple HTML artifacts (e.g., in_sample.html,
out_of_sample.html).
- If the HTML embeds images/fonts/other assets, upload those with
"public": true and embed the returned publicUrl (no relative paths, no
base64) — see CLAUDE.md → Single HTML File Outputs.
- Style the HTML with the Kami design system (see
report-style/): warm
parchment #f5f4ed canvas, ink-blue #1B365D accent, serif-led hierarchy
(weight 500, no bold/italic), warm grays, editorial whitespace. The report is
two parts — link the shared report-style/styles.css then
report-style/report.css (as hosted public-artifact publicUrls, or bundle
report-style/ alongside); do not inline or duplicate the CSS. Never ship
a report on a pure-white, system-default page.
- Charts: if the report shows a traded instrument's price over time (OHLCV,
candlestick, price+volume, indicator overlays, backtest markers, equity
curve, RSI/MACD panes), render it with TradingView Lightweight Charts via
financial-charts/SKILL.md — delivered as its own artifact (spec block + a
sibling data JSON), not inline. Use ECharts only for generic charts (heatmap,
pie, bar, scatter, treemap, dashboards).
- This upload convention is the umbrella: it applies to Backtesting reports,
Real-time/API Data snapshots that render as HTML, populated Financial
Templates, and TradingView price-chart artifacts — all styled with Kami.
See financial-templates/output-patterns.md#html-artifact-output for the
concrete upload steps and backtesting/SKILL.md#phase-5--results-reporting
for the Backtesting-specific application.
Do Not
- Do not delegate to external skill repos.
- Do not guess financial table columns. Read the catalog and schema first.
- Do not present recent/realtime data from memory.
- Do not treat Financial Templates as sourced analysis unless data has been
fetched, cited, or supplied by the user.
- Do not present backtest returns without drawdown, trade count, costs, and
limitations.
- Do not paste report HTML inline in the chat body. Upload it to the Artifact
Store and reference the file name in a
<rebyte-artifacts> tag.
- Do not leave the only copy of a report on local disk. An un-uploaded file is
never delivered to the user.
- Do not ship an HTML report that ignores Kami styling (pure-white background,
bold/italic serif, cool grays, a second accent color, or no
styles.css).
Form is always Kami — see report-style/.
1---2name: anyfinancial3description: Top-level router for AnyFinancial. A finance task runs in three phases — (1) Prepare the Data (hosted datasets or real-time/API market data for US/CN), (2) Analyze the Data (write code, compute indicators, backtest), (3) Generate the Report (finance templates + Kami style + TradingView price charts). Route by phase before doing work.4---56# AnyFinancial78Any AnyFinancial task runs as **three phases**. Identify where the request sits,9run the phases it needs in order, and load the phase's `SKILL.md`(s).1011## The Three Phases1213**Phase 1 — Prepare the Data.** Get the data the task needs, from one of two14sources:15- **Hosted datasets** — historical bars and reference data for backtests and16 research. Flow is catalog → schema → query. Load `data/SKILL.md`.17- **Real-time / API data** — recent/realtime provider APIs, split by market:18 `realtime-api-data/us/SKILL.md` (US) and `realtime-api-data/cn/SKILL.md` (CN),19 entry at `realtime-api-data/SKILL.md`.2021**Phase 2 — Analyze the Data.** Write the code and compute the result: derive22indicators, run event-driven backtests, evaluate signals, measure risk. Load23`backtesting/SKILL.md` (with `data/SKILL.md` for the bars it consumes). This is24where strategy logic and metric computation live.2526**Phase 3 — Generate the Report.** Turn the analysis into a delivered report:27- **Templates** — reusable finance report structures (statement/valuation/28 company/industry). Load `financial-templates/SKILL.md`. If **no template29 fits**, you (or the user) may use your own structure — but **every report,30 templated or not, MUST use the Kami style** (`report-style/README.md`).31- **Price charts** — when the report shows a traded instrument's price over32 time (OHLCV, candlestick, equity curve, backtest markers, RSI/MACD panes),33 render with TradingView Lightweight Charts via `financial-charts/SKILL.md`.34 Keep ECharts only for generic charts (heatmap, pie, bar, scatter, treemap,35 dashboards).36- **Form is always Kami**, and reports are delivered as uploaded HTML artifacts37 (see *HTML Artifact Output* below).3839## Route First4041Match the user's intent to a phase, then load that phase's `SKILL.md`.4243| User intent | Phase | Load next |44|---|---|---|45| Discover/read hosted historical data, pull bars into a backtest cache, validate coverage | 1 · Prepare (hosted) | `data/SKILL.md` |46| Latest quote, recent bar, current/recent market snapshot, point fundamentals, provider news | 1 · Prepare (real-time/API) | `realtime-api-data/SKILL.md` |47| US direct/recent market data | 1 · Prepare (real-time/API · US) | `realtime-api-data/us/SKILL.md` |48| CN direct/recent market data, CN A-shares, CN valuation/financials/universe/news | 1 · Prepare (real-time/API · CN) | `realtime-api-data/cn/SKILL.md` |49| Backtest, simulate strategy, evaluate signal, Sharpe/drawdown, out-of-sample validation, historical strategy performance | 2 · Analyze | `backtesting/SKILL.md` (+ `data/SKILL.md`) |50| Financial statement analysis structure, valuation framework, company/industry research outline, finance-specific report pattern | 3 · Report (template) | `financial-templates/SKILL.md` |51| Any report styling / HTML output form | 3 · Report (style) | `report-style/README.md` |52| Candlestick, OHLCV, price+volume, indicator overlays, backtest buy/sell markers, equity curve, RSI/MACD panes | 3 · Report (price chart) | `financial-charts/SKILL.md` |5354## Phase Rules5556- **Phase 1 (Prepare).** Hosted-data access (`data/SKILL.md`) follows catalog ->57 schema -> query and is primarily used to prepare or inspect data for later58 phases. Real-time/API data is for recent/realtime provider APIs, split into US59 (`realtime-api-data/us/SKILL.md`) and CN (`realtime-api-data/cn/SKILL.md`). Do60 not present recent/realtime data from memory.61- **Phase 2 (Analyze).** Backtesting/analysis (`backtesting/SKILL.md`) consumes62 Phase 1 bars and uses the local historical data service and NautilusTrader63 workflow. Never present a return without drawdown, trade count, costs, and64 in-sample vs out-of-sample status.65- **Phase 3 (Report).** Financial Templates are internally documented66 frameworks, not API calls; label them as templates unless populated with67 verified data. If no template fits, use your own structure — but the report68 form is **always Kami** (`report-style/`). Price/OHLCV charts use69 `financial-charts/` (TradingView Lightweight Charts); generic charts use70 ECharts.71- AnyFinancial is self-contained. US real-time/API data behavior is documented72 and executable under `realtime-api-data/us/` and `realtime-api-data/scripts/`;73 CN real-time/API data is documented under `realtime-api-data/cn/`.7475## Composition Patterns7677Each pattern threads the three phases: Prepare → Analyze → Report.7879### Strategy evaluation (backtest report)80811. **Prepare:** `data/SKILL.md` for historical bars.822. **Analyze:** `backtesting/SKILL.md` — run in-sample and out-of-sample.833. **Report:** Kami-styled HTML with costs/limitations; render the price series84 and trade markers with `financial-charts/SKILL.md`, the equity curve as a85 line/area chart.8687### Recent market data lookup88891. **Prepare:** `realtime-api-data/SKILL.md`, then the US or CN sub-skill; query90 the provider API and record timestamps/source fields.912. **Report:** if the snapshot renders as HTML, use Kami; use92 `financial-charts/SKILL.md` for any price/OHLCV chart.9394### Template-driven analysis95961. **Analyze/Report:** `financial-templates/SKILL.md`, choose the matching97 template; keep placeholders if no verified data source is available and do98 not invent figures.992. If no template fits, use your own structure — but keep the Kami form100 (`report-style/`).101102## HTML Artifact Output (Phase 3 — all reports)103104Any task that produces a **report, analysis, dashboard, chart, or backtest105result** for the user MUST render the HTML report and **upload it to the106Artifact Store**, then reference it in the final chat with a107`<rebyte-artifacts>` tag containing **only the file name** (not a path, not108inline HTML). An un-uploaded local file is never delivered to the user.109110```111<rebyte-artifacts>aapl_sma_backtest_20260705.html</rebyte-artifacts>112```113114**Every HTML report MUST be styled with the Kami design system — no115exceptions.** The report's *content* comes from Phases 1–2; its *form* is116always Kami: warm parchment canvas (`#f5f4ed`, never pure white), single117ink-blue accent (`#1B365D`), serif-led hierarchy (one serif, weight 500, no118bold/italic), warm grays only, and editorial whitespace.119120A report artifact is **two parts**: the **shared Kami style** and a **content121template**. The shared style is `report-style/styles.css` + `report-style/122report.css`; the content template (the report HTML) holds only content and123structure and **links** those two stylesheets — it carries **no inline CSS and124no duplicated Kami tokens**. `styles.css` loads before `report.css`. To restyle125every report, edit the shared CSS once, never a template. The full mandate,126palette, class list, and link-vs-bundle wiring live in127**`report-style/README.md`** (alongside `report-style/CHEATSHEET.md` and128`report-style/design.md`) — read it before building any report.129130Rules:131132- Build the HTML in the working directory (`/code/`), then upload it to the133 Artifact Store before ending the turn. The full upload flow (auth, signed134 upload URLs, `PUT`, and the mandatory `instruction` tag) is documented in135 the top-level `CLAUDE.md` under **Artifact Store**. In short:136 1. Ensure `AUTH_TOKEN` and `API_URL` are set (see `CLAUDE.md` →137 *Rebyte API Authentication*).138 2. `POST $API_URL/api/artifacts/upload-url` with the file(s) and139 `contentType: "text/html"`.140 3. `PUT` each HTML file to its signed `uploadUrl`.141 4. Follow the returned `instruction` — emit each delivered file in a142 `<rebyte-artifacts>` tag.143- File name is kebab- or snake-case, ends in `.html`, is unique per run144 (include ticker/run-name and an ISO date). Do not reuse a name across runs.145- The chat body may contain a short markdown summary of findings, but the146 full HTML report is delivered ONLY as an uploaded artifact. Do not paste147 `<html>…</html>` or long report HTML inline.148- One `<rebyte-artifacts>` tag per delivered file; emit multiple tags if a149 task produces multiple HTML artifacts (e.g., `in_sample.html`,150 `out_of_sample.html`).151- If the HTML embeds images/fonts/other assets, upload those with152 `"public": true` and embed the returned `publicUrl` (no relative paths, no153 base64) — see `CLAUDE.md` → *Single HTML File Outputs*.154- Style the HTML with the **Kami design system** (see `report-style/`): warm155 parchment `#f5f4ed` canvas, ink-blue `#1B365D` accent, serif-led hierarchy156 (weight 500, no bold/italic), warm grays, editorial whitespace. The report is157 two parts — **link** the shared `report-style/styles.css` then158 `report-style/report.css` (as hosted public-artifact `publicUrl`s, or bundle159 `report-style/` alongside); do **not** inline or duplicate the CSS. Never ship160 a report on a pure-white, system-default page.161- **Charts:** if the report shows a traded instrument's price over time (OHLCV,162 candlestick, price+volume, indicator overlays, backtest markers, equity163 curve, RSI/MACD panes), render it with TradingView Lightweight Charts via164 `financial-charts/SKILL.md` — delivered as its own artifact (spec block + a165 sibling data JSON), not inline. Use ECharts only for generic charts (heatmap,166 pie, bar, scatter, treemap, dashboards).167- This upload convention is the umbrella: it applies to Backtesting reports,168 Real-time/API Data snapshots that render as HTML, populated Financial169 Templates, and TradingView price-chart artifacts — all styled with Kami.170171See `financial-templates/output-patterns.md#html-artifact-output` for the172concrete upload steps and `backtesting/SKILL.md#phase-5--results-reporting`173for the Backtesting-specific application.174175## Do Not176177- Do not delegate to external skill repos.178- Do not guess financial table columns. Read the catalog and schema first.179- Do not present recent/realtime data from memory.180- Do not treat Financial Templates as sourced analysis unless data has been181 fetched, cited, or supplied by the user.182- Do not present backtest returns without drawdown, trade count, costs, and183 limitations.184- Do not paste report HTML inline in the chat body. Upload it to the Artifact185 Store and reference the file name in a `<rebyte-artifacts>` tag.186- Do not leave the only copy of a report on local disk. An un-uploaded file is187 never delivered to the user.188- Do not ship an HTML report that ignores Kami styling (pure-white background,189 bold/italic serif, cool grays, a second accent color, or no `styles.css`).190 Form is always Kami — see `report-style/`.