Files
hk-ipo/scripts/run_hk_ipo_analyst_once.sh
geometrybase 7cbdd533b0 Add A/H share-class mapping workflow
Request:
- Add a repeatable mechanism so HK IPO reports detect issuers that already have Mainland A shares.
- Include a third internet/official-exchange cross-check layer beyond structured history and prospectus scans.

Changes:
- Add listed_share_classes schema support for same-issuer A-share mappings and evidence links.
- Add scripts/archive_a_share_mappings.py to scan prospectus extracted text, reject sponsor/portfolio/cornerstone false positives, archive optional official web evidence and A-share/FX quote evidence, and export snapshots on write.
- Surface a_share_* fields in the analysis dataset and single-ticker report output.
- Update hk-ipo analyst/archivist skill rules and scheduled refresh prompt to require the three-layer A/H mapping check.

Verification:
- python3 -m py_compile scripts/archive_a_share_mappings.py scripts/build_analysis_dataset.py scripts/generate_ipo_report.py
- .venv/bin/python scripts/archive_a_share_mappings.py --as-of 2026-06-24T00:00:00Z --tickers 00668,01688,03661,09630 --dry-run
- .venv/bin/python scripts/build_analysis_dataset.py --db /tmp/hk_ipo_ah_dataset_test.sqlite --dataset /tmp/hk_ipo_ah_dataset_test.csv --report /tmp/hk_ipo_ah_model_test.md --as-of 2026-06-24T00:00:00Z
- .venv/bin/python scripts/generate_ipo_report.py 09630 --dataset /tmp/hk_ipo_ah_dataset_test.csv --stdout --as-of 2026-06-24T00:00:00Z
- git diff --check

Next useful context:
- Dry-run detected 00668->300866.SZ, 01688->002600.SZ, 03661->300661.SZ, and 09630->688630.SH.
- A false positive 01688->300476.SZ from a cornerstone investor parent was rejected by the issuer-context filter.
2026-06-24 07:21:21 +00:00

49 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
mkdir -p /run/hk-ipo
exec 9>/run/hk-ipo/analyst.lock
if ! flock -n 9; then
echo "$(date -Is) hk-ipo-analyst already running; skip"
exit 0
fi
cd "${REPO_ROOT}"
AS_OF="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
PROMPT_TEMPLATE="$(cat <<'EOF'
Use the `hk-ipo-analyst` skill from `.agents/skills/hk-ipo-analyst/SKILL.md`.
Run one scheduled HK IPO analyst refresh as of __AS_OF__.
Goals:
- Inspect the current worktree and recent git history first.
- Refresh the latest IPO candidate universe from online sources through `hk-ipo-archivist` before analysis.
- Update all relevant fresh network facts for the latest candidate report, especially live subscription-period market heat / margin subscription multiples, official T1 allotment demand when published, prospectus documents, listing calendars, and recent D1 review data.
- Refresh A/H or other onshore share-class mappings before rebuilding the report: use the structured `listed_share_classes` archive, scan prospectus extracted text with `scripts/archive_a_share_mappings.py`, and add internet / official-exchange cross-check evidence when supported.
- Keep unofficial subscription multiples in `ipo_market_heat` with their provider and `observed_at`; do not copy them into official T1 public oversubscription fields.
- Rebuild the analysis dataset after any archive refresh.
- Produce a complete latest broad IPO candidate report for actionable subscriptions, including ranking, fundamentals, break-risk/risk-reward, per-IPO notes, closed/waiting names, recent 30-day review, guardrails, and sources.
- In the break-risk/risk-reward/capital-efficiency section, include every current or recently closed ticker without confirmed D1 break/non-break information, even when its subscription has already closed and it is only waiting for T1/T2/D1.
- Write the dated report as `reports/YYYY-MM-DD_latest_ipo_candidates_analysis.md`, then copy the same final content to `reports/README.md` so the reports directory opens on the latest report.
- Keep stage discipline: no later facts leaking into earlier-stage conclusions.
- Write analyst output in Simplified Chinese.
- Commit only related project changes, including the dated report and `reports/README.md`, and push the current branch if upstream exists.
- If data is missing or stale, state the `data_gap` clearly instead of guessing.
- Do not ask interactive questions during this scheduled run.
- Do not change the systemd units or this wrapper script during this scheduled run.
EOF
)"
PROMPT="${PROMPT_TEMPLATE//__AS_OF__/${AS_OF}}"
codex --search \
-s danger-full-access \
-a never \
exec \
-C "${REPO_ROOT}" \
"${PROMPT}"