Skip to content

Commit 0039515

Browse files
Pigbibicodex
andcommitted
feat: add no-order IBKR reconciliation collector
Co-Authored-By: Codex <noreply@openai.com>
1 parent 9603026 commit 0039515

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Collect IBKR Reconciliation Evidence
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target:
7+
description: "Frozen live target to read; this workflow has no order path."
8+
required: true
9+
default: all
10+
type: choice
11+
options:
12+
- all
13+
- soxl_soxx_trend_income
14+
- tqqq_growth_income
15+
- global_etf_rotation
16+
- russell_top50_leader_rotation
17+
18+
permissions:
19+
contents: read
20+
id-token: write
21+
22+
env:
23+
GCP_PROJECT_ID: interactivebrokersquant
24+
GCP_REGION: us-central1
25+
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/303168642265/locations/global/workloadIdentityPools/github-actions/providers/github-main
26+
GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT: ibkr-platform-deploy@interactivebrokersquant.iam.gserviceaccount.com
27+
28+
concurrency:
29+
group: ibkr-reconciliation-evidence-${{ inputs.target }}
30+
cancel-in-progress: false
31+
32+
jobs:
33+
collect:
34+
name: Read ${{ matrix.profile }} baseline evidence
35+
if: ${{ inputs.target == 'all' || inputs.target == matrix.profile }}
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 10
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- profile: soxl_soxx_trend_income
43+
service: interactive-brokers-quant-live-u15998061-service
44+
- profile: tqqq_growth_income
45+
service: interactive-brokers-quant-live-u16608560-service
46+
- profile: global_etf_rotation
47+
service: interactive-brokers-quant-live-u18308207-service
48+
- profile: russell_top50_leader_rotation
49+
service: interactive-brokers-quant-live-u18336562-service
50+
steps:
51+
- name: Authenticate to Google Cloud
52+
uses: google-github-actions/auth@v3
53+
with:
54+
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
55+
service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}
56+
57+
- name: Set up gcloud
58+
uses: google-github-actions/setup-gcloud@v3
59+
60+
- name: Collect no-order reconciliation candidate
61+
env:
62+
SERVICE: ${{ matrix.service }}
63+
PROFILE: ${{ matrix.profile }}
64+
run: |
65+
set -euo pipefail
66+
service_url="$(gcloud run services describe "$SERVICE" --project "$GCP_PROJECT_ID" --region "$GCP_REGION" --format='value(status.url)')"
67+
test -n "$service_url"
68+
identity_token="$(gcloud auth print-identity-token --audiences="$service_url")"
69+
mkdir -p reports
70+
curl --fail --silent --show-error --max-time 90 \
71+
--request POST \
72+
--header "Authorization: Bearer ${identity_token}" \
73+
--output "reports/${PROFILE}.json" \
74+
"${service_url}/reconcile"
75+
jq -e --arg profile "$PROFILE" '
76+
.schema_version == "ibkr_reconciliation_candidate.v1"
77+
and .evidence.platform_id == "ibkr"
78+
and .evidence.strategy_profile == $profile
79+
and (.recovery_blockers | type == "array")
80+
' "reports/${PROFILE}.json" >/dev/null
81+
jq -r '[.permits_active_lkg, .expected_digests_configured, (.recovery_blockers | length)] | @tsv' \
82+
"reports/${PROFILE}.json" | awk -F '\t' '{print "candidate_collected permits_active_lkg=" $1 ", expected_digests_configured=" $2 ", blockers=" $3}'
83+
84+
- name: Retain redacted candidate
85+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
86+
with:
87+
name: ibkr-reconciliation-${{ matrix.profile }}-${{ github.run_id }}
88+
path: reports/${{ matrix.profile }}.json
89+
if-no-files-found: error
90+
retention-days: 30

docs/ibkr_reconciliation_baseline_enrollment.zh-CN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,14 @@ URI、部署 Cloud Run、连接券商或提交订单。实际启用仍需要单
8787
令牌被试图发送到普通管理站路径。每一种情况都必须抛出拒绝或返回没有
8888
`transition_plan` 的结果;测试同时断言 `state_write_attempted=false`。这让后续接入
8989
最小权限 CAS 时能持续证明“异常只能保持冻结,不能意外恢复实盘”。
90+
91+
## 收集两份候选收据
92+
93+
`Collect IBKR Reconciliation Evidence` 是显式手动工作流。它仅以部署身份调用每个
94+
冻结 Cloud Run 服务的 `POST /reconcile`,并在 30 天内保留脱敏
95+
`ibkr_reconciliation_candidate.v1` artifact。它不调用 `/run`、不修改 GitHub 变量、
96+
不发布状态账本,也不发送任何订单。
97+
98+
同一目标至少应在相隔一分钟的两次手动运行中得到候选,才能交给
99+
`build_reconciliation_baseline_candidate.py`。工作流的成功只说明读取和收据格式正常;
100+
候选仍可能因为未配置预期摘要或账本差异而正确保持阻断。

0 commit comments

Comments
 (0)