{"uid":"cap_6C3RMkE-wlzuxyEhQaio1","slug":"x402stock-backtest-api-69d6a8ac","name":"x402stock Backtest API","description":"Pay-per-call market and economic data API for AI agents: US stocks, ETFs and options, forex, crypto and on-chain perps, energy commodities, US and global macro (Fed, CPI, jobs, GDP, Treasury, World Bank), SEC filings, congressional trades, and market sentiment. No API keys, no accounts. Pay per request in USDC via x402 on Base.","url":"https://x402stock.xyz/api/v1/backtest/%7Bticker%7D?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD","DELETE"],"type":"string"},"queryParams":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["strategy","fast","slow","period","lower","upper","years","capital"],"properties":{"fast":{"type":"integer","default":50,"maximum":200,"exclusiveMinimum":0},"slow":{"type":"integer","default":200,"maximum":400,"exclusiveMinimum":0},"lower":{"type":"number","default":30,"maximum":99,"minimum":1},"upper":{"type":"number","default":70,"maximum":99,"minimum":1},"years":{"type":"number","default":3,"maximum":5,"exclusiveMinimum":0},"period":{"type":"integer","default":14,"maximum":100,"exclusiveMinimum":0},"capital":{"type":"number","default":10000,"maximum":1000000000,"exclusiveMinimum":0},"strategy":{"enum":["sma_cross","rsi_reversion"],"type":"string","default":"sma_cross"}},"additionalProperties":false}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["ticker","source","as_of","artifact","strategy","data","disclaimer"],"properties":{"data":{"type":"object","required":["bars","start_date","end_date","initial_capital","strategy","buy_hold","trades"],"properties":{"bars":{"type":"number"},"trades":{"type":"object","required":["count","win_rate_percent","avg_return_percent","best_percent","worst_percent","list"],"properties":{"list":{"type":"array","items":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"anyOf":[{"type":"number"},{"type":"string"},{"type":"null"}]}}},"count":{"type":"number"},"best_percent":{"type":"number"},"worst_percent":{"type":"number"},"win_rate_percent":{"type":"number"},"avg_return_percent":{"type":"number"}},"additionalProperties":false},"buy_hold":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"number"}},"end_date":{"anyOf":[{"type":"string"},{"type":"null"}]},"strategy":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"number"}},"start_date":{"anyOf":[{"type":"string"},{"type":"null"}]},"initial_capital":{"type":"number"}},"additionalProperties":false},"as_of":{"type":"string"},"source":{"type":"string","const":"x402stock"},"ticker":{"type":"string"},"artifact":{"type":"object","required":["id","url","format","expires_at"],"properties":{"id":{"type":"string"},"url":{"type":"string"},"format":{"type":"string","const":"png"},"expires_at":{"type":"string"}},"additionalProperties":false},"strategy":{"type":"object","required":["kind","label","params"],"properties":{"kind":{"type":"string"},"label":{"type":"string"},"params":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"number"}}},"additionalProperties":false},"disclaimer":{"type":"string"}},"additionalProperties":false}}}}},"responseSchema":{"type":"json","example":{"data":{"bars":1008,"trades":{"list":[{"bars_held":35,"exit_date":"2022-09-19T00:00:00.000Z","entry_date":"2022-08-01T00:00:00.000Z","exit_price":150,"entry_price":161.5,"return_percent":-7.12}],"count":6,"best_percent":27.1,"worst_percent":-7.2,"win_rate_percent":66.7,"avg_return_percent":9.4},"buy_hold":{"sharpe":0.72,"cagr_percent":12.1,"max_drawdown_percent":-31.2,"total_return_percent":58.1},"end_date":"2026-06-19T00:00:00.000Z","strategy":{"sharpe":0.94,"cagr_percent":13.2,"exposure_percent":71.3,"max_drawdown_percent":-18.4,"total_return_percent":64.2},"start_date":"2022-06-19T00:00:00.000Z","initial_capital":10000},"as_of":"2026-06-19T15:00:00.000Z","source":"x402stock","ticker":"AAPL","artifact":{"id":"abcdef0123456789abcdef0123456789","url":"https://x402stock.xyz/artifacts/abcdef0123456789abcdef0123456789.png","format":"png","expires_at":"2026-07-19T15:00:00.000Z"},"strategy":{"kind":"sma_cross","label":"SMA cross 50/200","params":{"fast":50,"slow":200}},"disclaimer":"Factual backtest over historical data, not investment advice. Past performance does not predict future results."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.5","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.5/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.5","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.5","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_SI3M0fGZRKk4TL3PJ4f2P","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.5","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Runs a historical backtest of SMA crossover or RSI reversion trading strategies on a given stock ticker, returning performance metrics, trade list, and a chart artifact","exampleAgentPrompt":"Run a backtest of a 50/200 SMA crossover strategy on AAPL over the last 3 years starting with $10,000 — I want to see the win rate, Sharpe ratio, max drawdown, and how it compares to just buying and holding.","exampleUseCases":null,"resultDescription":"Returns a JSON object with full backtest results including: number of price bars analyzed, start/end dates, strategy performance (CAGR, Sharpe ratio, max drawdown, total return, market exposure %), buy-and-hold benchmark comparison, list of individual trades with entry/exit dates and prices and return %, overall trade statistics (count, win rate, avg/best/worst return), a link to a PNG chart artifact, the strategy parameters used, and a disclaimer. Costs $0.50 USDC per call via x402 on Base.","failureModes":["Invalid or unknown ticker symbol returns an error","fast SMA period must be less than slow SMA period or validation fails","years parameter exceeding 5 returns a validation error","RSI lower bound must be less than upper bound","Insufficient historical data for the requested ticker and time window","Payment failure or insufficient USDC balance blocks the request","Strategy enum value not in ['sma_cross','rsi_reversion'] returns 422"],"whenToPreferThis":"Use this endpoint when you need quantitative backtesting results for US stocks or ETFs using classic technical strategies (SMA crossover or RSI reversion) with no API key setup required. Ideal for AI agents that need on-demand strategy evaluation paid per-call in USDC. Prefer this over full quant platforms when you want lightweight, single-ticker strategy simulation with a chart and trade log included.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-22T06:38:56.226Z","isFirstParty":false,"canonicalSlug":"x402stock-backtest-api-69d6a8ac"}