Developers / Examples / 01
From a market question
to a working API call.
Runnable examples for building with market data. Start with ZEC versus BTC: timestamped observations, fixed UTC windows, and a Python script you can make your own.
Market comparison
Did ZEC finish ahead of BTC?
The example calls compare_relative_return using ZECUSDT and BTCUSDT on Binance spot. It compares each market’s own open-to-close return over non-overlapping 12-hour windows. It does not use the ZECBTC cross pair.
00:00 UTC
Window opens
12 × 1h
Fixed window
12:00 UTC
Window closes
Relative return = ZEC return − BTC return, in percentage points. A positive value means ZEC finished ahead. A historical count is not a prediction of the next winner.
01 / Run it
Download the script, then run it in a terminal. There is nothing to install with pip.
curl -fSLO https://aipricepatterns.com/examples/beggy_zec_vs_btc.py
python3 beggy_zec_vs_btc.pyDefault grid: 00:00–12:00 and 12:00–00:00 UTC. Prints a readable summary and the latest finished windows. Run python3 beggy_zec_vs_btc.py --help for all options.
02 / Inspect the code
The full script handles initialization, JSON and SSE responses.
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "compare_relative_return",
"arguments": {
"base": "ZECUSDT",
"versus": "BTCUSDT",
"interval": "1h",
"horizonBars": 12,
"offsetBars": 0,
"recentWindows": 6
}
}
}POST https://aipricepatterns.com/api/mcp
The JSON above is the tool call after MCP initialization. The downloadable script performs the complete exchange. Switch to Full Python to copy everything.
03 / Know what comes back
Use --json for the full response. These are the useful blocks to start with:
- brief
- A readable summary of historical outcomes. Start here before interpreting individual statistics.
- recentWindows
- Finished windows with timestamped opens and closes, each market’s return, relative return and the observed winner.
- requestedWindow
- The specific round requested with --window-open, or an explicit unavailable result if it cannot be measured.
- currentWindow
- The round still in progress, bars elapsed and the side ahead so far. Its outcome is not final.
- regime
- Historical windows grouped by pre-open market conditions. Compares how wide relative returns were in calm, mid and wild regimes.
- coverage / data_coverage
- Measured history, source freshness, missing candles and limits. Inspect these before using observations in your application.
Keep open and finished windows separate
Only use a finished observation to determine a finished round’s outcome. currentWindow is still changing. A bar’s timestamp identifies its opening time; use the explicit window openUtc and closeUtc boundaries. Check unavailable observations and coverage rather than filling in missing candles.
04 / Make it yours
Change --base and --versus to compare BTCUSDT, ETHUSDT, SOLUSDT or ZECUSDT. Supported candle intervals are 5m, 15m, 1h, 4h and 1d. --horizon-bars is measured in candles: 12 on 1h is 12 hours; 12 on 5m is one hour.
This example measures observed prices and historical returns. It is not a signed settlement oracle or a guaranteed low-latency feed. The regime block describes window width, not a validated next-winner prediction.