Kelly Invest Stock
Operate a compact strategy experiment desk. Keep the first screen centered on a
large strategy table: concise thesis, maturity label, account NAV, return,
benchmark, drawdown, cash, and virtual positions. Open a row for the complete
strategy and ledger detail.
Mandatory Dependencies
Before changing the app:
- Read and follow
$kelly-app-skill-creator for product behavior, responsive UI,
and the canonical local content/kelly-invest-stock-app/ artifact.
- Read and follow
$busabase for connection, target Space, ChangeRequests,
review, and merge behavior.
- Read and follow
$busabase-app-creator for resource modeling, AirApp runtime,
security, validation, and deployment.
- Read
references/stock-sdk.md before changing market-data ingestion.
If a dependency is unavailable, continue safe local artifact work but stop before
the unavailable deployment or Busabase operation. Never create a second
persistent backend.
Product Boundary
- Limit the product to mainland China A shares. Preserve six-digit stock codes,
show Chinese security names as the primary identity, and use CNY for every
virtual account, price, market value, P/L, and portfolio total.
- Keep every account, position, return, stage, and regression result virtual.
Never connect to Futu or another brokerage, create order UI, or call a trading
API.
- Give every strategy exactly one virtual account and default every new strategy
to
L1.
- Treat
L1, L2, and L3 as manual labels on the whole strategy, never on an
individual stock:
L1: default basic observation;
L2: manually marked advanced observation;
L3: manually marked high-confidence observation.
- Do not copy the live-trading meaning of L2/L3 from
invest-ui. In this skill,
changing a label never changes execution mode, account type, or capital.
- Keep thesis, evidence, assumptions, confidence, and invalidation separate. A
label or score is not a recommendation.
- Use exact-pinned
stock-sdk@2.4.0 only in reviewed trusted execution. Browser
code performs no public market fetch.
Data And Modes
- Use Busabase as the persistent source by default. A normal invocation or URL
must never silently switch to Demo.
- Enter Demo only when the user explicitly asks to open or update Demo. Demo data
is deterministic, clearly labeled, and not persistent.
- Use 10 recognizable investor-style Demo strategies such as Buffett, Munger,
Duan Yongping, Peter Lynch, Howard Marks, Fisher, Graham, Li Lu, Templeton, or
Soros style examples. Build every Demo basket from clearly labeled A-share
examples and use a fixed CNY 1,000,000 nominal account per strategy.
Label them as style reproductions; never imply actual holdings, endorsement, or
current advice.
- Read and write persistent state through
busabase-sdk. Stage changes use a
records.changeRequest update to the strategy record's status field and a
dated approval record containing the human reason and account snapshot. Never
persist stage changes in browser storage or local files.
- Keep Busabase record page size inside the provider, at no more than the API's
supported maximum. Follow
nextCursor until exhaustion and never put transport
pagination in a Base declaration or treat one page as the complete dataset.
- Offer the deterministic classroom seed only in a completely empty Busabase
workspace. Submit one reviewable bulk ChangeRequest per Base without automatic
merge; the user or Space reviewer decides whether to merge it.
Core Resources
Keep five application-owned Bases under one application Folder:
strategies: name, key, family, status, thesis, selection rule,
invalidation rule, review cadence, next review time, benchmark, and confidence.
ledger-accounts: one virtual account per strategy with nominal capital, NAV,
cash, benchmark return, maximum drawdown, update time, and return baseline date.
ledger-positions: virtual quantity, entry price, reference price, market
value, weight, price source/time, strategy key, six-digit A-share code, and
Chinese security name.
strategy-backtests: dated strategy-level reports with window start/end,
methodology, coverage, benchmark, total return, CAGR, volatility, Sharpe,
maximum drawdown, benchmark-relative return, and bias/source notes.
strategy-reviews: dated research sources, source freshness, supporting and
counter evidence, account snapshots, manual stage decisions, reviewer, reason,
and the associated ChangeRequest ID.
Provision a new empty workspace lazily through one Busabase structure
ChangeRequest, re-read the Folder, and use only validated materialized IDs. For
an owned older schema, submit only declared suffix fields through reviewable field
ChangeRequests, wait for approval, then update resource metadata. Reject reordered,
changed, or otherwise incompatible fields. Ignore legacy app-owned resources
outside this declaration; never delete or adopt them implicitly.
Operating Loop
Research
Define a strategy's thesis, selection rule, invalidation rule, benchmark, review
cadence, next review time, and virtual account before evaluating it. Preserve
research source, source date, supporting evidence, counter evidence, and data
freshness in a dated review record.
Plan
State the evidence needed for the next review. New strategies remain L1. Treat an
L2/L3 change as a human maturity judgment, not an automated promotion or trading
authorization.
Action
Allow reviewed research updates, virtual-ledger records, and mouse-driven manual
stage marking. Before promotion, require complete strategy rules, one account with
a baseline date, dated research evidence, quote provenance, and reconciled NAV.
Require a human reason and confirmation for every stage change. Send persistent
stage changes through Busabase ChangeRequest, write the approval timeline record,
and reload canonical records after materialization.
Retrospective
Compare virtual return, benchmark, maximum drawdown, and contribution to the
whole book. Record whether thesis or process failed before changing a strategy's
rules.
UI Contract
- Use a fixed desktop sidebar with Strategy, L1, L2, L3, Regression, and Help &
Settings. Do not add a separate Virtual Ledger tab.
- Make the Strategy route a large full-width table that combines strategy summary
and ledger reality. Clicking the entire row opens Strategy Detail.
- Put the manual L1/L2/L3 segmented control and compact performance summary at
the top of Strategy Detail. Below it, use shareable hash-routed tabs in this
order:
组合持仓, 研究与审批, 策略逻辑, 回测表现.
- Open
组合持仓 by default. Make it the dominant detail surface with account
NAV/capital/cash/P&L, invested-versus-cash allocation, and a full-width table
showing Chinese security name, six-digit code, quantity, virtual entry price,
reference price, virtual market value, portfolio weight, and virtual P/L. Keep
cash visible as part of the portfolio rather than hiding it in a summary.
- Make L1/L2/L3 routes filter strategies, not stocks.
- Sort the default strategy table by next review time with missing or overdue
review dates first. Do not rank the default workflow by return or confidence.
- In
研究与审批, show dated positive and counter evidence, source provenance,
freshness, stage decisions, human reasons, reviewer, snapshot metrics, and
ChangeRequest IDs. Clearly state that Demo approvals reset on full refresh.
- Treat Strategy/L1/L2/L3 navigation as an in-memory strategy filter after the
desk has loaded. Preserve the sidebar and workspace header DOM, update only
the main strategy content, and do not refetch Busabase or show a full-page
loading state for these route changes.
- Make Regression a dated strategy backtest table aligned with
invest-ui:
report date, start/end dates, window label, methodology, coverage, total
return, CAGR, volatility, Sharpe, maximum drawdown, and benchmark-relative
return. Keep hindsight warnings visible. Show current virtual-book contribution
(strategy P/L / total nominal capital) and the removal case in a clearly
separate secondary section. Do not invent a backtest or any historical metric
without a stored dated report backed by historical observations.
- Do not show a rerun action unless a trusted historical-market-data workflow is
actually available. A stored report is inspectable data, not an executable
backtest engine.
- On mobile, use the shared off-canvas sidebar, a separate detail route, sticky
back action, and no horizontal page overflow at 390px or 360px.
- Keep the virtual-only boundary visible. Do not describe L2 as Futu paper trading
or L3 as real trading anywhere in this app.
Metric Rules
- Calculate position P/L as
quantity * (latest reference price - virtual entry price) and account return as NAV / nominal capital - 1.
- Treat the account's baseline date as the start of nominal-capital performance.
Do not compare, rank, or aggregate returns as comparable when baseline dates or
quote provenance are missing. Display missing metrics as unavailable, never as
zero.
- Reconcile each account NAV against cash plus position market values. Flag a
mismatch before allowing promotion.
- Calculate total-book return from summed account NAV and summed nominal capital.
- Calculate regression snapshot contribution as
strategy account P/L / total nominal capital; calculate the removal case from the remaining accounts.
- Sort and compare dated backtest reports only after checking that report date,
window start/end, method, coverage, and benchmark are present.
- Compare strategies on the same window and benchmark before ranking them.
- Keep Demo observations fixed and dated. Never present them as live data.
- Format account and position money in CNY. Show the Chinese security name first
and retain the six-digit code as secondary identity.
Completion Criteria
Finish only when:
pnpm --dir content/kelly-invest-stock-app dev remains supported and deterministic checks pass;
- Strategy overview/detail, L1/L2/L3 strategy filters, manual stage marking, and
Regression work on desktop and mobile;
- every strategy has one virtual account plus explicit selection and invalidation
rules;
- the five-resource declaration, additive schema migration, and lazy provisioning
pass fixture tests;
- research evidence and manual approvals persist in Busabase, with reason and
account snapshot visible in the strategy timeline;
- normal mode uses Busabase, while Demo is explicit, deterministic, and labeled;
- no brokerage path, real-money stage, trading action, or personalized investment
claim exists; and
- available dependency-skill deployment and real-data checks pass.
Stop Conditions
Stop before consequential Busabase mutation when the target Space is ambiguous,
the viewer lacks permission, ownership cannot be proven, a stale record would be
overwritten, or the request crosses into brokerage execution or money movement.
1---2name: kelly-invest-stock3description: Build and operate a Busabase-backed mainland China A-share strategy experiment desk with a bundled local Hono App-in-Skill, evidence-backed strategy research, strategy-level L1/L2/L3 manual maturity approvals, one CNY virtual ledger per strategy, and dated strategy backtest reports. Use when the user invokes $kelly-invest-stock or /kelly-invest-stock, wants to define or compare A-share strategies, inspect a strategy and its virtual book, record research evidence, manually approve strategy maturity, or review dated backtests, drawdown, and contribution to the total book. It never connects to a brokerage, places orders, moves money, or presents generated analysis as personalized investment advice.4---56# Kelly Invest Stock78Operate a compact strategy experiment desk. Keep the first screen centered on a9large strategy table: concise thesis, maturity label, account NAV, return,10benchmark, drawdown, cash, and virtual positions. Open a row for the complete11strategy and ledger detail.1213## Mandatory Dependencies1415Before changing the app:16171. Read and follow `$kelly-app-skill-creator` for product behavior, responsive UI,18 and the canonical local `content/kelly-invest-stock-app/` artifact.192. Read and follow `$busabase` for connection, target Space, ChangeRequests,20 review, and merge behavior.213. Read and follow `$busabase-app-creator` for resource modeling, AirApp runtime,22 security, validation, and deployment.234. Read `references/stock-sdk.md` before changing market-data ingestion.2425If a dependency is unavailable, continue safe local artifact work but stop before26the unavailable deployment or Busabase operation. Never create a second27persistent backend.2829## Product Boundary3031- Limit the product to mainland China A shares. Preserve six-digit stock codes,32 show Chinese security names as the primary identity, and use CNY for every33 virtual account, price, market value, P/L, and portfolio total.34- Keep every account, position, return, stage, and regression result virtual.35 Never connect to Futu or another brokerage, create order UI, or call a trading36 API.37- Give every strategy exactly one virtual account and default every new strategy38 to `L1`.39- Treat `L1`, `L2`, and `L3` as manual labels on the whole strategy, never on an40 individual stock:41 - `L1`: default basic observation;42 - `L2`: manually marked advanced observation;43 - `L3`: manually marked high-confidence observation.44- Do not copy the live-trading meaning of L2/L3 from `invest-ui`. In this skill,45 changing a label never changes execution mode, account type, or capital.46- Keep thesis, evidence, assumptions, confidence, and invalidation separate. A47 label or score is not a recommendation.48- Use exact-pinned `stock-sdk@2.4.0` only in reviewed trusted execution. Browser49 code performs no public market fetch.5051## Data And Modes5253- Use Busabase as the persistent source by default. A normal invocation or URL54 must never silently switch to Demo.55- Enter Demo only when the user explicitly asks to open or update Demo. Demo data56 is deterministic, clearly labeled, and not persistent.57- Use 10 recognizable investor-style Demo strategies such as Buffett, Munger,58 Duan Yongping, Peter Lynch, Howard Marks, Fisher, Graham, Li Lu, Templeton, or59 Soros style examples. Build every Demo basket from clearly labeled A-share60 examples and use a fixed CNY 1,000,000 nominal account per strategy.61 Label them as style reproductions; never imply actual holdings, endorsement, or62 current advice.63- Read and write persistent state through `busabase-sdk`. Stage changes use a64 `records.changeRequest` update to the strategy record's `status` field and a65 dated approval record containing the human reason and account snapshot. Never66 persist stage changes in browser storage or local files.67- Keep Busabase record page size inside the provider, at no more than the API's68 supported maximum. Follow `nextCursor` until exhaustion and never put transport69 pagination in a Base declaration or treat one page as the complete dataset.70- Offer the deterministic classroom seed only in a completely empty Busabase71 workspace. Submit one reviewable bulk ChangeRequest per Base without automatic72 merge; the user or Space reviewer decides whether to merge it.7374## Core Resources7576Keep five application-owned Bases under one application Folder:7778- `strategies`: name, key, family, `status`, thesis, selection rule,79 invalidation rule, review cadence, next review time, benchmark, and confidence.80- `ledger-accounts`: one virtual account per strategy with nominal capital, NAV,81 cash, benchmark return, maximum drawdown, update time, and return baseline date.82- `ledger-positions`: virtual quantity, entry price, reference price, market83 value, weight, price source/time, strategy key, six-digit A-share code, and84 Chinese security name.85- `strategy-backtests`: dated strategy-level reports with window start/end,86 methodology, coverage, benchmark, total return, CAGR, volatility, Sharpe,87 maximum drawdown, benchmark-relative return, and bias/source notes.88- `strategy-reviews`: dated research sources, source freshness, supporting and89 counter evidence, account snapshots, manual stage decisions, reviewer, reason,90 and the associated ChangeRequest ID.9192Provision a new empty workspace lazily through one Busabase structure93ChangeRequest, re-read the Folder, and use only validated materialized IDs. For94an owned older schema, submit only declared suffix fields through reviewable field95ChangeRequests, wait for approval, then update resource metadata. Reject reordered,96changed, or otherwise incompatible fields. Ignore legacy app-owned resources97outside this declaration; never delete or adopt them implicitly.9899## Operating Loop100101### Research102103Define a strategy's thesis, selection rule, invalidation rule, benchmark, review104cadence, next review time, and virtual account before evaluating it. Preserve105research source, source date, supporting evidence, counter evidence, and data106freshness in a dated review record.107108### Plan109110State the evidence needed for the next review. New strategies remain L1. Treat an111L2/L3 change as a human maturity judgment, not an automated promotion or trading112authorization.113114### Action115116Allow reviewed research updates, virtual-ledger records, and mouse-driven manual117stage marking. Before promotion, require complete strategy rules, one account with118a baseline date, dated research evidence, quote provenance, and reconciled NAV.119Require a human reason and confirmation for every stage change. Send persistent120stage changes through Busabase ChangeRequest, write the approval timeline record,121and reload canonical records after materialization.122123### Retrospective124125Compare virtual return, benchmark, maximum drawdown, and contribution to the126whole book. Record whether thesis or process failed before changing a strategy's127rules.128129## UI Contract130131- Use a fixed desktop sidebar with Strategy, L1, L2, L3, Regression, and Help &132 Settings. Do not add a separate Virtual Ledger tab.133- Make the Strategy route a large full-width table that combines strategy summary134 and ledger reality. Clicking the entire row opens Strategy Detail.135- Put the manual L1/L2/L3 segmented control and compact performance summary at136 the top of Strategy Detail. Below it, use shareable hash-routed tabs in this137 order: `组合持仓`, `研究与审批`, `策略逻辑`, `回测表现`.138- Open `组合持仓` by default. Make it the dominant detail surface with account139 NAV/capital/cash/P&L, invested-versus-cash allocation, and a full-width table140 showing Chinese security name, six-digit code, quantity, virtual entry price,141 reference price, virtual market value, portfolio weight, and virtual P/L. Keep142 cash visible as part of the portfolio rather than hiding it in a summary.143- Make L1/L2/L3 routes filter strategies, not stocks.144- Sort the default strategy table by next review time with missing or overdue145 review dates first. Do not rank the default workflow by return or confidence.146- In `研究与审批`, show dated positive and counter evidence, source provenance,147 freshness, stage decisions, human reasons, reviewer, snapshot metrics, and148 ChangeRequest IDs. Clearly state that Demo approvals reset on full refresh.149- Treat Strategy/L1/L2/L3 navigation as an in-memory strategy filter after the150 desk has loaded. Preserve the sidebar and workspace header DOM, update only151 the main strategy content, and do not refetch Busabase or show a full-page152 loading state for these route changes.153- Make Regression a dated strategy backtest table aligned with `invest-ui`:154 report date, start/end dates, window label, methodology, coverage, total155 return, CAGR, volatility, Sharpe, maximum drawdown, and benchmark-relative156 return. Keep hindsight warnings visible. Show current virtual-book contribution157 (`strategy P/L / total nominal capital`) and the removal case in a clearly158 separate secondary section. Do not invent a backtest or any historical metric159 without a stored dated report backed by historical observations.160- Do not show a rerun action unless a trusted historical-market-data workflow is161 actually available. A stored report is inspectable data, not an executable162 backtest engine.163- On mobile, use the shared off-canvas sidebar, a separate detail route, sticky164 back action, and no horizontal page overflow at 390px or 360px.165- Keep the virtual-only boundary visible. Do not describe L2 as Futu paper trading166 or L3 as real trading anywhere in this app.167168## Metric Rules169170- Calculate position P/L as `quantity * (latest reference price - virtual entry171 price)` and account return as `NAV / nominal capital - 1`.172- Treat the account's baseline date as the start of nominal-capital performance.173 Do not compare, rank, or aggregate returns as comparable when baseline dates or174 quote provenance are missing. Display missing metrics as unavailable, never as175 zero.176- Reconcile each account NAV against cash plus position market values. Flag a177 mismatch before allowing promotion.178- Calculate total-book return from summed account NAV and summed nominal capital.179- Calculate regression snapshot contribution as `strategy account P/L / total180 nominal capital`; calculate the removal case from the remaining accounts.181- Sort and compare dated backtest reports only after checking that report date,182 window start/end, method, coverage, and benchmark are present.183- Compare strategies on the same window and benchmark before ranking them.184- Keep Demo observations fixed and dated. Never present them as live data.185- Format account and position money in CNY. Show the Chinese security name first186 and retain the six-digit code as secondary identity.187188## Completion Criteria189190Finish only when:191192- `pnpm --dir content/kelly-invest-stock-app dev` remains supported and deterministic checks pass;193- Strategy overview/detail, L1/L2/L3 strategy filters, manual stage marking, and194 Regression work on desktop and mobile;195- every strategy has one virtual account plus explicit selection and invalidation196 rules;197- the five-resource declaration, additive schema migration, and lazy provisioning198 pass fixture tests;199- research evidence and manual approvals persist in Busabase, with reason and200 account snapshot visible in the strategy timeline;201- normal mode uses Busabase, while Demo is explicit, deterministic, and labeled;202- no brokerage path, real-money stage, trading action, or personalized investment203 claim exists; and204- available dependency-skill deployment and real-data checks pass.205206## Stop Conditions207208Stop before consequential Busabase mutation when the target Space is ambiguous,209the viewer lacks permission, ownership cannot be proven, a stale record would be210overwritten, or the request crosses into brokerage execution or money movement.