opencode-skills-collection 4.0.69 → 4.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/bundled-skills/.antigravity-install-manifest.json +39 -1
  2. package/bundled-skills/api-integration-architect/SKILL.md +241 -0
  3. package/bundled-skills/apify-generate-output-schema/SKILL.md +438 -0
  4. package/bundled-skills/apify-integration-development/SKILL.md +168 -0
  5. package/bundled-skills/apify-integration-development/references/ai-framework-package.md +158 -0
  6. package/bundled-skills/apify-integration-development/references/ai-harness-plugin.md +192 -0
  7. package/bundled-skills/apify-integration-development/references/sdk-integration.md +236 -0
  8. package/bundled-skills/apify-integration-development/references/workflow-automation.md +163 -0
  9. package/bundled-skills/architecture-review/README.md +42 -0
  10. package/bundled-skills/architecture-review/SKILL.md +77 -0
  11. package/bundled-skills/architecture-review/examples.md +11 -0
  12. package/bundled-skills/architecture-review/reference/best-practices.md +7 -0
  13. package/bundled-skills/architecture-review/reference/capabilities.md +20 -0
  14. package/bundled-skills/architecture-review/reference/fallbacks.md +11 -0
  15. package/bundled-skills/architecture-review/reference/graph.md +15 -0
  16. package/bundled-skills/architecture-review/reference/mcp.md +14 -0
  17. package/bundled-skills/architecture-review/reference/workflow.md +15 -0
  18. package/bundled-skills/architecture-review/templates/architecture-review.md +21 -0
  19. package/bundled-skills/code-review-sensei/SKILL.md +177 -0
  20. package/bundled-skills/codebase-onboarding/README.md +42 -0
  21. package/bundled-skills/codebase-onboarding/SKILL.md +77 -0
  22. package/bundled-skills/codebase-onboarding/examples.md +11 -0
  23. package/bundled-skills/codebase-onboarding/reference/best-practices.md +7 -0
  24. package/bundled-skills/codebase-onboarding/reference/capabilities.md +20 -0
  25. package/bundled-skills/codebase-onboarding/reference/fallbacks.md +11 -0
  26. package/bundled-skills/codebase-onboarding/reference/graph.md +15 -0
  27. package/bundled-skills/codebase-onboarding/reference/mcp.md +14 -0
  28. package/bundled-skills/codebase-onboarding/reference/workflow.md +15 -0
  29. package/bundled-skills/codebase-onboarding/templates/repository-onboarding.md +21 -0
  30. package/bundled-skills/connection-auth-rules/SKILL.md +199 -0
  31. package/bundled-skills/connection-auth-rules/fetch_schema.py +320 -0
  32. package/bundled-skills/dependency-analysis/README.md +42 -0
  33. package/bundled-skills/dependency-analysis/SKILL.md +76 -0
  34. package/bundled-skills/dependency-analysis/examples.md +11 -0
  35. package/bundled-skills/dependency-analysis/reference/best-practices.md +7 -0
  36. package/bundled-skills/dependency-analysis/reference/capabilities.md +20 -0
  37. package/bundled-skills/dependency-analysis/reference/fallbacks.md +11 -0
  38. package/bundled-skills/dependency-analysis/reference/graph.md +15 -0
  39. package/bundled-skills/dependency-analysis/reference/mcp.md +14 -0
  40. package/bundled-skills/dependency-analysis/reference/workflow.md +15 -0
  41. package/bundled-skills/dependency-analysis/templates/dependency-review.md +21 -0
  42. package/bundled-skills/devops-pipeline-builder/SKILL.md +200 -0
  43. package/bundled-skills/eas-app-stores/SKILL.md +197 -0
  44. package/bundled-skills/eas-app-stores/agents/openai.yaml +4 -0
  45. package/bundled-skills/eas-app-stores/references/app-store-metadata.md +497 -0
  46. package/bundled-skills/eas-app-stores/references/ios-app-store.md +376 -0
  47. package/bundled-skills/eas-app-stores/references/native-ios.md +167 -0
  48. package/bundled-skills/eas-app-stores/references/play-store.md +244 -0
  49. package/bundled-skills/eas-app-stores/references/testflight.md +62 -0
  50. package/bundled-skills/eas-app-stores/references/workflows.md +120 -0
  51. package/bundled-skills/eas-hosting/SKILL.md +448 -0
  52. package/bundled-skills/eas-hosting/agents/openai.yaml +4 -0
  53. package/bundled-skills/eas-observe/SKILL.md +75 -0
  54. package/bundled-skills/eas-observe/agents/openai.yaml +4 -0
  55. package/bundled-skills/eas-observe/references/metrics.md +98 -0
  56. package/bundled-skills/eas-observe/references/queries.md +403 -0
  57. package/bundled-skills/eas-observe/references/setup.md +476 -0
  58. package/bundled-skills/eas-observe/references/third-party.md +136 -0
  59. package/bundled-skills/eas-simulator/SKILL.md +251 -0
  60. package/bundled-skills/eas-simulator/agents/openai.yaml +4 -0
  61. package/bundled-skills/eas-simulator/references/controllers.md +135 -0
  62. package/bundled-skills/eas-simulator/references/run-your-app.md +240 -0
  63. package/bundled-skills/eas-simulator/references/troubleshooting.md +47 -0
  64. package/bundled-skills/eas-workflows/SKILL.md +119 -0
  65. package/bundled-skills/eas-workflows/agents/openai.yaml +4 -0
  66. package/bundled-skills/eas-workflows/scripts/fetch.js +109 -0
  67. package/bundled-skills/expo-animation/LICENSE +21 -0
  68. package/bundled-skills/expo-animation/RECIPES.md +385 -0
  69. package/bundled-skills/expo-animation/SKILL.md +295 -0
  70. package/bundled-skills/expo-animation/agents/openai.yaml +4 -0
  71. package/bundled-skills/fact-check-x-unified/SKILL.md +178 -0
  72. package/bundled-skills/fact-check-x-unified/agents/openai.yaml +4 -0
  73. package/bundled-skills/fact-check-x-unified/references/acceptance-criteria.md +44 -0
  74. package/bundled-skills/fact-check-x-unified/references/contracts.md +39 -0
  75. package/bundled-skills/fact-check-x-unified/scripts/common.py +31 -0
  76. package/bundled-skills/fact-check-x-unified/scripts/fact_check_x.py +1832 -0
  77. package/bundled-skills/fact-check-x-unified/scripts/trusted_search_config.py +324 -0
  78. package/bundled-skills/fact-check-x-unified/tests/anchor_downgrade_test.py +90 -0
  79. package/bundled-skills/fact-check-x-unified/tests/multi_platform_test.py +369 -0
  80. package/bundled-skills/fact-check-x-unified/tests/smoke_test.py +740 -0
  81. package/bundled-skills/fact-check-x-unified/tests/stage_checkpoint_test.py +103 -0
  82. package/bundled-skills/fact-check-x-unified/tests/trusted_search_config_test.py +156 -0
  83. package/bundled-skills/gpt-taste/SKILL.md +8 -1
  84. package/bundled-skills/hf-cli/SKILL.md +263 -0
  85. package/bundled-skills/huggingface-community-evals/SKILL.md +228 -0
  86. package/bundled-skills/huggingface-community-evals/examples/.env.example +3 -0
  87. package/bundled-skills/huggingface-community-evals/examples/USAGE_EXAMPLES.md +101 -0
  88. package/bundled-skills/huggingface-community-evals/scripts/inspect_eval_uv.py +104 -0
  89. package/bundled-skills/huggingface-community-evals/scripts/inspect_vllm_uv.py +306 -0
  90. package/bundled-skills/huggingface-community-evals/scripts/lighteval_vllm_uv.py +297 -0
  91. package/bundled-skills/huggingface-datasets/SKILL.md +130 -0
  92. package/bundled-skills/jev-social/SKILL.md +182 -0
  93. package/bundled-skills/longbridge-derivatives/SKILL.md +117 -0
  94. package/bundled-skills/longbridge-derivatives/references/option.md +36 -0
  95. package/bundled-skills/longbridge-derivatives/references/options-advanced.md +101 -0
  96. package/bundled-skills/longbridge-derivatives/references/options-pnl.md +74 -0
  97. package/bundled-skills/longbridge-derivatives/references/options-strategy.md +82 -0
  98. package/bundled-skills/longbridge-derivatives/references/options-volatility.md +70 -0
  99. package/bundled-skills/longbridge-derivatives/references/warrant.md +12 -0
  100. package/bundled-skills/longbridge-quant/SKILL.md +151 -0
  101. package/bundled-skills/longbridge-quant/references/correlation.md +51 -0
  102. package/bundled-skills/longbridge-quant/references/execution-model.md +68 -0
  103. package/bundled-skills/longbridge-quant/references/factor-research.md +95 -0
  104. package/bundled-skills/longbridge-quant/references/factor-screen.md +101 -0
  105. package/bundled-skills/longbridge-quant/references/hedging.md +136 -0
  106. package/bundled-skills/longbridge-quant/references/ml-strategy.md +77 -0
  107. package/bundled-skills/longbridge-quant/references/multifactor.md +68 -0
  108. package/bundled-skills/longbridge-quant/references/pairs-trading.md +61 -0
  109. package/bundled-skills/longbridge-quant/references/quant-cli.md +133 -0
  110. package/bundled-skills/longbridge-quant/references/quant-stats.md +150 -0
  111. package/bundled-skills/longbridge-quant/references/seasonality.md +50 -0
  112. package/bundled-skills/longbridge-quant/references/strategy-optimizer.md +68 -0
  113. package/bundled-skills/longbridge-quant/references/volatility-strategy.md +52 -0
  114. package/bundled-skills/longbridge-research/SKILL.md +187 -0
  115. package/bundled-skills/longbridge-research/references/company-profile.md +96 -0
  116. package/bundled-skills/longbridge-research/references/company-tearsheet.md +82 -0
  117. package/bundled-skills/longbridge-research/references/competitive-analysis.md +81 -0
  118. package/bundled-skills/longbridge-research/references/consensus.md +92 -0
  119. package/bundled-skills/longbridge-research/references/coverage-initiation.md +76 -0
  120. package/bundled-skills/longbridge-research/references/defi-yield.md +60 -0
  121. package/bundled-skills/longbridge-research/references/finance-calendar.md +165 -0
  122. package/bundled-skills/longbridge-research/references/financial-planning.md +77 -0
  123. package/bundled-skills/longbridge-research/references/forecast-eps.md +39 -0
  124. package/bundled-skills/longbridge-research/references/fund-holder.md +44 -0
  125. package/bundled-skills/longbridge-research/references/hkipo-analysis.md +101 -0
  126. package/bundled-skills/longbridge-research/references/industry-peers.md +46 -0
  127. package/bundled-skills/longbridge-research/references/industry-rank.md +62 -0
  128. package/bundled-skills/longbridge-research/references/insider-trades.md +48 -0
  129. package/bundled-skills/longbridge-research/references/institution-rating.md +62 -0
  130. package/bundled-skills/longbridge-research/references/investment-ideas.md +69 -0
  131. package/bundled-skills/longbridge-research/references/investment-proposal.md +95 -0
  132. package/bundled-skills/longbridge-research/references/investors.md +87 -0
  133. package/bundled-skills/longbridge-research/references/onchain.md +70 -0
  134. package/bundled-skills/longbridge-research/references/post-investment.md +76 -0
  135. package/bundled-skills/longbridge-research/references/shareholder.md +72 -0
  136. package/bundled-skills/longbridge-research/references/short-positions.md +50 -0
  137. package/bundled-skills/longbridge-research/references/short-trades.md +50 -0
  138. package/bundled-skills/longbridge-research/references/stock-research.md +61 -0
  139. package/bundled-skills/longbridge-research/references/thesis-tracker.md +64 -0
  140. package/bundled-skills/makepad-2-0-animation/SKILL.md +318 -0
  141. package/bundled-skills/makepad-2-0-animation/references/animator-reference.md +433 -0
  142. package/bundled-skills/makepad-2-0-dsl/SKILL.md +492 -0
  143. package/bundled-skills/makepad-2-0-dsl/references/dsl-syntax-reference.md +511 -0
  144. package/bundled-skills/makepad-2-0-dsl/references/extended-guide.md +56 -0
  145. package/bundled-skills/makepad-2-0-dsl/references/property-system.md +757 -0
  146. package/bundled-skills/makepad-2-0-events/SKILL.md +497 -0
  147. package/bundled-skills/makepad-2-0-events/references/event-patterns.md +802 -0
  148. package/bundled-skills/makepad-2-0-events/references/extended-guide.md +590 -0
  149. package/bundled-skills/makepad-2-0-layout/SKILL.md +499 -0
  150. package/bundled-skills/makepad-2-0-layout/references/extended-guide.md +243 -0
  151. package/bundled-skills/makepad-2-0-layout/references/layout-patterns.md +881 -0
  152. package/bundled-skills/makepad-2-0-widgets/SKILL.md +261 -0
  153. package/bundled-skills/makepad-2-0-widgets/references/widget-advanced.md +648 -0
  154. package/bundled-skills/makepad-2-0-widgets/references/widget-catalog.md +547 -0
  155. package/bundled-skills/meeting-distiller-pro/SKILL.md +120 -0
  156. package/bundled-skills/monte-carlo-analyze-root-cause/SKILL.md +12 -1
  157. package/bundled-skills/monte-carlo-asset-health/SKILL.md +12 -1
  158. package/bundled-skills/monte-carlo-context-detection/SKILL.md +170 -0
  159. package/bundled-skills/monte-carlo-context-detection/references/signal-definitions.md +46 -0
  160. package/bundled-skills/remotion-captions/SKILL.md +57 -0
  161. package/bundled-skills/remotion-captions/agents/openai.yaml +7 -0
  162. package/bundled-skills/remotion-captions/assets/remotion-icon.svg +4 -0
  163. package/bundled-skills/remotion-captions/display-captions.md +190 -0
  164. package/bundled-skills/remotion-captions/import-srt-captions.md +73 -0
  165. package/bundled-skills/remotion-captions/transcribe-captions.md +70 -0
  166. package/bundled-skills/remotion-create/SKILL.md +106 -0
  167. package/bundled-skills/remotion-create/agents/openai.yaml +7 -0
  168. package/bundled-skills/remotion-create/assets/remotion-icon.svg +4 -0
  169. package/bundled-skills/remotion-create/tailwind.md +11 -0
  170. package/bundled-skills/remotion-create/video-layout.md +9 -0
  171. package/bundled-skills/remotion-docs/SKILL.md +67 -0
  172. package/bundled-skills/remotion-docs/agents/openai.yaml +7 -0
  173. package/bundled-skills/remotion-docs/assets/remotion-icon.svg +4 -0
  174. package/bundled-skills/remotion-interactivity/SKILL.md +270 -0
  175. package/bundled-skills/remotion-interactivity/agents/openai.yaml +7 -0
  176. package/bundled-skills/remotion-interactivity/assets/remotion-icon.svg +4 -0
  177. package/bundled-skills/remotion-render/SKILL.md +48 -0
  178. package/bundled-skills/remotion-render/agents/openai.yaml +7 -0
  179. package/bundled-skills/remotion-render/assets/remotion-icon.svg +4 -0
  180. package/bundled-skills/remotion-render/transparent-videos.md +106 -0
  181. package/bundled-skills/saas-pricing-strategist/SKILL.md +169 -0
  182. package/bundled-skills/score-eval/SKILL.md +35 -0
  183. package/bundled-skills/writing-guidelines/SKILL.md +60 -0
  184. package/package.json +1 -1
  185. package/skills_index.json +980 -3
