myfund-cli
v0.1.0
Published
Agent-first JSON CLI for querying myFund portfolio data.
Readme
myFund CLI
Agent-friendly JSON CLI for querying myFund portfolio data without pushing the full beta API payload into your context window.
myfund calls the myfund.pl API, normalizes the parts agents usually need, and writes compact JSON that is easy to parse from scripts, skills, and automation.
Why Prefer the CLI Over the Official API?
The official myFund API is the source of truth, but its beta response can be too broad for agent workflows. Pulling the full payload into context by default wastes tokens, makes parsing more fragile, and exposes data the current task may not need.
This CLI keeps the workflow agentic:
- Token efficiency: focused commands return only the requested slice of portfolio data.
- Progressive disclosure: agents can start with
summary, then drill intopositions,position,allocation, orhistoryonly when needed. - Bounded history:
historyreturns one metric at a time and enforces range, interval, and point limits.
Requirements
- Node.js 20 or newer
- A myFund API key from myFund account settings
- A myFund portfolio name
Installation
Install from npm after the package is published:
npm install -g myfund-cliCodex Skill
This repository includes a Codex skill at skills/myfund-cli for agents that should prefer the CLI over direct myFund API calls.
npx skills add https://github.com/szemroda/myfund-cli --skill myfund-cliQuick Start
Configure an API key and a default portfolio:
myfund config set api-key <key>
myfund portfolios add "Portfolio in total" --description "Aggregated portfolio"
myfund portfolios set-default "Portfolio in total"Query the default portfolio:
myfund capabilities
myfund summary
myfund positions --sort value --limit 10
myfund history --metric value --period 90d --interval weeklyQuery a portfolio without storing it as the default:
myfund summary --portfolio "Long-term portfolio"Configuration
Default config path:
~/.config/myfund-cli/config.jsonUse a different config file for any command:
myfund --config ./myfund.config.json summaryAPI key resolution order:
- Config
apiKey MYFUND_API_KEY
Portfolio resolution order for API-backed commands:
--portfolio <name>- Config
defaultPortfolio
Useful config commands:
myfund config get
myfund config path
myfund config set api-key <key>
myfund config unset api-key
myfund config set default-portfolio <name>
myfund config unset default-portfoliomyfund config get reports whether an API key is configured, but never prints the key.
Commands
Portfolio Data
myfund capabilities
myfund summary [--portfolio <name>]
myfund performance [--portfolio <name>]
myfund positions [--portfolio <name>] [--sort value|weight|profit|return|daily-change] [--limit <n>] [--type <type>] [--source-portfolio <name>]
myfund position <query> [--portfolio <name>]
myfund allocation --by asset-type|position [--portfolio <name>]
myfund history --metric value|profit|contribution|benchmark|return [--portfolio <name>] [--period 30d|90d|1y|ytd|all] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--interval daily|weekly|monthly] [--max-points <n>]
myfund raw-response [--portfolio <name>]Portfolio Registry
The portfolio registry is local metadata stored in the config file. It does not create, rename, or delete portfolios in myFund.
myfund portfolios list
myfund portfolios add <name> [description]
myfund portfolios add <name> --description <text>
myfund portfolios remove <name>
myfund portfolios set-default <name>Config
myfund config get
myfund config path
myfund config set api-key <key>
myfund config unset api-key
myfund config set default-portfolio <name>
myfund config unset default-portfolioOutput Contract
Successful commands write minified JSON to stdout.
myfund capabilities returns an agent-facing JSON catalog of commands, when to use each command, important options, output shapes, and examples. Agents should call it first when the right command is unclear.
Example success shape:
{"portfolio":"Portfolio in total","value":12345.67,"periodReturns":{"1m":1.23,"ytd":4.56}}Errors write minified JSON to stderr and return a non-zero exit code.
Example error shape:
{"error":{"code":"MISSING_PORTFOLIO","message":"Missing portfolio. Pass --portfolio or configure defaultPortfolio."}}Common error codes include:
MISSING_API_KEYMISSING_PORTFOLIOPORTFOLIO_NOT_FOUNDMYFUND_API_ERRORNETWORK_ERRORINVALID_ARGUMENTSPOSITION_NOT_FOUNDAMBIGUOUS_POSITIONTOO_MANY_POINTSCONFIG_ERROR
History Queries
History is the largest and riskiest part of the myFund API response for agent workflows. The history command returns only one requested metric and enforces bounded output.
Supported metrics:
valueprofitcontributionbenchmarkreturn
Defaults:
--period 30dwhen no range is supplieddailyinterval for ranges up to 90 daysweeklyinterval for--period 1ymonthlyinterval for--period alland ranges longer than 90 days--max-points 366
Use either --period or --from/--to, not both.
Examples:
myfund history --metric value --period 30d
myfund history --metric return --period ytd
myfund history --metric profit --from 2026-01-01 --to 2026-06-30 --interval monthlyUse raw-response only when you explicitly need the complete myFund API payload:
myfund raw-response --portfolio "Portfolio in total"Development
npm run typecheck
npm test
npm run build
npm audit
npm run verifynpm run verify runs typecheck, tests, build, and audit.
The package targets Node.js 20+. Dependencies intentionally avoid packages that require newer Node versions.
