Skip to content

Commit bfa503e

Browse files
committed
Keep LongBridge README platform-scoped
1 parent c987c23 commit bfa503e

1 file changed

Lines changed: 11 additions & 166 deletions

File tree

README.md

Lines changed: 11 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Quant system on LongPort OpenAPI and Google Cloud Run.
1212
This repository uses `QuantPlatformKit` for LongPort token handling, context bootstrap, account snapshot access, market data, and order submission. Cloud Run deploys this repository directly.
1313
The LongBridge runtime can execute all five live `us_equity` profiles from `UsEquityStrategies`; `LongBridgePlatform` keeps the LongPort runtime, token refresh, execution, and notification flow.
1414

15-
Full strategy documentation now lives in [`UsEquityStrategies`](https://github.com/QuantStrategyLab/UsEquityStrategies). The sections below focus on execution-side defaults and runtime behavior.
16-
This runtime matrix is the authoritative enablement source for LongBridge. `UsEquityStrategies` only carries strategy-layer compatibility and metadata.
15+
Full strategy documentation now lives in [`UsEquityStrategies`](https://github.com/QuantStrategyLab/UsEquityStrategies). The sections below focus on LongBridge runtime behavior, profile enablement, deployment, and credentials.
16+
This runtime matrix is the authoritative enablement source for LongBridge. `UsEquityStrategies` carries strategy-layer logic, cadence, compatibility, and metadata.
1717

1818
### Execution boundary
1919

@@ -43,84 +43,13 @@ Check the current matrix locally:
4343
python3 scripts/print_strategy_profile_status.py
4444
```
4545

46-
### Runtime cadence
46+
### Strategy documentation boundary
4747

48-
Strategy cadence is owned by the strategy profile, but the actual broker run is
49-
triggered by Cloud Scheduler. Keep the Cloud Scheduler job aligned with the
50-
selected `STRATEGY_PROFILE` for each Cloud Run service:
51-
52-
| Profile | Intended cadence | Recommended Cloud Scheduler | Notes |
53-
| --- | --- | --- | --- |
54-
| `global_etf_rotation` | quarterly rebalance + daily canary | weekdays near US close, e.g. `45 15 * * 1-5` in `America/New_York` | Non-rebalance days should only act on the canary emergency path. |
55-
| `soxl_soxx_trend_income` | daily | weekdays near US close, e.g. `45 15 * * 1-5` in `America/New_York` | Trend/income value-mode profile. |
56-
| `tqqq_growth_income` | daily | weekdays near US close, e.g. `45 15 * * 1-5` in `America/New_York` | Current SG line. |
57-
| `russell_1000_multi_factor_defensive` | monthly | first few calendar days after month end, e.g. `45 15 1-7 * *` in `America/New_York` | Consumes monthly feature snapshots from `UsEquitySnapshotPipelines`. |
58-
| `tech_communication_pullback_enhancement` | monthly | first few calendar days after month end, e.g. `45 15 1-7 * *` in `America/New_York` | Current HK line. LongBridge constrains this profile to the first trading day after the monthly snapshot to avoid month-internal rebalancing. |
59-
60-
The upstream snapshot/data workflows live in `UsEquitySnapshotPipelines` and run
61-
monthly. Cloud Scheduler only invokes the broker runtime; it does not generate
62-
new feature snapshots.
63-
64-
**Layers**
65-
66-
- **Trading:** SOXL / SOXX / BOXX
67-
- **Income:** QQQI / SPYI
68-
69-
### Strategy
70-
71-
**Trading layer**
72-
73-
- SOXL 150-day MA for trend.
74-
- SOXL > MA150 → hold SOXL; SOXL ≤ MA150 → hold SOXX.
75-
- Rest of trading capital in BOXX.
76-
77-
**Income layer**
78-
79-
- Starts when total equity ≥ 150,000 USD.
80-
- Target income allocation cap 15%.
81-
- New income allocation: QQQI 70% / SPYI 30%.
82-
- Income positions are buy-only (no automatic reduction).
83-
84-
**Execution**
85-
86-
- Only SOXL, SOXX, BOXX, QQQI, SPYI are used.
87-
- Cash from account USD `available_cash`; no margin.
88-
- `estimate_max_purchase_quantity` used before buys.
89-
- Telegram alerts for submit, fill, reject, and errors.
48+
Strategy logic, cadence, asset universes, parameters, and research/backtest notes live in `UsEquityStrategies`. This platform README keeps only LongBridge profile enablement, env vars, deployment wiring, broker execution behavior, and notification transport.
9049

9150
### Notifications
9251

93-
Telegram notifications include structured execution and heartbeat messages, with English and Chinese variants.
94-
95-
**Trade execution:**
96-
```
97-
🔔 【Trade Execution Report】
98-
📊 Market: 🚀 RISK-ON (SOXL)
99-
💼 Risk Position: 57.8%
100-
💰 Income Target: 0.0%
101-
🏦 Income Locked: 38.8%
102-
🎯 Signal: SOXL above 150d MA, hold SOXL, risk 57.8%
103-
━━━━━━━━━━━━━━━━━━
104-
📈 [Market buy] BOXX: 190 shares @ $115.99 [order_id=xxx]
105-
```
106-
107-
**Heartbeat (no trades):**
108-
```
109-
💓 【Heartbeat】
110-
📊 Market: 🚀 RISK-ON (SOXL)
111-
💰 Equity: $150,000.00
112-
━━━━━━━━━━━━━━━━━━
113-
SOXL: $85,000.00 SOXX: $0.00
114-
QQQI: $15,000.00 SPYI: $6,000.00
115-
BOXX: $34,000.00 Cash: $10,000.00
116-
━━━━━━━━━━━━━━━━━━
117-
💼 Risk Position: 57.0%
118-
💰 Income Target: 5.0%
119-
🏦 Income Locked: 14.0%
120-
🎯 Signal: SOXL above 150d MA, hold SOXL, risk 57.0%
121-
━━━━━━━━━━━━━━━━━━
122-
✅ No trades needed
123-
```
52+
Telegram notifications include structured execution and heartbeat messages, with English and Chinese variants. Strategy-specific signal/status fields come from the selected `UsEquityStrategies` profile; LongBridge-specific fields cover order submission, fill/reject/error reporting, account prefix, and region.
12453

12554
### Environment variables
12655

@@ -211,17 +140,10 @@ Important:
211140
2. Create secret `longport_token_hk` for HK / `longport_token_sg` for SG (or your custom `LONGPORT_SECRET_NAME`) in Secret Manager and add your LongPort access token as the first version.
212141
3. Set the required env vars above on the Cloud Run service.
213142
4. Deploy the app to Cloud Run (e.g. `gcloud run deploy` from repo root with Dockerfile or buildpack).
214-
5. Create a Cloud Scheduler job that POSTs to the Cloud Run URL on a schedule. Use the [runtime cadence](#runtime-cadence) table: daily profiles usually use `45 15 * * 1-5`, while monthly snapshot profiles use a first-week monthly candidate window such as `45 15 1-7 * *`.
143+
5. Create a Cloud Scheduler job that POSTs to the Cloud Run URL. Choose the cron from the strategy-layer cadence in `UsEquityStrategies`; this platform repo only owns the runtime trigger wiring.
215144

216145
IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Accessor for the configured `LONGPORT_SECRET_NAME`, `LONGPORT_APP_KEY_SECRET_NAME`, and `LONGPORT_APP_SECRET_SECRET_NAME`, such as `longport_token_hk`, `longport-app-key-hk`, `longport-app-secret-hk`) and **Logs Writer**. Build/deploy typically uses a separate account with Artifact Registry Writer, Cloud Run Admin, Service Account User.
217146

218-
### Parameters (main.py)
219-
220-
- `TREND_MA_WINDOW`
221-
- `SMALL_ACCOUNT_DEPLOY_RATIO` / `MID_ACCOUNT_DEPLOY_RATIO` / `LARGE_ACCOUNT_DEPLOY_RATIO`
222-
- `TRADE_LAYER_DECAY_COEFF`
223-
- `INCOME_LAYER_START_USD` / `INCOME_LAYER_MAX_RATIO`
224-
- `INCOME_LAYER_QQQI_WEIGHT` / `INCOME_LAYER_SPYI_WEIGHT`
225147

226148
---
227149

@@ -233,7 +155,7 @@ IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Acc
233155
这个仓库通过 `QuantPlatformKit` 复用 LongPort token 处理、上下文初始化、账户快照、行情读取和下单逻辑。Cloud Run 直接部署这个仓库。
234156
`LongBridgePlatform` 现在可直接执行 `UsEquityStrategies` 里的全部 5 条 live `us_equity` 策略:`global_etf_rotation``russell_1000_multi_factor_defensive``soxl_soxx_trend_income``tqqq_growth_income``tech_communication_pullback_enhancement`;仓库本身继续保留 LongPort 运行时、token 刷新、执行和通知流程。
235157

236-
完整策略说明现在放在 [`UsEquityStrategies`](https://github.com/QuantStrategyLab/UsEquityStrategies)下面这些章节主要保留执行侧默认值和运行时行为
158+
完整策略说明现在放在 [`UsEquityStrategies`](https://github.com/QuantStrategyLab/UsEquityStrategies)下面这些章节只保留 LongBridge 运行时、profile 启用状态、部署和凭据说明
237159

238160
### 执行边界
239161

@@ -262,82 +184,13 @@ IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Acc
262184
python3 scripts/print_strategy_profile_status.py
263185
```
264186

265-
### 策略执行频率
266-
267-
策略频率由策略档位决定,但实际券商执行是 Cloud Scheduler 触发的。
268-
每个 Cloud Run 服务的 Cloud Scheduler 需要和当前 `STRATEGY_PROFILE` 对齐:
187+
### 策略文档边界
269188

270-
| Profile | 目标频率 | 建议 Cloud Scheduler | 说明 |
271-
| --- | --- | --- | --- |
272-
| `global_etf_rotation` | 季度调仓 + 每日 canary 防守检查 | 美股临近收盘的工作日,例如 `45 15 * * 1-5`,时区 `America/New_York` | 非调仓日原则上只在 canary 紧急防守路径动作。 |
273-
| `soxl_soxx_trend_income` | 日频 | 美股临近收盘的工作日,例如 `45 15 * * 1-5`,时区 `America/New_York` | 趋势/收益 value-mode 策略。 |
274-
| `tqqq_growth_income` | 日频 | 美股临近收盘的工作日,例如 `45 15 * * 1-5`,时区 `America/New_York` | 当前 SG 线路。 |
275-
| `russell_1000_multi_factor_defensive` | 月频 | 月末之后前几个自然日,例如 `45 15 1-7 * *`,时区 `America/New_York` | 消费 `UsEquitySnapshotPipelines` 生成的月度 feature snapshot。 |
276-
| `tech_communication_pullback_enhancement` | 月频 | 月末之后前几个自然日,例如 `45 15 1-7 * *`,时区 `America/New_York` | 当前 HK 线路。LongBridge 会把该策略限制在月度 snapshot 之后第一个交易日执行,避免月内重复调仓。 |
277-
278-
上游数据刷新和 feature snapshot 发布在 `UsEquitySnapshotPipelines` 里,按月运行。
279-
Cloud Scheduler 只负责触发券商运行时,不负责生成新的 feature snapshot。
280-
281-
**层级**
282-
283-
- **交易层:** SOXL / SOXX / BOXX
284-
- **收入层:** QQQI / SPYI
285-
286-
### 策略
287-
288-
**交易层**
289-
290-
- 使用 SOXL 150 日均线判断趋势。
291-
- SOXL > MA150 → 持有 SOXL;SOXL ≤ MA150 → 切换至 SOXX。
292-
- 交易层剩余资金放入 BOXX。
293-
294-
**收入层**
295-
296-
- 当总资产 ≥ 150,000 USD 时启动。
297-
- 收入层目标配比上限 15%。
298-
- 新增收入配置:QQQI 70% / SPYI 30%。
299-
- 收入层仅买入,不自动减仓。
300-
301-
**执行**
302-
303-
- 仅使用 SOXL、SOXX、BOXX、QQQI、SPYI。
304-
- 使用账户 USD 可用现金,不使用保证金。
305-
- 买入前调用 `estimate_max_purchase_quantity` 校验。
306-
- 通过 Telegram 推送下单、成交、拒绝及异常通知。
189+
策略逻辑、策略频率、标的池、参数和研究/回测说明都放在 `UsEquityStrategies`。这个平台 README 只保留 LongBridge profile 启用状态、环境变量、部署 wiring、券商执行行为和通知通道说明。
307190

308191
### 通知格式
309192

310-
Telegram 通知包含结构化的调仓和心跳消息,支持中英文切换。
311-
312-
**调仓通知:**
313-
```
314-
🔔 【调仓指令】
315-
📊 市场状态: 🚀 RISK-ON (SOXL)
316-
💼 交易层风险仓位: 57.8%
317-
💰 收入层目标: 0.0%
318-
🏦 收入层锁定占比: 38.8%
319-
🎯 触发信号: SOXL 站上 150 日均线,持有 SOXL,交易层风险仓位 57.8%
320-
━━━━━━━━━━━━━━━━━━
321-
📈 [市价买入] BOXX: 190股 @ $115.99 [order_id=xxx]
322-
```
323-
324-
**心跳通知 (无需调仓):**
325-
```
326-
💓 【心跳检测】
327-
📊 市场状态: 🚀 RISK-ON (SOXL)
328-
💰 净值: $150,000.00
329-
━━━━━━━━━━━━━━━━━━
330-
SOXL: $85,000.00 SOXX: $0.00
331-
QQQI: $15,000.00 SPYI: $6,000.00
332-
BOXX: $34,000.00 现金: $10,000.00
333-
━━━━━━━━━━━━━━━━━━
334-
💼 交易层风险仓位: 57.0%
335-
💰 收入层目标: 5.0%
336-
🏦 收入层锁定占比: 14.0%
337-
🎯 信号: SOXL 站上 150 日均线,持有 SOXL,交易层风险仓位 57.0%
338-
━━━━━━━━━━━━━━━━━━
339-
✅ 无需调仓
340-
```
193+
Telegram 通知包含结构化的调仓和心跳消息,支持中英文切换。策略相关的信号/状态字段来自当前选择的 `UsEquityStrategies` profile;LongBridge 侧只负责下单、成交/拒单/异常、账户前缀和区域字段。
341194

342195
### 环境变量
343196

@@ -428,14 +281,6 @@ Secret Manager 中需存在 `LONGPORT_SECRET_NAME` 指定的密钥(默认: `lo
428281
2. 在 Secret Manager 中为 HK 创建 `longport_token_hk`、为 SG 创建 `longport_token_sg`(或使用你自定义的 `LONGPORT_SECRET_NAME`),并将 LongPort access token 作为第一个版本写入。
429282
3. 在 Cloud Run 服务上配置上述环境变量。
430283
4. 部署至 Cloud Run(如从仓库根目录执行 `gcloud run deploy`)。
431-
5. 创建 Cloud Scheduler 定时任务,POST 到 Cloud Run URL。按上面的[策略执行频率](#策略执行频率)配置:日频策略通常用 `45 15 * * 1-5`,月频 snapshot 策略用类似 `45 15 1-7 * *` 的月初候选窗口
284+
5. 创建 Cloud Scheduler 定时任务,POST 到 Cloud Run URL。cron 频率以 `UsEquityStrategies` 里的策略层 cadence 为准;这个平台仓只维护运行时触发 wiring
432285

433286
IAM: Cloud Run 服务账号需要 **Secret Manager Admin**(或当前 `LONGPORT_SECRET_NAME``LONGPORT_APP_KEY_SECRET_NAME``LONGPORT_APP_SECRET_SECRET_NAME` 对应 secret 的 Secret Accessor,例如 `longport_token_hk``longport-app-key-hk``longport-app-secret-hk`)和 **Logs Writer** 权限。
434-
435-
### 策略参数 (main.py)
436-
437-
- `TREND_MA_WINDOW`
438-
- `SMALL_ACCOUNT_DEPLOY_RATIO` / `MID_ACCOUNT_DEPLOY_RATIO` / `LARGE_ACCOUNT_DEPLOY_RATIO`
439-
- `TRADE_LAYER_DECAY_COEFF`
440-
- `INCOME_LAYER_START_USD` / `INCOME_LAYER_MAX_RATIO`
441-
- `INCOME_LAYER_QQQI_WEIGHT` / `INCOME_LAYER_SPYI_WEIGHT`

0 commit comments

Comments
 (0)