@@ -0,0 +1,136 @@
1
+ # longbridge-hedging
2
+
3
+ Design and evaluate hedging strategies for a portfolio or single position using Longbridge market data — from simple Beta hedges to options-based protection and cross-asset tail-risk hedges.
4
+
5
+ ## Workflow
6
+
7
+ ### Step 1 — Identify hedge objective
8
+
9
+ Clarify with the user:
10
+
11
+ - What is being hedged: single position, portfolio, or sector exposure?
12
+ - Risk to hedge: market Beta, tail event, currency, or volatility?
13
+ - Hedge horizon: days, weeks, or months?
14
+ - Cost tolerance: zero-cost (collar) or willing to pay premium?
15
+
16
+ ### Step 2 — Fetch data
17
+
18
+ ```bash
19
+ longbridge kline --help
20
+ longbridge option --help
21
+
22
+ # Beta calculation (60-day daily returns)
23
+ longbridge kline <SYMBOL> --period day --count 60 --format json
24
+
25
+ # Option chain for hedge instruments
26
+ longbridge option chain <SYMBOL> --format json
27
+
28
+ # Current portfolio positions (requires login with trade scope)
29
+ longbridge positions --format json
30
+ ```
31
+
32
+ ### Step 3 — Beta hedge
33
+
34
+ **Portfolio Beta**:
35
+
36
+ ```
37
+ β_portfolio = Σ(w_i × β_i)
38
+ ```
39
+
40
+ Compute individual Beta for each holding from 60-day returns vs benchmark (SPX / HSI / CSI300). Fetch benchmark kline with `longbridge kline <BENCHMARK> --period day --count 60 --format json`.
41
+
42
+ **Hedge ratio (index futures or inverse ETF)**:
43
+
44
+ ```
45
+ Contracts needed = (Portfolio Value × β_portfolio) / (Futures Price × Contract Multiplier)
46
+ ```
47
+
48
+ Present: number of contracts, hedge cost, and residual Beta after hedge.
49
+
50
+ ### Step 4 — Options-based protection
51
+
52
+ **Protective Put** (保护性看跌期权介绍):
53
+
54
+ - 原理:持有正股的同时持有看跌期权;当标的价格下跌时,期权价值上升,可对冲下行风险。常见做法是选择平值(ATM)或略虚值(OTM)的看跌期权。
55
+ - Cost = put premium; protection kicks in below strike.
56
+ - Effective floor = Strike − Premium paid.
57
+ - 具体期权合约是否适用,请根据自身持仓情况和风险偏好独立判断。
58
+ - Fetch available strikes: `longbridge option chain <SYMBOL> --format json`.
59
+
60
+ **Collar Strategy** (zero-cost or near-zero):
61
+
62
+ - Buy OTM put (downside protection) + sell OTM call (cap upside).
63
+ - Net premium ≈ 0 if call premium offsets put premium.
64
+ - Present: put strike, call strike, net cost, max gain, max loss.
65
+
66
+ **Selection criteria**:
67
+ | Criterion | Protective Put | Collar |
68
+ |---|---|---|
69
+ | Upside retention | Full | Capped at call strike |
70
+ | Cost | Premium paid | Near zero |
71
+ | Best for | Bullish with hedge need | Neutral/mild bearish |
72
+
73
+ ### Step 5 — Tail risk hedges
74
+
75
+ | Tool | Instrument | Mechanism |
76
+ | ------------------------ | --------------------- | ---------------------------------- |
77
+ | VIX calls | UVXY.US / VIX options | Profit from volatility spike |
78
+ | Gold | GLD.US / 518880.SH | Safe-haven in risk-off |
79
+ | Long-dated US Treasuries | TLT.US | Negative correlation with equities |
80
+ | Put on index | SPY puts / HSI puts | Direct market hedge |
81
+
82
+ Note: fetch current price and recent kline for any hedge instrument before recommending.
83
+
84
+ ### Step 6 — Currency hedge
85
+
86
+ For HK/US cross-currency portfolios:
87
+
88
+ - USD/HKD is pegged — minimal FX risk.
89
+ - CNY exposure: use offshore RMB (CNH) forwards or futures.
90
+ - Non-HKD Asian exposure: fetch FX rate via `longbridge fx --format json` (verify flag with `--help`).
91
+
92
+ Present notional hedge amount, instrument, tenor, and estimated cost.
93
+
94
+ ### Step 7 — Hedge cost assessment
95
+
96
+ ```
97
+ Cost efficiency = Protection value / Premium paid
98
+ ```
99
+
100
+ Present: premium as % of protected notional, breakeven move, and expected cost per 1% of downside protection.
101
+
102
+ ## CLI
103
+
104
+ ```bash
105
+ longbridge kline --help
106
+ longbridge option --help
107
+ longbridge positions --help
108
+
109
+ longbridge kline <SYMBOL> --period day --count 60 --format json
110
+ longbridge option chain <SYMBOL> --format json
111
+ longbridge positions --format json
112
+ ```
113
+
114
+ ## Output
115
+
116
+ Present:
117
+
118
+ 1. Hedge objective summary.
119
+ 2. Recommended strategy with rationale.
120
+ 3. Implementation details (strikes, contracts, premium).
121
+ 4. Cost vs protection table.
122
+ 5. Scenarios: portfolio value if market falls 10% / 20% with and without hedge.
123
+ 6. Caveats (basis risk, early exercise for American options, liquidity).
124
+
125
+ Always note: hedging reduces risk but also limits upside.
126
+
127
+ > 以上内容仅供参考,不构成投资建议。投资决策请结合自身风险承受能力独立判断。/ The above is for reference only and does not constitute investment advice. Please make investment decisions independently based on your own risk tolerance.
128
+
129
+ ## Error handling
130
+
131
+ | Situation | 简体回复 | 繁體回覆 | English reply |
132
+ | ------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------ |
133
+ | `command not found: longbridge` | 请安装 longbridge-terminal 或检查 MCP 配置。 | 請安裝 longbridge-terminal 或檢查 MCP 配置。 | Install longbridge-terminal or check MCP config. |
134
+ | stderr: `not logged in` | 请运行 `longbridge auth login`(需 Trade 权限查看持仓)。 | 請執行 `longbridge auth login`(需 Trade 權限查看持倉)。 | Run `longbridge auth login` (Trade scope needed for positions). |
135
+ | No option chain data | 该标的无期权数据,请尝试对应指数期权或 ETF 期权。 | 該標的無期權數據,請嘗試指數或 ETF 期權。 | No option chain for this symbol; try index or ETF options instead. |
136
+ | Negative or missing Beta | Beta 数据不足,将使用市值加权 Beta=1 作为默认值。 | Beta 數據不足,使用 Beta=1 作為默認值。 | Insufficient Beta data; defaulting to Beta = 1. |
@@ -0,0 +1,77 @@
1
+ # longbridge-ml-strategy
2
+
3
+ Walk-forward machine-learning framework for stock direction prediction. Fetches historical OHLCV data, engineers technical features, trains a rolling classifier (Random Forest or Gradient Boosting), generates probabilistic buy/sell signals, and evaluates backtest performance.
4
+
5
+ ## Dependencies
6
+
7
+ Requires: `scikit-learn`, `pandas`, `numpy` (usually pre-installed).
8
+ Optional: `xgboost` or `lightgbm` for gradient-boosting models.
9
+ If unavailable, fall back to a simpler logistic-regression model.
10
+
11
+ ## Workflow
12
+
13
+ 1. Fetch 504 daily candles (≈ 2 years):
14
+ `longbridge kline <SYMBOL> --period day --count 504 --format json`
15
+
16
+ 2. **Feature engineering** (compute on rolling windows):
17
+ - MACD line and signal (EMA12 − EMA26, signal EMA9)
18
+ - RSI-14
19
+ - Bollinger Band width: (upper − lower) / mid, window 20
20
+ - Volume change rate: (vol*t − vol*{t-5}) / vol\_{t-5}
21
+ - 5-day price momentum: (close*t / close*{t-5}) − 1
22
+ - Label: 1 if close\_{t+5} > close_t × 1.01, 0 if < close_t × 0.99, else drop
23
+
24
+ 3. **Walk-forward training**:
25
+ - Training window: 252 days; retrain every 60 days
26
+ - Model: `RandomForestClassifier(n_estimators=100)` or `GradientBoostingClassifier`
27
+ - Predict probability for the current bar
28
+
29
+ 4. **Signal generation**:
30
+ - prob > 0.60 → 模型上涨概率偏高 / Model upside probability elevated
31
+ - prob < 0.40 → 模型下跌概率偏高 / Model downside probability elevated
32
+ - Otherwise → 模型无方向性预测 / No directional signal from model
33
+
34
+ 5. **Backtest metrics** (on out-of-sample predictions):
35
+ - Win rate (% correct directional calls)
36
+ - Profit factor (gross profit / gross loss)
37
+ - Annualised Sharpe ratio (assuming daily rebalance)
38
+ - Max drawdown
39
+
40
+ 6. **Feature importance**: rank top-5 features by mean decrease in impurity.
41
+
42
+ Run `longbridge kline --help` to confirm flag names before calling.
43
+
44
+ ## CLI
45
+
46
+ ```bash
47
+ longbridge kline --help
48
+
49
+ longbridge kline <SYMBOL> --period day --count 504 --format json
50
+ ```
51
+
52
+ ## Output
53
+
54
+ | Metric | 简体 | 繁體 | English |
55
+ | ------------------ | -------- | -------- | ------------------ |
56
+ | Current signal | 当前信号 | 當前訊號 | Current signal |
57
+ | Signal probability | 预测概率 | 預測概率 | Signal probability |
58
+ | Win rate | 胜率 | 勝率 | Win rate |
59
+ | Profit factor | 盈亏比 | 盈虧比 | Profit factor |
60
+ | Sharpe ratio | 夏普比率 | 夏普比率 | Sharpe ratio |
61
+ | Max drawdown | 最大回撤 | 最大回撤 | Max drawdown |
62
+ | Top features | 重要特征 | 重要特徵 | Top features |
63
+
64
+ Output: current signal box → backtest summary table → feature importance list → caveats (past performance, data snooping). Cite **Longbridge Securities** / **数据来源:长桥证券** / **數據來源:長橋證券**.
65
+
66
+ > 以上内容仅供参考,不构成投资建议。投资决策请结合自身风险承受能力独立判断。
67
+ > The above is for reference only and does not constitute investment advice. Investment decisions should be made based on your own risk tolerance.
68
+
69
+ ## Error handling
70
+
71
+ | Situation | 简体回复 | 繁體回復 | English reply |
72
+ | -------------------------------- | ---------------------------------------------------------------- | ----------------------------------------- | ----------------------------------------------- |
73
+ | `command not found: longbridge` | 回退到 MCP 或提示安装 longbridge-terminal | 回退到 MCP 或提示安裝 longbridge-terminal | Fall back to MCP or install longbridge-terminal |
74
+ | `not logged in` / `unauthorized` | 请运行 `longbridge auth login` | 請執行 `longbridge auth login` | Run `longbridge auth login` |
75
+ | `scikit-learn` not found | 提示 `pip install scikit-learn pandas numpy`,并改用逻辑回归降级 | 提示安裝,降級至邏輯回歸 | Prompt install; degrade to logistic regression |
76
+ | Fewer than 252 candles | 数据不足,无法完成 walk-forward 训练 | 數據不足 | Insufficient data for walk-forward |
77
+ | Other stderr | 直接显示原始错误 | 直接顯示原始錯誤 | Surface verbatim |
@@ -0,0 +1,68 @@
1
+ # longbridge-multifactor
2
+
3
+ Cross-sectional multi-factor quantitative stock selection. Scores a universe of stocks on value, momentum, quality, and low-volatility factors; composites the scores; ranks stocks; and outputs a TopN buy list and bottom-N short list with factor-level attribution.
4
+
5
+ ## Workflow
6
+
7
+ 1. **Get universe**: fetch index constituents:
8
+ `longbridge constituent <INDEX> --format json`
9
+ Extract the `stocks` key. If the user provides a custom list, skip this step.
10
+
11
+ 2. **Fetch valuation factors** for each symbol (batched, up to 20 stocks for manageable output):
12
+ `longbridge calc-index <SYMBOL> --format json`
13
+ Extract PE, PB, ROE. Value factors: `f_value = 0.5 × (1/PE) + 0.5 × (1/PB)` (normalised).
14
+
15
+ 3. **Fetch price history** for momentum and low-vol:
16
+ `longbridge kline <SYMBOL> --period day --count 60 --format json`
17
+ - Momentum: (close_today / close_60d_ago) − 1
18
+ - Low-volatility: annualised std of last 60 daily returns × √252 (negate: lower HV → higher score)
19
+
20
+ 4. **Standardise** each factor across the universe to Z-scores (subtract mean, divide by std).
21
+
22
+ 5. **Composite score**:
23
+ - Equal-weight: `score = 0.25 × Z_value + 0.25 × Z_momentum + 0.25 × Z_quality + 0.25 × Z_lowvol`
24
+ - IC-weighted (if the user specifies): weight each factor by its historical IC (information coefficient); if IC data unavailable, default to equal-weight.
25
+
26
+ 6. **Rank and output**:
27
+ - Top 20%: buy / long signal
28
+ - Bottom 20%: avoid / short signal
29
+ - Display top-10 and bottom-10 stocks with individual factor Z-scores and composite score.
30
+
31
+ Run `longbridge constituent --help`, `longbridge calc-index --help`, and `longbridge kline --help` to verify current flag names.
32
+
33
+ ## CLI
34
+
35
+ ```bash
36
+ longbridge constituent --help
37
+ longbridge calc-index --help
38
+ longbridge kline --help
39
+
40
+ longbridge constituent <INDEX> --format json
41
+ longbridge calc-index <SYMBOL> --format json
42
+ longbridge kline <SYMBOL> --period day --count 60 --format json
43
+ ```
44
+
45
+ Supported index examples: `HSI.HK`, `SPX.US`, `IXIC.US`, `DJI.US`, `000300.SH`.
46
+
47
+ ## Output
48
+
49
+ | Column | 简体 | 繁體 | English |
50
+ | --------------- | --------------- | --------------- | ---------------- |
51
+ | Composite score | 综合得分 | 綜合得分 | Composite score |
52
+ | Value Z | 价值因子 Z 值 | 價值因子 Z 值 | Value Z-score |
53
+ | Momentum Z | 动量因子 Z 值 | 動量因子 Z 值 | Momentum Z-score |
54
+ | Quality Z | 质量因子 Z 值 | 質量因子 Z 值 | Quality Z-score |
55
+ | Low-vol Z | 低波动因子 Z 值 | 低波動因子 Z 值 | Low-vol Z-score |
56
+ | Signal | 信号 | 訊號 | Signal |
57
+
58
+ Output: top-10 / bottom-10 ranked table → factor dispersion summary → composite methodology note. Add caveat that the universe is limited by API throughput. Cite **Longbridge Securities** / **数据来源:长桥证券** / **數據來源:長橋證券**.
59
+
60
+ ## Error handling
61
+
62
+ | Situation | 简体回复 | 繁體回復 | English reply |
63
+ | -------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------------- |
64
+ | `command not found: longbridge` | 回退到 MCP 或提示安装 longbridge-terminal | 回退到 MCP 或提示安裝 longbridge-terminal | Fall back to MCP or install longbridge-terminal |
65
+ | `not logged in` / `unauthorized` | 请运行 `longbridge auth login` | 請執行 `longbridge auth login` | Run `longbridge auth login` |
66
+ | `calc-index` returns null PE/PB | 跳过该标的,标注"数据缺失" | 跳過該標的,標注"數據缺失" | Skip symbol; mark as "data missing" |
67
+ | Universe > 50 stocks | 自动截取前50只成交额最大的标的 | 自動截取前50只 | Auto-limit to top-50 by turnover |
68
+ | Other stderr | 直接显示原始错误 | 直接顯示原始錯誤 | Surface verbatim |
@@ -0,0 +1,61 @@
1
+ # longbridge-pairs-trading
2
+
3
+ Statistical-arbitrage strategy for a pair of correlated securities. Tests for cointegration, estimates hedge ratio, computes spread Z-score, and outputs actionable long/short signals with half-life and position sizing guidance.
4
+
5
+ ## Workflow
6
+
7
+ 1. Fetch 252 daily candles for each symbol:
8
+ ```
9
+ longbridge kline <SYMBOL_A> --period day --count 252 --format json
10
+ longbridge kline <SYMBOL_B> --period day --count 252 --format json
11
+ ```
12
+ 2. Align on `time`, drop unmatched rows (different trading calendars).
13
+ 3. **Cointegration test (Engle-Granger)**:
14
+ - OLS regress `ln(close_A)` on `ln(close_B)` → hedge ratio β
15
+ - Compute residuals (spread) = `ln(close_A) − β × ln(close_B)`
16
+ - Run ADF test on residuals; if p-value < 0.05, declare cointegrated
17
+ 4. **Spread statistics**:
18
+ - Spread mean μ, std σ
19
+ - Z-score = (spread_current − μ) / σ
20
+ - Half-life λ = −ln(2) / OLS*slope of Δspread ~ spread*{t-1} (AR(1))
21
+ 5. **Signal**:
22
+ - Z > 2.0: 价差处于历史高位区间(统计上偏离均值偏大)/ Spread at historical high (statistically elevated)
23
+ - Z < −2.0: 价差处于历史低位区间(统计上偏离均值偏小)/ Spread at historical low (statistically depressed)
24
+ - |Z| < 0.5: 价差回归均值区间 / Spread near historical mean
25
+ 6. Position sizing: suggest equal-dollar or volatility-scaled sizing; note that execution must be simultaneous.
26
+
27
+ Run `longbridge kline --help` to confirm current flag names before calling.
28
+
29
+ ## CLI
30
+
31
+ ```bash
32
+ longbridge kline --help
33
+
34
+ longbridge kline <SYMBOL_A> --period day --count 252 --format json
35
+ longbridge kline <SYMBOL_B> --period day --count 252 --format json
36
+ ```
37
+
38
+ ## Output
39
+
40
+ | Metric | 简体 | 繁體 | English |
41
+ | --------------------- | ------------ | ------------ | --------------------- |
42
+ | Hedge ratio β | 对冲比率 | 對沖比率 | Hedge ratio |
43
+ | Cointegration p-value | 协整 p 值 | 協整 p 值 | Cointegration p-value |
44
+ | Spread Z-score | 价差 Z 分 | 價差 Z 分 | Spread Z-score |
45
+ | Half-life | 半衰期(天) | 半衰期(天) | Half-life (days) |
46
+ | Signal | 交易信号 | 交易訊號 | Trade signal |
47
+
48
+ Output: cointegration verdict → spread statistics table → current signal → position guidance. Add a risk note if p-value > 0.05 (not cointegrated). Cite **Longbridge Securities** / **数据来源:长桥证券** / **數據來源:長橋證券**.
49
+
50
+ > 以上内容仅供参考,不构成投资建议。投资决策请结合自身风险承受能力独立判断。
51
+ > The above is for reference only and does not constitute investment advice. Investment decisions should be made based on your own risk tolerance.
52
+
53
+ ## Error handling
54
+
55
+ | Situation | 简体回复 | 繁體回復 | English reply |
56
+ | -------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------------- |
57
+ | `command not found: longbridge` | 回退到 MCP 或提示安装 longbridge-terminal | 回退到 MCP 或提示安裝 longbridge-terminal | Fall back to MCP or install longbridge-terminal |
58
+ | `not logged in` / `unauthorized` | 请运行 `longbridge auth login` | 請執行 `longbridge auth login` | Run `longbridge auth login` |
59
+ | ADF p-value > 0.05 | 两标的未通过协整检验,配对交易风险较高 | 兩標的未通過協整檢驗,配對交易風險較高 | Not cointegrated; pairs trade is high-risk |
60
+ | Insufficient overlapping dates | 两标的历史数据重叠不足,无法建立配对 | 兩標的歷史數據重疊不足 | Insufficient overlapping history |
61
+ | Other stderr | 直接显示原始错误 | 直接顯示原始錯誤 | Surface verbatim |
@@ -0,0 +1,133 @@
1
+ # quant
2
+
3
+ Quantitative analysis: run indicator scripts against K-line data
4
+
5
+ Subcommands: run Example: longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 --script "..." Example: cat script.nv | longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31
6
+
7
+ Usage: longbridge quant [OPTIONS] <COMMAND>
8
+
9
+ Commands:
10
+ run Run a quant indicator script against historical K-line data on the server
11
+ help Print this message or the help of the given subcommand(s)
12
+
13
+ Options:
14
+ --format <FORMAT>
15
+ Output format: 'pretty' for human-readable, 'json' for AI agents and scripting
16
+
17
+ [default: pretty]
18
+ [possible values: table, json]
19
+
20
+ -v, --verbose
21
+ Print verbose request info (host, elapsed) to stderr, prefixed with `*` like curl -v
22
+
23
+ --lang <LANG>
24
+ Language for content fetched from longbridge.com: zh-CN or en. Defaults to system LANG env var, then en
25
+
26
+ --schema
27
+ Show response fields for this command and exit
28
+
29
+ -h, --help
30
+ Print help (see a summary with '-h')
31
+
32
+ ---
33
+
34
+ ## `quant run` — run an indicator script
35
+
36
+ ```
37
+ Run a quant indicator script against historical K-line data on the server
38
+
39
+ Executes the script server-side and returns the computed indicator/plot values as JSON. Scripts are written in Navi (.nv); pass --language pine for PineScript compatibility.
40
+
41
+ Periods: 1m 5m 15m 30m 1h day week month year
42
+
43
+ Script source (--script takes priority over stdin): --script TEXT inline script text stdin cat script.nv | longbridge quant run TSLA.US ...
44
+
45
+ The optional --input flag accepts a JSON array matching the order of input.*() calls in the script, e.g. --input '[14,2.0]'
46
+
47
+ Example: longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 --script "..." Example: cat script.nv | longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 Example: longbridge quant run 700.HK --period 1h --start 2024-01-01 --end 2024-06-30 --script "..." --input '[14]' Example: longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 --script "..." --format json Example: longbridge quant run 700.HK --period 1m --start "2024-01-02 09:30" --end "2024-01-02 16:00" --script "..." Example: cat script.pine | longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 --language pine
48
+
49
+ Usage: longbridge quant run [OPTIONS] --start <START> --end <END> <SYMBOL>
50
+
51
+ Arguments:
52
+ <SYMBOL>
53
+ Symbol in <CODE>.<MARKET> format, e.g. TSLA.US 700.HK
54
+
55
+ Options:
56
+ --period <PERIOD>
57
+ K-line period: 1m 5m 15m 30m 1h day week month year (default: day)
58
+
59
+ [default: day]
60
+
61
+ --start <START>
62
+ Start date/time for the K-line range (local YYYY-MM-DD, local "YYYY-MM-DD HH:MM", or RFC 3339)
63
+
64
+ --end <END>
65
+ End date/time for the K-line range (local YYYY-MM-DD, local "YYYY-MM-DD HH:MM", or RFC 3339)
66
+
67
+ --script <SCRIPT>
68
+ Script text. Omit to read from stdin (e.g. echo "..." | longbridge quant run ...)
69
+
70
+ --input <INPUT>
71
+ Script input values as a JSON array, e.g. '[14,2.0]' Must match the order of input.*() calls in the script
72
+
73
+ --language <LANGUAGE>
74
+ Script language: `navi` (default), or `pine` for PineScript compatibility
75
+
76
+ [default: navi]
77
+
78
+ --format <FORMAT>
79
+ Output format: 'pretty' for human-readable, 'json' for AI agents and scripting
80
+
81
+ [default: pretty]
82
+ [possible values: table, json]
83
+
84
+ -v, --verbose
85
+ Print verbose request info (host, elapsed) to stderr, prefixed with `*` like curl -v
86
+
87
+ --lang <LANG>
88
+ Language for content fetched from longbridge.com: zh-CN or en. Defaults to system LANG env var, then en
89
+
90
+ --schema
91
+ Show response fields for this command and exit
92
+
93
+ -h, --help
94
+ Print help (see a summary with '-h')
95
+ ```
96
+
97
+ ## Example script (Navi)
98
+
99
+ ```nv
100
+ indicator("RSI");
101
+
102
+ let length = input.int(14, "Length", minval: 1);
103
+ let rsi = ta.rsi(close, length);
104
+
105
+ plot(rsi, "RSI");
106
+ plot(70.0, "OB");
107
+ plot(30.0, "OS");
108
+ ```
109
+
110
+ ```bash
111
+ cat rsi.nv | longbridge quant run AAPL.US --start 2025-01-01 --end 2026-01-31
112
+ ```
113
+
114
+ ## Usage patterns
115
+
116
+ ```bash
117
+ # Run an inline script against a symbol
118
+ longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 --script "..."
119
+
120
+ # Pipe a script file
121
+ cat my_strategy.nv | longbridge quant run NVDA.US --start 2024-01-01 --end 2024-12-31
122
+
123
+ # Always add --format json for AI agent processing
124
+ longbridge quant run TSLA.US --start 2024-01-01 --end 2024-12-31 --script "..." --format json
125
+ ```
126
+
127
+ ## Notes
128
+
129
+ - Script language: **Navi** (`.nv`) by default; `--language pine` for PineScript compatibility. Any unrecognised value falls back to Navi.
130
+ - Navi syntax and standard library: <https://navi-lang.org> is authoritative. Install its CLI (<https://navi-lang.org/docs/install.md>) and run `navi lint script.nv` before sending — the API only reports script errors as an opaque error code.
131
+ - `--format json` sets `exclude_chart`, so series values are absent from the JSON response; backtest metrics still come back via `.report_json`.
132
+ - Run `longbridge quant run --help` for all current flags
133
+ - Use `longbridge kline` to preview the underlying OHLCV data first
@@ -0,0 +1,150 @@
1
+ # longbridge-quant-stats
2
+
3
+ Apply rigorous statistical methods to financial time-series data retrieved from Longbridge — test assumptions before modelling, diagnose residuals, and produce statistically sound inferences.
4
+
5
+ ## Prerequisites
6
+
7
+ ```bash
8
+ pip install statsmodels scipy numpy pandas
9
+ ```
10
+
11
+ ## Workflow and test catalogue
12
+
13
+ ### Step 1 — Fetch price data
14
+
15
+ ```bash
16
+ longbridge kline --help
17
+ longbridge kline <SYMBOL> --period day --count 252 --format json
18
+ ```
19
+
20
+ Extract the `close` price series. Compute log returns: `r_t = ln(P_t / P_{t-1})`.
21
+
22
+ ### Step 2 — Stationarity: ADF Unit Root Test
23
+
24
+ **When to use**: Before regression or time-series modelling — most models require stationary series.
25
+
26
+ **Python (statsmodels)**:
27
+
28
+ ```python
29
+ from statsmodels.tsa.stattools import adfuller
30
+ result = adfuller(series, autolag='AIC')
31
+ # result: (adf_stat, p_value, lags, n_obs, critical_values, icbest)
32
+ ```
33
+
34
+ **Interpretation**:
35
+
36
+ - p < 0.05 → reject unit root → series is stationary.
37
+ - p ≥ 0.05 → fail to reject → series has unit root → difference the series.
38
+ - Log prices: usually non-stationary. Log returns: usually stationary.
39
+
40
+ ### Step 3 — Cointegration Test
41
+
42
+ **When to use**: Two non-stationary series may share a long-run equilibrium (pairs trading).
43
+
44
+ **Engle-Granger (two-series)**:
45
+
46
+ ```python
47
+ from statsmodels.tsa.stattools import coint
48
+ t_stat, p_value, critical_values = coint(series_A, series_B)
49
+ # p < 0.05 → cointegrated
50
+ ```
51
+
52
+ **Johansen (multivariate)**:
53
+
54
+ ```python
55
+ from statsmodels.tsa.vector_ar.vecm import coint_johansen
56
+ result = coint_johansen(df, det_order=0, k_ar_diff=1)
57
+ # trace statistic vs critical values at 90%/95%/99%
58
+ ```
59
+
60
+ Report: test statistic, p-value, critical values, and cointegrating vector.
61
+
62
+ ### Step 4 — GARCH Volatility Modelling
63
+
64
+ **When to use**: Financial returns show volatility clustering (ARCH effects).
65
+
66
+ ```python
67
+ from arch import arch_model
68
+ model = arch_model(returns * 100, vol='Garch', p=1, q=1)
69
+ res = model.fit(disp='off')
70
+ print(res.summary())
71
+ ```
72
+
73
+ Note: `pip install arch` required in addition to statsmodels.
74
+
75
+ **Output**: omega, alpha (ARCH), beta (GARCH) coefficients. Persistence = alpha + beta. If > 0.95, volatility is highly persistent.
76
+
77
+ **ARCH-LM test first** (to verify ARCH effects exist):
78
+
79
+ ```python
80
+ from statsmodels.stats.diagnostic import het_arch
81
+ lm_stat, p_value, f_stat, f_p = het_arch(residuals)
82
+ ```
83
+
84
+ ### Step 5 — Regression Diagnostics
85
+
86
+ After running OLS (`statsmodels.api.OLS`), check:
87
+
88
+ | Test | Purpose | Command |
89
+ | ------------- | ----------------------------------- | ---------------------------------------------------------------- |
90
+ | Durbin-Watson | Serial autocorrelation in residuals | `statsmodels.stats.stattools.durbin_watson(resid)` |
91
+ | Breusch-Pagan | Heteroskedasticity | `statsmodels.stats.diagnostic.het_breuschpagan(resid, exog)` |
92
+ | Jarque-Bera | Normality of residuals | `statsmodels.stats.stattools.jarque_bera(resid)` |
93
+ | VIF | Multicollinearity | `statsmodels.stats.outliers_influence.variance_inflation_factor` |
94
+
95
+ Interpret Durbin-Watson: ~2.0 = no autocorrelation; < 1.5 = positive autocorrelation; > 2.5 = negative autocorrelation.
96
+
97
+ ### Step 6 — Bootstrap Confidence Intervals
98
+
99
+ **When to use**: Non-normal distributions; small samples; estimating CI for Sharpe ratio, IC, or any statistic.
100
+
101
+ ```python
102
+ import numpy as np
103
+
104
+ def bootstrap_ci(data, stat_fn, n_boot=10000, ci=0.95):
105
+ boots = [stat_fn(np.random.choice(data, len(data), replace=True))
106
+ for _ in range(n_boot)]
107
+ lo = np.percentile(boots, (1 - ci) / 2 * 100)
108
+ hi = np.percentile(boots, (1 + ci) / 2 * 100)
109
+ return lo, hi
110
+
111
+ # Example: Sharpe ratio CI
112
+ sharpe_lo, sharpe_hi = bootstrap_ci(returns, lambda x: x.mean() / x.std() * np.sqrt(252))
113
+ ```
114
+
115
+ ### Step 7 — Hypothesis Tests
116
+
117
+ | Test | Use case | Function |
118
+ | ------------------- | ------------------------------------------- | -------------------------------------------- |
119
+ | t-test (one sample) | Is mean IC > 0? | `scipy.stats.ttest_1samp(ic_series, 0)` |
120
+ | t-test (two sample) | Is long portfolio return > short portfolio? | `scipy.stats.ttest_ind(long_ret, short_ret)` |
121
+ | F-test / ANOVA | Are returns different across deciles? | `scipy.stats.f_oneway(*decile_returns)` |
122
+ | Mann-Whitney U | Non-parametric alternative to t-test | `scipy.stats.mannwhitneyu(a, b)` |
123
+
124
+ Always report: test statistic, p-value, degrees of freedom, and conclusion at 5% significance level.
125
+
126
+ ## CLI
127
+
128
+ ```bash
129
+ longbridge kline --help
130
+ longbridge kline <SYMBOL> --period day --count 252 --format json
131
+ ```
132
+
133
+ ## Output
134
+
135
+ For each test present:
136
+
137
+ 1. Test name and null hypothesis.
138
+ 2. Test statistic and p-value.
139
+ 3. Critical values (where applicable).
140
+ 4. Conclusion at 5% significance.
141
+ 5. Practical implication for the user's use case.
142
+
143
+ ## Error handling
144
+
145
+ | Situation | 简体回复 | 繁體回覆 | English reply |
146
+ | ------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------- |
147
+ | `command not found: longbridge` | 请安装 longbridge-terminal 或检查 MCP 配置。 | 請安裝 longbridge-terminal 或檢查 MCP 配置。 | Install longbridge-terminal or check MCP config. |
148
+ | `ModuleNotFoundError: statsmodels` | 请运行 `pip install statsmodels scipy numpy pandas`。 | 請執行 `pip install statsmodels scipy numpy pandas`。 | Run `pip install statsmodels scipy numpy pandas`. |
149
+ | Insufficient data (< 30 observations) | 样本量过小,统计结论可靠性有限,建议延长数据期。 | 樣本量過小,建議延長數據期。 | Sample too small; extend the data period for reliable results. |
150
+ | ARCH module missing for GARCH | 请运行 `pip install arch` 以使用 GARCH 模型。 | 請執行 `pip install arch` 以使用 GARCH 模型。 | Run `pip install arch` for GARCH modelling. |