Stock Analyst Agent
UOMP flagship example Agent (v1.0). Upgraded to a self-serve HTTP API deployable to Digital Ocean — anyone can connect, authorize, and analyze. Analysis dimensions: P&L, sector allocation, concentration, volatility, Sharpe, VaR, Beta, Alpha, correlation matrix, RSI/MACD indicators, rebalance suggestions, scenario analysis.
Full code and sample data are in the reference implementation under examples/stock-analyst.
Prerequisites
- Node.js >= 20
- pnpm 9 (
corepack enableornpm install -g pnpm@9) - Clone uomp-core
1. Build and initialize
pnpm install
pnpm build
pnpm cli init 2. Start the Auth + Guard service
In Terminal 1, start the local service:
pnpm --filter @uomp/server start Keep this terminal running.
3. Import private data
In Terminal 2, import the risk profile:
pnpm cli import ./examples/stock-analyst/sample-risk.json Import the holdings CSV (high sensitivity):
pnpm cli import ./examples/stock-analyst/sample-holdings.csv \
--tag portfolio:holdings \
--sensitivity high 4. Discover and connect the Agent
pnpm cli discover ./examples/stock-analyst
pnpm cli connect ./examples/stock-analyst 5. Authorize the Agent
Interactive authorization (recommended):
pnpm cli authorize ./examples/stock-analyst After selecting tags, the CLI prints:
export UOM_TOKEN="<token>"
export UOMP_BASE_URL="http://127.0.0.1:9374" Scripted authorization:
pnpm cli authorize ./examples/stock-analyst \
--scope portfolio:holdings profile:risk \
--output /tmp/uomp.env 6. Run the Agent
source /tmp/uomp.env
node ./examples/stock-analyst/index.js The Agent reads authorized data, fetches market quotes, and writes a Markdown report to output/.
7. Review sessions and audit logs
pnpm cli sessions -a
pnpm cli audit --limit 20 8. Revoke authorization
pnpm cli revoke <session-id> 9. Self-serve mode (HTTP API)
v1.0 adds an HTTP server mode: the Agent runs as a standalone service with a Web UI and REST API. Users paste their Token in a browser — no CLI needed.
node examples/stock-analyst/server.js
# Visit http://localhost:3080/ and paste your token
# Or use the API:
curl -X POST http://localhost:3080/analyze \
-H 'Content-Type: application/json' \
-d '{"token":"...","gateway_url":"..."}' Deploy to Digital Ocean to make it a public service. See the full README.
10. Remote mode: access via Gateway
If the Agent runs on a different machine or container, use apps/gateway to expose the local Memory Guard as an HTTPS + mTLS entry point. The Agent connects via mTLS, runs aggregate queries first, reads authorized data, and generates reports — then uploads the encrypted Payload and submits a deletion proof.
One-command end-to-end test (covers local + Gateway mode):
./scripts/test-stock-analyst.sh Analysis dimensions: P&L, sector allocation with target deviation, HHI concentration, annualized volatility, Beta, stop-loss/take-profit signals, drawdown alerts, portfolio volatility, bilingual reports.
See apps/gateway/README.md for full configuration.