These examples are designed for the first hour after cloning TreLLM. They avoid
live LLM calls by default and write local artifacts under outputs/examples/.
The default examples are deterministic smoke tests and visual demos, not live
model benchmarks; live or cache-backed LLM runs are opt-in.
python scripts/run_showcase.pyOpen:
outputs/examples/showcase.html
The showcase links to a practical tour of auditable trajectories, execution realism, animated visual diagnostics, A-share market-rule interventions, portfolio baselines, paper broker exports, crypto microstructure stress, futures roll risk, redacted LLM cache manifests, and a custom plugin extension plus a contributor extension walkthrough and retail planning sandbox.
python examples/quickstart_core_benchmark.pyShows how two leaderboard cases share the same market, risk, execution, and evaluation stack.
Output:
outputs/examples/quickstart_core_metrics.json
python examples/visual_tour_demo.pyRegenerates the README-style audit lifecycle, execution realism, and diagnostics animations as local hands-on artifacts.
Output:
outputs/examples/visual_tour_index.htmloutputs/examples/visual_tour_summary.jsonoutputs/examples/visual_tour_audit_lifecycle.gifoutputs/examples/visual_tour_execution_realism.gifoutputs/examples/visual_tour_diagnostics_loop.gif
python examples/audit_trajectory_walkthrough.py
python scripts/render_audit_report.pyShows one complete observe-plan-risk-act-reflect trajectory, including risk clipping, pending orders, rejected orders, fills, memory events, and reproducibility metadata.
Output:
outputs/examples/audit_walkthrough_trajectory.jsonoutputs/examples/audit_report.html
python examples/sidecar_data_demo.pyShows how news.csv, macro.csv, filings.csv, and
alternative_data.csv can enter observations through the CSV provider without
changing the runner.
Output:
outputs/examples/sidecar_data/
python examples/akshare_csv_reuse_demo.pyShows the recommended A-share integration boundary: download data once,
normalize to OHLCV CSV, and reuse the standard CsvMarketDataProvider.
Output:
outputs/examples/akshare_csv_reuse_summary.jsonoutputs/examples/akshare_csv_reuse.svg
Live download command:
python -m pip install -e ".[ashare]"
python scripts/download_akshare_ashare_daily.py \
--symbols 600519.SS,300750.SZ \
--start 2021-01-01 \
--end 2026-05-14 \
--output-dir data/real/akshare_ashare_dailypython examples/ashare_market_rules_demo.pyShows how T+1, 10% price limits, and 100-share board lots become auditable risk-gate outcomes.
Output:
outputs/examples/ashare_market_rules_summary.jsonoutputs/examples/ashare_market_rules_orders.csvoutputs/examples/ashare_market_rules.svg
Hong Kong board-lot conversion uses the same market-rule boundary:
python examples/hk_market_rules_demo.pyIt converts target weights into raw share quantities, clips them to tradable board lots, and records regular-session plus stamp-duty assumptions.
Output:
outputs/examples/hk_market_rules_summary.jsonoutputs/examples/hk_market_rules_orders.csvoutputs/examples/hk_market_rules.svg
python examples/execution_realism_sweep_demo.pyShows how fees, quoted spread, slippage, latency, liquidity limits, and
rejections change agent behavior. The high_spread preset isolates a wide
bid-ask spread while keeping fill eligibility close to the default case, so the
artifact makes crossing cost visible rather than hiding it inside generic
slippage.
Output:
outputs/examples/execution_realism_sweep_summary.jsonoutputs/examples/execution_realism_sweep.csvoutputs/examples/execution_realism_sweep.svg
python examples/portfolio_markowitz_demo.pyShows passive, signal-weighted, and MVO-style allocation through the same strategy and evaluator interfaces.
Output:
outputs/examples/portfolio_markowitz_summary.jsonoutputs/examples/portfolio_markowitz.csvoutputs/examples/portfolio_markowitz.svg
python examples/representation_signature_demo.pyShows how tracked diagnostic tables can be turned into an offline visual artifact.
Output:
outputs/examples/representation_signature_summary.jsonoutputs/examples/representation_signature.svg
python examples/custom_plugin_demo.pyShows a local analyst plugin running through the existing strategy, risk, execution, memory, and evaluator stack.
Output:
outputs/examples/custom_plugin_summary.jsonoutputs/examples/custom_plugin.svg
python examples/extension_walkthrough_demo.pyShows how to add a custom analyst, risk manager, and evaluator without editing the core runner.
Output:
outputs/examples/extension_walkthrough_summary.jsonoutputs/examples/extension_walkthrough.svgoutputs/examples/extension_walkthrough_notes.md
python examples/retail_planner_demo.pyShows how investor profiles and goals become suitability-audited allocations, paper rebalance instructions, and futures margin estimates.
Output:
outputs/examples/retail_planning_report.htmloutputs/examples/retail_planning_summary.jsonoutputs/examples/retail_planning_audit.jsonoutputs/examples/retail_planning_allocation.svg
python examples/llm_cache_replay_demo.pyShows portable model-experiment metadata without shipping raw prompt/response text. This is not a live LLM run and does not replay raw model decisions; it is a public manifest of model coverage, parse rates, and cache portability.
Output:
outputs/examples/llm_cache_replay_summary.json
Use the CLI when you want the first run to actually call an LLM analyst:
$env:POE_API_KEY="..."
tradearena --benchmark llm-smoke `
--analysts poe-llm `
--llm-model gpt-5.5 `
--periods 3 `
--symbols SYN,ALT `
--llm-cache outputs/examples/poe_llm_smoke_cache.jsonlThe command runs one LLM-backed analyst case through the normal observe-plan-risk-act-reflect loop. If a matching cache row exists, the analyst replays it; otherwise it calls the configured provider and appends a local cache entry ignored by Git.
python examples/alpaca_paper_export_demo.pyConverts approved TreLLM orders into neutral JSON/CSV rows for Alpaca-style
broker review. It marks the adapter mode as offline_export and does not
submit orders.
Output:
outputs/examples/alpaca_paper_export/summary.jsonoutputs/examples/alpaca_paper_export/alpaca_paper_orders.jsonoutputs/examples/alpaca_paper_export/alpaca_paper_orders.csv
python examples/dry_run_broker_adapter_demo.pyValidates broker request shape through the generic dry-run adapter. It writes reviewable JSON/CSV handoff rows, runs the broker handoff validator, and makes no broker API calls.
Output:
outputs/examples/dry_run_broker_adapter/summary.jsonoutputs/examples/dry_run_broker_adapter/dry_run_orders.jsonoutputs/examples/dry_run_broker_adapter/dry_run_orders.csv
python examples/broker_capability_manifest_demo.pyWrites the adapter capability declaration reviewers should inspect before a broker-facing adapter is accepted. It names supported modes, account modes, credential policy, network access, and live-safety controls without reading credentials or submitting orders.
Output:
outputs/examples/broker_capability_manifest/capability_manifest.jsonoutputs/examples/broker_capability_manifest/capability_manifest.md
python examples/broker_approval_safety_demo.pyBuilds a redacted broker approval artifact, validates it, converts it into a
live_human_approved safety config, and proves that a bounded order passes
while an oversized order is blocked. It does not read broker credentials or
submit orders.
Output:
outputs/examples/broker_approval_safety/summary.jsonoutputs/examples/broker_approval_safety/broker_approval_artifact.json
python examples/broker_response_reconciliation_demo.pyMatches synthetic paper broker responses back to submitted client order IDs and writes a reconciliation artifact. It uses paper-mode sample responses only: no credentials are read and no live orders are submitted.
Output:
outputs/examples/broker_response_reconciliation/summary.jsonoutputs/examples/broker_response_reconciliation/broker_response_artifact.jsonoutputs/examples/broker_response_reconciliation/alpaca_paper_orders.json
python examples/broker_response_status_mapping_fixture_demo.pyWrites a schema-valid paper response artifact with accepted, rejected, partially filled, canceled, and unknown statuses plus recomputed reconciliation counts. The fixture is synthetic: no credentials are read and no live orders are submitted.
Output:
outputs/examples/broker_response_artifact/summary.jsonoutputs/examples/broker_response_artifact/response_artifact.jsonoutputs/examples/broker_response_artifact/alpaca_paper_orders.json
python examples/mock_paper_sandbox_client_demo.pyShows a broker-specific paper sandbox contribution pattern with an injected mock client. The fixture proves no default network call is made, writes a paper-mode handoff artifact, and records a broker response artifact through the generic paper sandbox skeleton.
Output:
outputs/examples/mock_paper_sandbox_client/summary.jsonoutputs/examples/mock_paper_sandbox_client/alpaca_paper_orders.jsonoutputs/examples/mock_paper_sandbox_client/paper_sandbox_response_artifact.json
python examples/operator_runbook_demo.pyWrites an offline operator checklist for live-capable paths. The artifact names the default mode, approval expiry, kill switch, reconciliation, rollback, and artifact-retention evidence, plus the incident owner and final live-readiness preflight validation command, without reading credentials or submitting orders.
Output:
outputs/examples/operator_runbook/summary.jsonoutputs/examples/operator_runbook/operator_runbook.md
python examples/live_readiness_preflight_demo.pyLinks the capability manifest, handoff artifact, approval binding, a response
artifact bound to the reviewed handoff hash and client_order_id, and operator
runbook into one review packet. It validates the chain locally and does not
authorize live submission.
Output:
outputs/examples/live_readiness_preflight/preflight_bundle.jsonoutputs/examples/live_readiness_preflight/preflight_response_artifact.jsonoutputs/examples/live_readiness_preflight/preflight_summary.json
python examples/holdings_csv_import_demo.pyLoads examples/fixtures/retail_holdings.csv into the retail planning sandbox
and produces paper rebalance diagnostics.
Output:
outputs/examples/holdings_csv_import/summary.json
python examples/futures_roll_risk_demo.pyUses contract metadata and a paper roll schedule to flag futures expiry or roll
risk in a normal RiskReport.
Output:
outputs/examples/futures_roll_risk/summary.jsonoutputs/examples/futures_roll_risk/futures_roll_risk.svg
python examples/crypto_microstructure_stress_demo.pyRuns a no-key synthetic crypto scenario with matching baseline and fee-tier/spread-shock execution presets. The artifact exposes fill rate, slippage cost, commission, rejected orders, partial fills, and pending orders while marking the settings as stress assumptions rather than venue calibration.
Output:
outputs/examples/crypto_microstructure_stress/summary.jsonoutputs/examples/crypto_microstructure_stress/crypto_microstructure_stress.svg
python examples/almgren_chriss_stress_demo.pyCompares the default execution-stress baseline with opt-in linear and concave market-impact proxies. The fixture reports modeled shortfall and calibration boundaries without claiming broker-grade transaction-cost calibration.
Output:
outputs/examples/almgren_chriss_stress/summary.jsonoutputs/examples/almgren_chriss_stress/summary.mdoutputs/examples/almgren_chriss_stress/almgren_chriss_stress.svg
python examples/liquidity_halt_demo.pyBuilds a deterministic paper-only trajectory where a delayed order is pending when a circuit halt begins. The artifact includes risk and execution reports for pending, partial, rejected, and blocked order outcomes.
Output:
outputs/examples/liquidity_halt/summary.jsonoutputs/examples/liquidity_halt/trajectory.jsonoutputs/examples/liquidity_halt/summary.mdoutputs/examples/liquidity_halt/liquidity_halt.svg
python examples/rl_policy_baseline_demo.pyWraps a deterministic mock RL allocation policy as a StrategyAgent so a real
FinRL/Qlib policy can later replace the scoring function while reusing the risk,
execution, trajectory, and evaluator stack.
Output:
outputs/examples/rl_policy_baseline/summary.jsonoutputs/examples/rl_policy_baseline/rl_policy_baseline.svg
python -m pytest tests -q
python scripts/run_showcase.py --reuse-existing