Skip to content

Fize/mmtickerlab / sim-trade

sim-trade

Verified

A 股专用的确定性模拟交易系统。具备严格的数据真实性门禁、五档盘口真实撮合、T+1 规则、持仓盈亏计算及 SQLite 可审计流水账本。当用户需要进行模拟交易下单、模拟买入/卖出、查询模拟盘持仓、账户资产或重置模拟盘时触发(包含触发词:模拟买入, 模拟卖出, 模拟交易, 查持仓, 模拟盘, 交易账本, sim trade, paper trading)。

references/data_contract.md

View on GitHub
# Market data contract

The simulator treats provider data as untrusted input. A successful HTTP response alone is not sufficient for matching or valuation.

## Matching snapshot

A matching snapshot must contain:

- a supported six-digit A-share code and non-empty name;
- source and source timestamp in `Asia/Shanghai`;
- timestamp date equal to the order's trading date;
- age no greater than 30 seconds and no more than 5 seconds in the future;
- positive last price and previous close;
- explicit positive upper and lower price limits from the provider;
- a parseable listing date;
- `TRADING` status during order matching;
- at least one positive-price, positive-quantity level across the five-level bid/ask book.

An empty ask book at the upper limit and an empty bid book at the lower limit are valid matching snapshots when the opposite side exists, but provide no executable liquidity on that side. After the close, a snapshot may have no book and remain valid for valuation; it is never valid for matching. A security without explicit price limits is unsupported rather than guessed.

The East Money adapter requires provider status code `f292=2` for normal listing/trading eligibility and maps `f292=6` to `SUSPENDED`. Unknown values fail closed. A normal status without an executable book is `NO_BOOK`, not `TRADING`.

Store every snapshot used to evaluate an order in SQLite, including the raw provider payload. Never replace missing values with the order price, cost, previous close, zero, or an adjusted historical close.

## Valuation snapshot

Valuation requires positive identity and last-price fields. Its quote date must equal the latest official trading day on or before the report date. During an active session, apply the same 30-second freshness limit as matching. After the close or on a non-trading day, accept the latest official close snapshot.

If any held security fails valuation, return its valuation as `UNAVAILABLE`. Do not include a fabricated market value in account totals.

## Calendar

Use `AKShare.tool_trade_date_hist_sina` and persist the returned dates. A missing target date is not evidence that the exchange is closed when the calendar fetch itself failed. Fail closed until a successful calendar source or persisted date confirms the result.

## Provider implementation

The live adapter uses East Money for identity, listing date, explicit limits, and provider status. When East Money omits the order book for a normal security, it requires a Sina quote with the same code/name, previous close, a timestamp within 30 seconds, and a last-price difference no greater than the larger of CNY 0.05 or 0.5% of previous close before using its timestamp, last/pre-close, and five-level book. Any consistency mismatch or incomplete source fails closed. AKShare supplies the official trading-date series. Import `akshare_patch` before importing `akshare` so retries and East Money TLS handling are active.
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall