API, MCP and AI Agents
InvestTester works from code and from AI assistants, with no account: a link that opens a simulation, a price API, the simulation engine as one file for Node, and an MCP server. A summary for language models is in llms.txt.
Share links
A link opens the Portfolio page with its inputs and runs the simulation:
https://investtester.com/?p1=SPY-60_TLT-40&p2=QQQ-100&from=2015-01-01&cash=10000&dep=500&freq=monthly
p1,p2,p3: up to 3 portfolios. Assets are joined by _, each one TICKER-PERCENT; the percent is the text after the last -, so BTC-USD-50 is BTC-USD at 50%. URL-encode the ticker (+ is %2B). At most 10 tickers in all portfolios together.from,to: the first and last day, YYYY-MM-DD. Withoutto, the run goes to today.cash: the initial balance.dep: the deposit per period.freq: none, weekly, monthly, quarterly, biannual or yearly.- Another language: put its prefix before the query (
/pt-br?p1=BOVA11.SA-100). The results are in the currency of that language.
The watchlist has share links too: /watchlist?t=SPY,QQQ,BTC-USD.
Price API
GET https://investtester.com/api/search?assetCodes=SPY,QQQ&minDate=2015-01-01&maxDate=2025-12-31
The daily prices of up to 10 tickers, in the ticker syntax of the site (see Tickers). The answer is JSON, one item per ticker, with key, type, metadata and data (date, value and currency). Stock and ETF prices include dividends and splits. The interactive reference is the Swagger page.
- Limits: 10 tickers and 10 distinct codes per request, at most 4 requests at a time and about 5 per second per address. Above that, the answer is HTTP 429.
- The API sends no CORS headers: call it from a server or a script, not from a web page of another site.
Simulation engine for Node
The engine of the site as one file, for a script or an agent that runs commands (Node 20 or later). It takes its prices from the API above and prints the numbers of the site as JSON, without a browser:
curl -s https://investtester.com/tools/invest-tester.mjs | node --input-type=module - '{"portfolios":[{"SPY":60,"TLT":40},{"QQQ":100}],"from":"2015-01-01","cash":10000}'
- The argument is one JSON object:
portfolios(up to 3, each a ticker to percent map that sums to 100),from, and the optionalto,cash,deposits,frequency,languageandcurrency. - The answer has the inputs with the defaults it used, the
urlof the same run on the site, and for each portfolio itssummary(balance, return, annual return, volatility, max drawdown, Sharpe, Alpha, Beta, and the best and worst year and month) andwarnings. Fractions: 0.1234 is 12.34%. - A strategy, as on the Algo Trading page: in place of
portfolios, sendtickers(up to 10) andcodewith the JavaScript, orcodeFilewith the path of a file that has it:'{"codeFile":"strategy.js","tickers":["SPY","TLT"],"from":"2015-01-01","cash":10000}'. Optional:leverage,initMarginandminMargin. The answer has thesummary, thewarningsand the last 200 lines ofthis.printinmessages; it has nourl. The code runs in Node on your machine, not in the sandbox of a browser, so run only code that you trust. A run stops after 5 minutes. - License: run the file unmodified, piped from the site as above, to get results for yourself or for the person you act for. Do not save, change, redistribute or host it, or use it in a product or service.
MCP server
https://investtester.com/mcp is an MCP server (Streamable HTTP), with no login. Its tools:
- share_link: the link of a backtest from its inputs. The page runs the simulation in the browser.
- prices: the monthly prices (the last price of each month) of up to 10 tickers.
- engine: the Node command above.
Add it to an MCP client as a remote HTTP server with that URL. In Claude Code, for example: claude mcp add --transport http investtester https://investtester.com/mcp
The prices come from public market sources and can have gaps or errors. The results are historical simulations, not investment advice.