# Clasig > Clasig is a broker-independent trading research workflow. It publishes rule-based market scenarios with the trigger, the invalidation and the evaluation method fixed before the outcome is known, then keeps every outcome, losses and unresolved cases included, in an archive whose hash-chained receipts anyone can re-verify. Live reference data and a persisted forward record. Purchases are not open. Current reference quotes refresh about every 30 seconds and retain event, fetch and observation times. Completed H1 bars drive the persisted forward record. Stale or unavailable data is reported explicitly. Historical replay examples are separate at /replay/. List and archive responses default to 20 records and allow limit=1..50. total and counts describe the whole matching selection. Follow nextCursor with the same filters until it is null; one page is not the complete archive. archive.json has complete=true only when an unfiltered response contains every record. ## Use Clasig - [MCP server](https://clasig.io/mcp): seven read-only tools over Streamable HTTP, no pilot code for public reads. - [Scenario page](https://clasig.io/agent/v1/scenarios.json): dynamic current summaries; choose an actual id before opening a detail. - [OpenAPI](https://clasig.io/openapi.json): exact query parameters and bounded-page schemas. - [Reference quotes](https://clasig.io/live/api/quotes): quote time and freshness, separate from H1 evaluation. Private credential only. ## Verify the record - [Published root](https://clasig.io/agent/v1/root.json): persisted publication time; request includeHeads=true to retain heads. - [Archive page](https://clasig.io/agent/v1/archive.json): follow nextCursor until null; never treat the first page as the whole record. - [Method and test vectors](https://clasig.io/agent/v1/method.json): receipt algorithm, evaluation assumptions and verification cases. - [Root timestamps](https://clasig.io/agent/v1/anchors.json): Bitcoin-anchored OpenTimestamps proofs of published roots. Download /agent/v1/anchors/{root}.ots and run ots verify -d {root} clasig-root-{root}.ots. - Input bars: agent/v1/scenarios/{id}/bars.json returns the archived bars behind a scenario inputHash, so the fingerprint can be recomputed after the working window moves on. Private credential only: vendor market data is for internal use. - [Full reference](https://clasig.io/llms-full.txt) ## About - [Product and live status](https://clasig.io/agent/v1/about.json) - [Agent guide](https://clasig.io/agents) - [MCP server card](https://clasig.io/mcp/server-card) ## Historical replay - [Historical browser](https://clasig.io/replay/): earlier replayed prices and modelled examples, separate from live publication. - [Historical agent guide](https://clasig.io/replay/agents): snapshot-specific counts, dates, receipts and worked examples. ## Agent instructions Clasig (live engine). Clasig is a broker-independent trading research workflow. It publishes rule-based market scenarios with the trigger, the invalidation and the evaluation method fixed before the outcome is known, then keeps every outcome, losses and unresolved cases included, in an archive whose hash-chained receipts anyone can re-verify. Live reference data and persisted forward records. Each scenario names its feed, the feed's rights profile and how its bars were built. Historical replay examples are separate. Start with list_scenarios, open one with get_scenario, and check its receipt with verify_scenario or recompute it yourself (explain_method topic "receipts"). Every R value is modelled under each scenario's published evaluation version, never an execution. Historical replay retains eval.v1; new forward scenarios use eval.v2. A publication-overlap touch is unresolved with no entry, return or loss bound. Other unresolved cases may carry a bound labelled "if counted as a loss". Never state: any hit rate, win rate, accuracy, return or profitability figure, from the preview or otherwise; that a scenario is a signal, a tip or a recommendation to trade; that historical replay examples are a live forward record or customer executions; a price, a launch date or that purchases are open; that Clasig connects to, requires or is affiliated with any broker; that a valid receipt means a scenario was correct or profitable. ## Published rules ### Trend pullback (trend-pullback v1) In an established trend (EMA50 beyond EMA200 and moved in the trend direction over the last 10 bars), price touches the EMA20 within the 5 bars before the signal bar while none of those closes falls more than 0.5 ATR through EMA50; the signal bar then closes beyond EMA20 on the trend side, closing in the trend direction. Triggers on a trade through the signal bar extreme; protective level 0.25 ATR beyond the 6-bar pullback extreme; objective 2R. Skipped when the trigger-to-protective distance exceeds 3 ATR. ### Range breakout (range-breakout v1) A compressed 24-bar range (width at most 4 ATR) is closed beyond by more than 0.1 ATR by a bar that closes in the breakout direction. Triggers on a trade through the breakout bar extreme; invalidated by a close back inside the range by a quarter of its width; protective level at the range midpoint; objective one range width. Skipped when the trigger-to-protective distance exceeds 4 ATR. ### Sweep and reclaim (sweep-reclaim v1) The most recent confirmed swing level (3 bars each side) formed 10 to 60 bars earlier and held on every close since is traded through by at most 1 ATR, and the signal bar closes back on the original side, closing in the reversal direction. Triggers on a trade through the signal bar extreme; protective level 0.1 ATR beyond the sweep; objective 2R. Skipped when the trigger-to-protective distance exceeds 2.5 ATR. ## Evaluation - Each scenario's evaluation.id fixes its published evaluation version. Historical replay preserves eval.v1; new forward scenarios default to eval.v2. For both versions, reference OHLC is treated as mid for scoring, not an observed bid/ask midpoint. Each scenario's source label identifies cached provider OHLC or sampled reference rates; neither describes executable bid/ask fills. - eval.v1 preserves its original scoring from the signal bar close, including the first interval before publication. Its published scenario text, receipts and historical results remain unchanged. - eval.v2 does not score bars wholly before publication. If a bar overlapping publication touches the trigger, objective or protective level, the scenario is unresolved (publication_overlap), with no entry, return or loss bound. A clean overlapping bar still counts in the window and preserves continuity; its close can invalidate the pending scenario after publication. - Entry and exit each pay half the assumed spread; a round-trip fee is deducted. Both assumptions are published per market (see list_markets). - Subject to the published version's overlap rule, a pending scenario triggers on the first bar that trades at or through its trigger level. Otherwise a bar CLOSE beyond the invalidation level invalidates it, and reaching the end of the trigger window (counted in bars from the signal close) without a trigger expires it. An opening gap past the trigger fills at the open; a gap past both the trigger and the objective expires the scenario with no entry assumed. - After the trigger, the scenario closes at the objective (target_hit), at the protective level (stopped) or at the close of the bar that reaches the time limit, counted from the trigger bar (time_exit). Opening gaps past either level fill at the open. - Other unresolved cases can carry a conservative bound, if counted as a loss: a trigger bar that did not gap and also touches the protective level (the protective level may have traded first), or any bar that touches both the protective level and the objective. A trigger bar that gapped past the trigger and touches only the protective level is stopped. Missing bars while the market was open are also unresolved (data_gap). Publication overlap carries no such bound. - netR is the modelled result in multiples of the planned risk, after spread and fee. ## Receipts - A record is {scenario, events}. Each event has exactly the fields scenarioId, seq, type, at, data, prevHash and hash. - canonicalJson(value) is the JSON Canonicalization Scheme, RFC 8785 (JCS), so any JCS library computes it: JSON with no whitespace; object keys sorted by UTF-16 code unit order (keys whose value is undefined are dropped); strings escaped exactly as JavaScript JSON.stringify (ES2019) escapes them; numbers read as IEEE-754 doubles and written as JavaScript writes them: the shortest digits that round-trip, plain decimal when 1e-6 <= |x| < 1e21 (0.00007, 5, never 5.0), otherwise exponent form (1e-7, 1e+21); -0 is written 0. Non-finite numbers are invalid. - sha256hex(text): SHA-256 of the UTF-8 bytes of text, as 64 lowercase hex characters. - Every event: hash = sha256hex(canonicalJson({scenarioId, seq, type, at, data, prevHash})), and scenarioId = scenario.id. - Event 0 has type "published", prevHash = 64 zeros and data.scenarioHash = sha256hex(canonicalJson(scenario)), which binds the whole scenario (text, plan, reasons, evaluation and data basis) to the receipt. - Event n > 0 has seq = n and prevHash = the hash of event n-1. - The receipt is the hash of the last event. - Checks run in this order and the first failure is reported with the failing event's own seq field: the first event is not "published" (seq 0); then, event by event, scenarioId differs from scenario.id ("event belongs to another scenario"), seq differs from its position ("sequence gap"), prevHash differs ("chain broken"), the recomputed hash differs ("event altered"), and for event 0 the scenarioHash differs ("scenario content altered after publication"). - archiveRoot = sha256hex(canonicalJson([[scenarioId, receipt], ...])) over every record, pairs sorted by scenarioId in UTF-16 code unit order, ids unique. root.json lists the heads as [scenarioId, receipt, eventCount]. - Store the receipts, root and heads you read. Later, each stored head [scenarioId, receipt, eventCount] must still be the hash of event eventCount-1 of that scenario: a missing scenario or a different hash means history was rewritten. A chain cut back to an earlier event still verifies on its own, so only a stored receipt or head catches a removed newest event. - Python: use an RFC 8785 library (pip install jcs, then sha256 of jcs.canonicalize(value)). A plain json.dumps(sort_keys=True, separators=(",", ":"), ensure_ascii=False) is wrong for floats: Python writes 7e-05 where JavaScript writes 0.00007 (every EURUSD and GBPUSD scenario has fee 0.00007) and 1e-07 where JavaScript writes 1e-7. Check any implementation against the test vectors. - A valid receipt verifies internal consistency. Comparison with an earlier held receipt or head can detect a later rewrite. This does not establish independent publication time, scenario quality or an executed trade. Read the root before and after collecting all archive pages. If it changes, restart collection. Do not invent a root, example, count or publication time when no registered record exists. ## Timestamps - Each newly published archive root is submitted, at most once an hour, to public OpenTimestamps calendars (a.pool.opentimestamps.org, b.pool.opentimestamps.org, finney.calendar.eternitywall.com). They commit it into a Bitcoin transaction, so the time a root existed no longer rests on Clasig's own clock or database. - The proof is a standard detached OpenTimestamps file over the 32 bytes of the root: GET /agent/v1/anchors/{root}.ots. /agent/v1/anchors.json lists the newest proof per root, most recent first, with its status (pending until a Bitcoin block confirms it, usually within hours, then complete): 20 per page by default, limit=1..50, and follow nextCursor until it is null to reach older roots. - Verify with the standard client (pip install opentimestamps-client): ots verify -d {root} clasig-root-{root}.ots. It needs a Bitcoin Core node (a pruned node works) and prints "Success! Bitcoin block N attests existence as of ...". Without a node, ots info prints the block height and the merkle root the proof expects; compare that with the block on any explorer. - A pending proof can be completed by anyone with ots upgrade clasig-root-{root}.ots, which asks the same calendars directly. - A confirmed root fixes every receipt and head it commits to (see the root algorithm) no later than that block time: a later archive that cannot reproduce those heads was rewritten. Records published after the newest confirmed root are covered only by the next one. ## Data - Scenarios are computed once per market and timeframe and shared by every reader; nothing is personalised. - A bar is used only after it has closed. It can publish a scenario only if it reached the engine within the stated feed delay plus a grace period after its close; a later bar is monitored but never publishes (AC-004). A market whose newest bar is older than one bar plus the delay plus the grace period is shown as stale and publishes nothing. - Each scenario records its data basis: source, source kind (synthetic, licensed or reference), delay, rights profile, bar count and a SHA-256 of the exact input bars. - Scheduled event risks (risk factors keyed event.*) come only from official calendars: Federal Reserve Board, U.S. Bureau of Labor Statistics, U.S. Bureau of Economic Analysis, European Central Bank, Bank of England, Office for National Statistics, Eurostat, each cited as the source; get_scenario gives each event risk its official page (sourceUrl) and attribution. Contains public sector information licensed under the Open Government Licence v3.0. Licence: https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/ ECB meeting dates are available free of charge at www.ecb.europa.eu. Impact tiers are Clasig's own, not a vendor rating. Bank of Japan dates are not listed: Its terms exclude "the copying or reproduction of the content for commercial purposes" without prior permission (boj.or.jp/en/about/copyright.htm); no permission is recorded. A scenario in JPY carries the risk factor calendar.unlisted.JPY instead. - The calendar lists events through 2027-03-31 (UTC); from 21 days before that day, the agenda on every page names it. A scenario whose window runs past it carries the risk factor calendar.coverage_end; an unlisted stretch never means that no event is scheduled. - The historical preview replay runs without the event calendar, so its scenarios and receipts stay byte-for-byte as first published; event risks apply to live scenarios. ## Input bars - GET agent/v1/scenarios/{id}/bars.json returns the exact closed bars a live scenario was derived from, read from an append-only archive that outlives the 500-bar working window of the engine. - The bars are vendor market data for internal use, so this read needs the private credential (401 without it). The public verifies a receipt by its hash chain, the published root and its OpenTimestamps proof; an auditor holding the credential can also recompute inputHash from the bars. - bars holds dataBasis.barCount bars, oldest first, from dataBasis.firstBarOpen to the bar closing at dataBasis.lastBarClose. Only bars the engine had observed by publication are included (observedAt <= publishedAt); a hole filled later is not part of the hash. - Recompute: genesis = sha256hex(canonicalJson({instrumentId, timeframe, source: dataBasis.sourceId, genesis: 64 zeros})); then for each bar h = sha256hex(prev + "|" + openTime + "," + open + "," + high + "," + low + "," + close), numbers written as JavaScript writes them. The last h must equal dataBasis.inputHash. The same bars also reproduce the EMA and ATR values in reasons. - check.complete is false while the archive is still filling (the first minutes after a new archive starts) or when the bars predate the archive; check.matches is true only for a complete set whose hash equals dataBasis.inputHash. Scenarios on any other data source have no bar archive (404). - An archived bar is never overwritten. If a vendor later sends different values for the same bar, the original stays in bars and the new values are listed under revisions. - licence names each vendor and its terms. The bars are reference data shown under the rights profile on the scenario; do not repackage them as a price feed. ## Macro evidence - GET agent/v1/scenarios/{id}/evidence.json returns the macro environment a live scenario appeared in: US real and nominal yields, the 2s10s curve, the Federal Reserve H.10 nominal broad dollar index (not DXY), the latest BLS CPI and jobs releases, BEA PCE when configured, CFTC gold managed-money positioning for gold, and ECB reference rates (information only) for euro, sterling and yen pairs. - Each value is read from its original publisher (U.S. Treasury, BLS, BEA, CFTC, Federal Reserve, ECB), kept exactly as published, and every revision is stored as a new vintage. Each input names its series, period, publisher page and the time Clasig first retrieved it. - stored: true means the snapshot was built only from values Clasig had retrieved by the publication time, then stored once with its SHA-256 (check.matches recomputes it). stored: false is reconstructed from data retrieved later: pointInTime is false and it must not be used in a backtest. - Releases are compared with the previous release. No consensus forecast is used, so there is no surprise score. - The snapshot is context only. It does not rank, filter or change scenarios, and it is not part of the receipt chain. - GET agent/v1/macro.json lists every series, its newest vintage and its freshness against the publisher's own calendar (current, awaiting, late, unlisted, not_configured, no_data). - GET agent/v1/outcomes.json joins each scenario's outcome with its stored snapshot, newest first; scenarios published from the holdout date on are withheld so later validation runs on untouched periods. - Bucketed statistics (agent/v1/conditions.json) are private to the owner until a claim audit is done; never derive a hit rate, win rate or performance claim from outcomes.json. ## MCP Endpoint: https://clasig.io/mcp. Protocol versions: 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26. Tools: about_clasig, list_markets, list_scenarios, get_scenario, verify_scenario, get_archive_root, explain_method. List and archive responses default to 20 records and allow limit=1..50. total and counts describe the whole matching selection. Follow nextCursor with the same filters until it is null; one page is not the complete archive. archive.json has complete=true only when an unfiltered response contains every record.