Strategy backtest (crypto, daily closes) ($0.009)
strategy_backtestPAID ($0.009 USDC via x402). Backtest a simple, stated trading rule on a crypto asset's daily USD closes from Coinbase Exchange and compare it with buying and holding over the same window. Strategies: sma_cross (long while the fast simple moving average is above the slow one), rsi_reversion (buy below rsiBuy, sell above rsiSell), dca (buy a fixed slice every dcaEveryDays), buy_and_hold. Signals formed at one close are executed at the next (no look-ahead); a fee of feeBps per trade; long or flat only. Returns total return, buy-and-hold return, max drawdown, Sharpe, exposure, win rate, the trades and an equity curve, with the full rules in method. 30-365 days. An empty body tests BTC, SMA 20/50 over 180 days. A ticker with no Coinbase USD market is 404 (not charged). A test of past prices, not a forecast or advice. Without payment this returns the 402 challenge; the fiatdock-mcp npm package pays automatically. Any answer the tool cannot produce is >= 400 and is NOT charged.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Length of the tested window in days, 30-365 (default 180) | |
| fast | No | sma_cross: fast moving-average length in days, 2-100 (default 20) | |
| slow | No | sma_cross: slow moving-average length in days, 3-200, longer than fast (default 50) | |
| asset | No | Crypto asset ticker with a USD market on Coinbase Exchange (BTC, ETH, SOL, …). Default BTC | |
| feeBps | No | Fee on every trade in basis points, 0-100 (default 10 = 0.1%) | |
| rsiBuy | No | rsi_reversion: buy when RSI falls below this, 1-50 (default 30) | |
| payment | No | Base64 of a single x402 v2 PaymentPayload (EIP-3009 transferWithAuthorization on Base USDC). OMIT it on the first call: the 402 you get back carries `howToPay.payloadTemplate` — the exact envelope to fill in — plus the price and the EIP-712 domain. Send it on the second call to complete the purchase; it is forwarded as the PAYMENT-SIGNATURE header, never as body data. Nothing is charged for the 402 itself, and a call that fails after payment settles nothing. | |
| rsiSell | No | rsi_reversion: sell when RSI rises above this, 50-99 (default 70) | |
| strategy | No | sma_cross (long while the fast moving average is above the slow one), rsi_reversion (buy when RSI falls below rsiBuy, sell when it rises above rsiSell), dca (buy a fixed amount every dcaEveryDays), buy_and_hold. Default sma_cross | |
| rsiPeriod | No | rsi_reversion: RSI length in days, 2-50 (default 14) | |
| capitalUsd | No | Starting capital in USD, 10-10000000 (default 1000) | |
| dcaEveryDays | No | dca: days between purchases, 1-30 (default 7) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asOf | Yes | ISO time the prices were read | |
| note | Yes | What a backtest is and is not | |
| asset | Yes | The asset tested (its ticker) | |
| market | Yes | The Coinbase Exchange market read, e.g. BTC-USD | |
| method | Yes | The rules, in full — enough to recompute every number | |
| params | Yes | The parameters the rule used (defaults filled in) | |
| period | Yes | The tested window: first and last completed UTC day, and its length | |
| sharpe | Yes | Annualised Sharpe ratio of daily equity returns (risk-free 0); null when equity never moved | |
| source | Yes | Where the prices come from | |
| trades | Yes | Number of trades (buys and sells) | |
| strategy | Yes | The rule tested: sma_cross, rsi_reversion, dca or buy_and_hold | |
| tradeList | Yes | The last 30 trades: date, buy or sell, execution close | |
| winRatePct | Yes | Share of closed round trips that ended above their entry, in percent; null with no closed trip | |
| endPriceUsd | Yes | Close on the last day of the window | |
| equityCurve | Yes | Up to 31 evenly spaced points of the equity curve, with the asset's close | |
| exposurePct | Yes | Share of days the rule held the asset, in percent | |
| startPriceUsd | Yes | Close on the first day of the window | |
| finalEquityUsd | Yes | Capital at the end, cash plus the asset at the last close | |
| maxDrawdownPct | Yes | The largest peak-to-trough fall of the rule's equity, in percent | |
| totalReturnPct | Yes | The rule's return over the window, fees included, in percent | |
| buyAndHoldReturnPct | Yes | Buying at the first close and holding, in percent (no fee) — the benchmark |