{
  "standard_id": "marketworld_external_strategy_submission_standard_v1",
  "version": "2026-06-29",
  "purpose": "Public standard for external strategy backtest and submission without exposing MarketWorld private feature extraction or slice rules.",
  "security_model": {
    "public_user_receives": [
      "official historical dataset packages",
      "MarketWorld offline backtest kit",
      "official manifest and cost model hashes",
      "strategy package schema",
      "hash commitment requirements",
      "preflight and submission API routes"
    ],
    "public_user_does_not_receive": [
      "MarketWorld internal feature names",
      "MarketWorld private slice definitions",
      "MarketWorld private acceptance thresholds beyond public risk minimums",
      "MarketWorld private review implementation"
    ],
    "hash_policy": "Hashes are commitments, not encrypted data to decode. MarketWorld recomputes private review features from official data and submitted artifacts, then matches the submitted hashes and commitment_id.",
    "compute_policy": "Backtests must be run with the MarketWorld offline backtest kit on submitter-controlled compute. MarketWorld servers do not run user historical backtests."
  },
  "download_and_api": {
    "submission_standard": "GET /external-strategies/submission-standard",
    "offline_backtest_kit": "GET /external-strategies/offline-kit",
    "backtest_requirements": "GET /external-strategies/backtest-requirements",
    "dataset_catalog": "GET /external-strategies/backtest-datasets",
    "dataset_manifest": "GET /external-strategies/backtest-datasets/{dataset_id}/manifest",
    "dataset_file": "GET /external-strategies/backtest-datasets/{dataset_id}/files/{file_name}",
    "external_history_capabilities": "GET /external-history/capabilities",
    "external_history_download": "POST /external-history/downloads",
    "preflight": "POST /external-strategies?dry_run=true&replace=false",
    "formal_submit": "POST /external-strategies?replace=false",
    "submission_status": "GET /external-strategies/submissions/{submission_id}/status",
    "release_signatures": "GET /signatures.json",
    "release_public_key": "GET /release-public-key.pem"
  },
  "official_public_history_window": {
    "start": "2026-03-29",
    "end": "2026-06-26",
    "timezone": "UTC",
    "locked": true,
    "scope": "All public external historical data downloads must stay inside this fixed window; users choose provider, instruments, and supported granularity, but cannot request dates outside the window.",
    "news_event_packages": {
      "content_only": true,
      "forbid_effect_labels": true,
      "time_field_used_for_backtest": "available_time",
      "same_event_selection_rule": "same canonical event keeps only the earliest available_time inside the fixed public window",
      "public_fields": [
        "event_id",
        "canonical_event_id",
        "event_time",
        "published_time",
        "available_time",
        "source",
        "source_url",
        "headline",
        "content",
        "language",
        "content_sha256"
      ]
    }
  },
  "submission_backend": {
    "preflight_open": true,
    "formal_submit_requires_header": "X-MarketWorld-External-Token",
    "formal_submit_requires_queue": "Cloudflare KV binding MW_EXTERNAL_SUBMISSIONS_KV",
    "formal_submit_optional_raw_storage": "Cloudflare R2 binding MW_EXTERNAL_SUBMISSIONS_R2",
    "accepted_initial_status": "pending_private_review",
    "policy": "Formal submit stores the package and audit metadata only. Hash commitment packages do not enter the simulation candidate pool until MarketWorld internal private review approves the commitment_id."
  },
  "release_signature": {
    "algorithm": "Ed25519",
    "signature_file": "signatures.json",
    "public_key_file": "release_public_key.pem",
    "verify_script": "scripts/verify_external_strategy_release.py",
    "policy": "Users should verify signatures.json and file SHA256 values before running the offline backtest kit or using historical data packages."
  },
  "public_scorer": {
    "script": "scripts/external_strategy_public_scorer.py",
    "scorer_id": "marketworld_public_backtest_score_v4",
    "example": "python scripts/external_strategy_public_scorer.py --summary summary.json --slices slice_report.json --out score_report.json --fail-below-threshold",
    "runs_on_submitter_compute": true,
    "sample_adequacy_policy": {
      "rule": "Opening count is not judged as a fixed absolute number. The public scorer uses completed round trips normalized by dataset granularity, observed bar count, and backtest period. Backtest start/end dates are not fixed; the minimum sample requirement grows sublinearly with the selected window.",
      "round_trip_min_formula": "ceil(max(ref_round_trips_90d * floor_ratio, ref_round_trips_90d * sqrt(period_days / 90), ref_round_trips_90d * sqrt(bar_count / ref_bars_90d)))",
      "active_day_min_formula": "min(ceil(period_days), ceil(max(min(5, ceil(period_days)), 0.85 * sqrt(period_days))))",
      "required_summary_fields": [
        "granularity",
        "bar_count",
        "period_days",
        "open_count",
        "round_trip_count",
        "active_days"
      ],
      "classes": {
        "daily": "ref_round_trips_90d=12, ref_bars_90d=90, floor_ratio=0.35",
        "multi_hour": "ref_round_trips_90d=16, ref_bars_90d=540, floor_ratio=0.35",
        "hourly": "ref_round_trips_90d=24, ref_bars_90d=2160, floor_ratio=0.35",
        "intraday": "ref_round_trips_90d=40, ref_bars_90d=8640, floor_ratio=0.35",
        "high_frequency": "ref_round_trips_90d=120, ref_bars_90d=129600, floor_ratio=0.35"
      },
      "anti_gaming": "The minimum sample threshold is only a hard gate. Full sample credit requires twice the minimum target. passed=true also requires score >=70, all risk gates, at least two of three positive slices, and a passing final holdout slice.",
      "risk_minimums": {
        "net_return_after_cost_bps": 25.0,
        "profit_factor": 1.2,
        "sharpe": 0.5,
        "max_drawdown_pct": 15.0,
        "slice_max_drawdown_pct": 20.0,
        "passing_slice_ratio": 0.6666666667,
        "final_holdout_slice_required": true
      }
    }
  },
    "offline_backtest_runner": {
    "kit": "output/marketworld_external_backtest_offline_kit.zip",
    "download": "GET /external-strategies/offline-kit",
    "script": "scripts/external_strategy_offline_backtest.py",
    "runner_id": "marketworld_external_strategy_offline_backtest_v1",
    "runner_sha256_required": true,
    "example": "python scripts/external_strategy_offline_backtest.py --dataset-id mw_okx_btc_spot_perp_daily_v1 --strategy-entrypoint external_strategies/python/backtest/templates/strategy.py --strategy-id your_strategy_id --author your_name --out-dir runs/your_strategy_id",
    "server_backtest_compute": false,
    "policy": "Only packages generated by the MarketWorld offline runner and passing the public score threshold should be uploaded."
  },
  "required_backtest_evidence": {
    "schema": "BacktestEvidenceV2",
    "evidence_mode": "hash_commitment",
    "run_mode_allowed": ["client_side", "external_compute", "user_supplied"],
    "public_score": {
      "scorer_id": "marketworld_public_backtest_score_v4",
      "score_range": [0, 100],
      "minimum_upload_score": 70.0,
      "passed_required": true,
      "risk_gate_passed_required": true,
      "holdout_slice_passed_required": true,
      "score_report_json_sha256_required": true,
      "policy": "The submitter must compute the public score locally through the MarketWorld offline backtest kit after backtesting MarketWorld official data. Packages below the minimum upload score, failing any risk gate, failing the final holdout slice, or using an unchanged built-in reference strategy are rejected before storage."
    },
    "runner": {
      "runner_id": "must equal marketworld_external_strategy_offline_backtest_v1",
      "runner_sha256": "must equal the current MarketWorld offline backtest runner script hash",
      "server_backtest_compute": false
    },
    "dataset": {
      "provider": "marketworld",
      "dataset_id": "must come from GET /external-strategies/backtest-datasets",
      "data_fingerprint": "must exactly match the official dataset data_fingerprint",
      "manifest_hash": "must exactly match the official manifest_hash",
      "source_policy_id": "must exactly match the official source_policy_id",
      "venue_policy_id": "must exactly match the official venue_policy_id",
      "event_data_fingerprint": "required only for official news-event packages; must exactly match the official news_events file SHA256",
      "event_source_policy_id": "required only for official news-event packages; must exactly match the official event source policy",
      "news_event_policy": "news-event packages expose content and times only; affected symbols, impact labels, sentiment, direction, and side fields are forbidden",
      "venue_pair_id": "must exactly match one official venue_pairs[].venue_pair_id",
      "venue_scope_policy": "same_venue, same_brand, cross_venue, and spot_only are separate official package scopes; cross-exchange strategies must use an official cross_venue dataset package instead of mixing files from multiple packages",
      "timestamp_alignment": "cross_venue packages must declare the official alignment policy; current released cross_venue packages use UTC daily closed bars with zero timestamp lag and reject missing legs",
      "venue_bindings": "must exactly match official instrument_sources for every submitted leg",
      "granularity": "must be supported by the official dataset",
      "instruments": "must cover all instruments used by rules and signal legs"
    },
    "cost_model": {
      "model_id": "must exactly match the official dataset cost_model_id",
      "hash": "must exactly match the official dataset cost_model_hash"
    },
    "attestation_required_true": [
      "no_lookahead",
      "no_survivorship_bias",
      "costs_included",
      "client_side_compute",
      "marketworld_dataset_used",
      "venue_locked_data"
    ],
    "conditional_attestations_required_true": {
      "when_dataset_has_event_data_fingerprint": [
        "news_events_official_earliest_only",
        "news_events_available_time_only"
      ]
    },
    "artifact_hashes_required": [
      "summary_json_sha256",
      "trades_csv_sha256",
      "equity_curve_csv_sha256",
      "slice_report_json_sha256",
      "score_report_json_sha256",
      "config_json_sha256",
      "artifact_manifest_sha256"
    ],
    "commitments_required": [
      "opaque_feature_commitment_hash",
      "strategy_source_sha256"
    ]
  },
  "artifact_contract": {
    "summary.json": "Submit SHA256 only. Keep the file available for private review if requested.",
    "trades.csv": "Submit SHA256 only. Must include every fill/order event used in the backtest.",
    "equity_curve.csv": "Submit SHA256 only. Must include timestamped equity or cumulative PnL series.",
    "slice_report.json": "Submit SHA256 only. Generated by the submitter's runner using the public runner contract; MarketWorld does not publish private slice definitions.",
    "score_report.json": "Submit SHA256 only. Contains the public 0-100 score, threshold, pass flag, scorer_id, component scores, and generic performance inputs.",
    "config.json": "Submit SHA256 only. Must include dataset_id, period, cost_model_id, strategy parameters, and runner version.",
    "artifact_manifest.json": "Submit SHA256 only. Lists artifact names, sizes, hashes, and canonicalization rules.",
    "strategy_source": "Submit SHA256 of the exact source/model/config bundle used for the submitted backtest."
  },
  "runnable_runtime_contract": {
    "schema": "MarketWorldRunnableStrategyBundleV1",
    "purpose": "Required only when an external or employee strategy requests Docker execution after review. A JSON-only strategy package is evidence and registration, not executable code.",
    "required_files": [
      "strategy_package.json",
      "runtime/strategy.py",
      "runtime/requirements.lock"
    ],
    "conditional_files": {
      "runtime/wheels/": "Required when requirements.lock contains packages absent from the published runtime image. Every dependency must be pinned and supplied as an offline wheel.",
      "runtime/models/": "Required when the strategy uses model weights, feature normalizers, vocabularies or action maps. Each file must be declared with SHA256 in runtime.model_files."
    },
    "runtime_fields_required": [
      "runtime.type",
      "runtime.bundle_format",
      "runtime.entrypoint",
      "runtime.requirements_lock",
      "runtime.source_bundle_sha256",
      "runtime.timeout_seconds"
    ],
    "entrypoint_contract": "entrypoint must resolve to a function such as runtime/strategy.py:generate_signals. It reads a point-in-time snapshot and returns SignalIntentV1 objects only.",
    "hash_rule": "runtime.source_bundle_sha256 must equal backtest_evidence.commitments.strategy_source_sha256. A mismatch means the code to run differs from the code that produced the evidence and is rejected.",
    "security": {
      "container_only": true,
      "network": "none",
      "root_filesystem": "read_only",
      "user": "non_root",
      "host_secrets": "never mounted",
      "order_authority": false
    },
    "transport_limits": {
      "zip_max_bytes": 536870912,
      "expanded_max_bytes": 805306368,
      "single_file_max_bytes": 268435456,
      "max_file_count": 2000,
      "zip_rules": ["no_symlink", "no_absolute_path", "no_parent_path", "no_executable_binary", "no_secret_file"]
    },
    "compatibility": {
      "runtime_image_manifest_required": true,
      "image_digest_python_abi_and_cpu_architecture": "must be published by MarketWorld; do not assume wheels are cross-architecture compatible",
      "snapshot_schema": "marketworld_runtime_snapshot_v1",
      "signal_schema": "SignalIntentV1"
    },
    "documentation": "external_strategies/RUNNABLE_STRATEGY_BUNDLE_V1.md",
    "template_directory": "external_strategies/runnable_strategy_bundle_template"
  },
  "hash_format": {
    "pattern": "sha256:<64 lowercase hex characters>",
    "powershell_file_hash_example": "('sha256:' + (Get-FileHash .\\trades.csv -Algorithm SHA256).Hash.ToLower())",
    "python_file_hash_example": "hashlib.sha256(open(path, 'rb').read()).hexdigest()"
  },
  "submission_flow": [
    "Download this standard and the MarketWorld offline backtest kit.",
    "Generate or adapt a strategy so it outputs Strategy Package V2 / SignalIntentV1 without secrets.",
    "Run scripts/external_strategy_offline_backtest.py on submitter-controlled compute using the official dataset and cost model.",
    "Let the offline runner generate the required artifact files, public score, hashes, BacktestEvidenceV2, and commitment_id.",
    "Upload only strategy_package_ready_to_submit.json; failed score or failed validation packages must not be uploaded.",
    "If Docker execution is requested, upload the complete MarketWorldRunnableStrategyBundleV1 rather than JSON/hash evidence alone.",
    "Submit through dry_run first.",
    "Formal submit stores the package and audit trail.",
    "Hash commitment packages do not enter the simulation candidate pool until MarketWorld private review approves their commitment_id."
  ],
  "llm_instruction_prompt_zh": "你是策略接入工程师。请只根据本标准和我提供的策略说明，生成一个可离线回测、可提交到 MarketWorld 的 strategy_package_v2 JSON 和本地 runner 目录。要求：1）不要生成或猜测 MarketWorld 内部特征名、内部切片规则或私有阈值；2）回测只能读取 MarketWorld 官方数据包和成本模型；跨交易所策略必须使用官方 cross_venue 数据包，不能自行混用不同包；3）输出 BacktestEvidenceV2，evidence_mode=hash_commitment；4）生成 summary.json、trades.csv、equity_curve.csv、slice_report.json、score_report.json、config.json、artifact_manifest.json 的本地文件和 SHA256；5）本地公开评分器 scorer_id=marketworld_public_backtest_score_v4，score 必须 >=70 且 passed=true；v4 会按数据粒度、bar 数和回测窗口用平方根公式校验 round_trip_count/open_count，不限制回测开始/结束日期，不允许用高频碎单刷开仓次数；否则不要上传；6）策略包不得包含 API key、token、密码或账户信息；7）默认 enabled=false、review_requested=true；8）提交前先调用 POST /external-strategies?dry_run=true&replace=false 预检。",
  "template_file": "external_strategies/strategy_package_template_v2.json"
}
