Initial commit: Trading skills collection
- OKX交易自动化 (okx-auto-position, okx-crypto, okx-exchange) - 交易信号处理 (signal-confirmation-templates, trading-signal-aggregator) - 量化因子挖掘 (quant-factor-mining) - 长桥集成 (longbridge-cli, longbridge-python-sdk) - 六合彩分析 (lottery-hk) - 股息投资 (dividend-investing, dividend-scanner) - 日内交易 (intraday-trading) - 同花顺 (tonghuashun)
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
# LongPort Python SDK API Reference
|
||||
|
||||
## QuoteContext Methods (Watchlist & Quotes)
|
||||
|
||||
```python
|
||||
from longport import openapi
|
||||
cfg = openapi.Config.from_env()
|
||||
ctx = openapi.QuoteContext(config=cfg)
|
||||
```
|
||||
|
||||
### Watchlist Management
|
||||
|
||||
| Method | Description | Returns |
|
||||
|--------|-------------|---------|
|
||||
| `ctx.watchlist()` | Get all watchlist groups with securities | `list[WatchlistGroup]` |
|
||||
| `ctx.create_watchlist_group(name, securities)` | Create new watchlist group | - |
|
||||
| `ctx.update_watchlist_group(name, securities)` | Update existing group | - |
|
||||
| `ctx.delete_watchlist_group(name)` | Delete a watchlist group | - |
|
||||
|
||||
### Watchlist Response Structure
|
||||
|
||||
```python
|
||||
resp = ctx.watchlist()
|
||||
for group in resp:
|
||||
print(f'Group: {group.name}')
|
||||
print(f' Securities: {len(group.securities)}')
|
||||
for sec in group.securities:
|
||||
# sec has: symbol, market, name, watched_price, watched_at
|
||||
print(f' - {sec.symbol}: {sec.name} @ {sec.watched_price}')
|
||||
```
|
||||
|
||||
**WatchlistSecurity fields:**
|
||||
- `symbol` — e.g. "O.US", "823.HK"
|
||||
- `market` — "US", "HK", "CN"
|
||||
- `name` — display name
|
||||
- `watched_price` — `Some(float)` or `None`
|
||||
- `watched_at` — ISO timestamp string
|
||||
|
||||
**Special groups:**
|
||||
- `all` — contains all securities across groups (auto-generated)
|
||||
- `us` / `hk` — market-based auto-groups
|
||||
- User-created groups (e.g. "收息", "月派", "月拼", "季派")
|
||||
|
||||
### Quote Methods
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `ctx.quote(symbols)` | Get real-time quotes for symbols |
|
||||
| `ctx.realtime_quote(symbols)` | Real-time quote subscription |
|
||||
| `ctx.candlesticks(symbol, period, count)` | Get K-line data |
|
||||
| `ctx.history_candlesticks_by_offset(...)` | Historical K-lines |
|
||||
| `ctx.depth(symbol)` | Order book depth |
|
||||
| `ctx.trades(symbol)` | Recent trades |
|
||||
| `ctx.static_info(symbols)` | Static security info |
|
||||
| `ctx.capital_flow(symbol)` | Capital flow data |
|
||||
| `ctx.capital_distribution(symbol)` | Capital distribution |
|
||||
|
||||
### Quote Response
|
||||
|
||||
```python
|
||||
resp = ctx.quote(['O.US', 'STAG.US', 'AGNC.US'])
|
||||
for q in resp:
|
||||
print(f'{q.symbol}: ${q.last_done:.2f}, vol={q.volume}')
|
||||
```
|
||||
|
||||
**Quote fields:** `symbol`, `last_done`, `prev_close`, `volume`, `turnover`, `high`, `low`, `open`
|
||||
|
||||
## TradeContext Methods
|
||||
|
||||
```python
|
||||
trade_ctx = openapi.TradeContext(config=cfg)
|
||||
```
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `trade_ctx.stock_positions()` | Get holdings |
|
||||
| `trade_ctx.account_balance()` | Get account balance |
|
||||
| `trade_ctx.today_orders()` | Today's orders |
|
||||
| `trade_ctx.history_orders(...)` | Historical orders |
|
||||
| `trade_ctx.place_order(...)` | Place new order |
|
||||
| `trade_ctx.cancel_order(order_id)` | Cancel order |
|
||||
|
||||
### Positions Response
|
||||
|
||||
```python
|
||||
positions = trade_ctx.stock_positions()
|
||||
for ch in positions.channels:
|
||||
for pos in ch.positions:
|
||||
print(f'{pos.symbol}: {pos.quantity} @ {pos.cost_price}')
|
||||
```
|
||||
|
||||
## Symbol Format
|
||||
|
||||
| Market | Format | Example |
|
||||
|--------|--------|---------|
|
||||
| US | `{TICKER}.US` | `O.US`, `AAPL.US` |
|
||||
| HK | `{CODE}.HK` | `823.HK`, `9988.HK` |
|
||||
| CN | `{CODE}.SZ` or `{CODE}.SH` | `000001.SZ` |
|
||||
|
||||
## Market Access Notes
|
||||
|
||||
- LV1 Real-time Quotes: CN, HK, US
|
||||
- Nasdaq Basic: US stocks
|
||||
- USOption: requires separate purchase
|
||||
- Some markets may show access warnings on connect (normal)
|
||||
@@ -0,0 +1,83 @@
|
||||
# Chinese/Asian Broker SDK Comparison
|
||||
|
||||
## LongPort (长桥) vs Snowball Securities (雪盈)
|
||||
|
||||
| Feature | LongPort (`longbridge`) | Snowball (`snbpy`) |
|
||||
|---|---|---|
|
||||
| **CLI Tool** | ✅ `longport-cli` | ❌ None |
|
||||
| **Python SDK** | ✅ `longbridge` (PyPI) | ✅ `snbpy` (PyPI) |
|
||||
| **Java SDK** | ✅ | ✅ |
|
||||
| **Market Data API** | ✅ Realtime, K-lines, depth, options chain | ❌ No market data |
|
||||
| **Trading API** | ✅ Full (limit/market/stop/trailing) | ✅ 10 APIs |
|
||||
| **Watchlist API** | ✅ | ❌ |
|
||||
| **Fundamentals** | ✅ PE/PB/EPS/BPS/dividend yield | ❌ |
|
||||
| **Capital Flow** | ✅ | ❌ |
|
||||
| **Active Maintenance** | ✅ Regular updates | ⚠️ Last updated ~2021 |
|
||||
| **Market Coverage** | HK, US, CN, SG | HK, US (+ forex, futures, options, bonds) |
|
||||
| **GitHub Stars** | ~hundreds | 35 |
|
||||
|
||||
## Snowball Securities (`snbpy`) Details
|
||||
|
||||
### Install
|
||||
```bash
|
||||
pip install snbpy
|
||||
```
|
||||
|
||||
### 10 Core APIs
|
||||
| Method | Description |
|
||||
|---|---|
|
||||
| `login` | Get auth token |
|
||||
| `get_token_status` | Check token expiry |
|
||||
| `place_order` | Submit order |
|
||||
| `cancel_order` | Cancel order |
|
||||
| `get_order_by_id` | Query single order |
|
||||
| `get_order_list` | Query all orders |
|
||||
| `get_position_list` | Query holdings |
|
||||
| `get_balance` | Query account balance |
|
||||
| `get_security_detail` | Security info |
|
||||
| `get_transaction_list` | Query trade history |
|
||||
|
||||
### Supported Order Types
|
||||
Limit, Market, Stop, Stop Limit, Trailing, Market-on-Open, Limit-on-Open, Market-on-Close, Limit-on-Close
|
||||
|
||||
### Supported Asset Types
|
||||
Stocks (STK), Futures (FUT), Options (OPT), Warrants (WAR), CFDs, Forex (CASH), Bonds, Funds, CBBCs (IOPT)
|
||||
|
||||
### Configuration
|
||||
```python
|
||||
from snbpy.common.domain.snb_config import SnbConfig
|
||||
from snbpy.snb_api_client import SnbHttpClient
|
||||
|
||||
config = SnbConfig()
|
||||
config.account = "DU876752" # Your account ID
|
||||
config.key = 'your_secret_key'
|
||||
config.snb_server = 'openapi.snbsecurities.com' # prod
|
||||
config.snb_port = '443'
|
||||
config.schema = 'https'
|
||||
config.timeout = 1000
|
||||
|
||||
client = SnbHttpClient(config)
|
||||
client.login()
|
||||
```
|
||||
|
||||
### Environments
|
||||
| Env | URL | Account |
|
||||
|---|---|---|
|
||||
| SIT (test) | sandbox.snbsecurities.com | Contact support |
|
||||
| PROD (real) | openapi.snbsecurities.com | Self-register on website |
|
||||
|
||||
### Key Limitations
|
||||
- **No market data** — cannot get quotes, K-lines, or depth
|
||||
- **No CLI** — Python/Java SDK only
|
||||
- **Stale** — last PyPI release ~2021, no recent commits
|
||||
- **Token limit** — server keeps max 10 tokens per user
|
||||
|
||||
### GitHub
|
||||
https://github.com/snowballsecurities/snbpy (35 stars, MIT license)
|
||||
|
||||
### Docs
|
||||
https://snowballsecurities.github.io/
|
||||
|
||||
## When to Use Which
|
||||
- **LongPort**: Primary choice for everything — data, trading, analysis
|
||||
- **Snowball**: Only if you have a Snowball account and want to automate trades there. Use LongPort for all market data regardless.
|
||||
@@ -0,0 +1,91 @@
|
||||
# LongPort CalcIndex Enum Reference
|
||||
|
||||
## 估值相关 (Valuation)
|
||||
| Enum | 说明 | 单位 | 示例 |
|
||||
|------|------|------|------|
|
||||
| `PeTtmRatio` | PE TTM | 倍 | 49.91 |
|
||||
| `PbRatio` | PB | 倍 | 1.43 |
|
||||
| `DividendRatioTtm` | 股息率 TTM | % | 5.40 |
|
||||
| `TotalMarketValue` | 总市值 | 货币单位 | 55921577024.10 |
|
||||
|
||||
## 行情相关 (Market)
|
||||
| Enum | 说明 | 单位 |
|
||||
|------|------|------|
|
||||
| `LastDone` | 最新价 | 货币单位 |
|
||||
| `ChangeRate` | 涨跌幅 | % |
|
||||
| `ChangeValue` | 涨跌额 | 货币单位 |
|
||||
| `Volume` | 成交量 | 股 |
|
||||
| `Turnover` | 成交额 | 货币单位 |
|
||||
| `TurnoverRate` | 换手率 | % |
|
||||
| `VolumeRatio` | 量比 | 倍 |
|
||||
| `Amplitude` | 振幅 | % |
|
||||
|
||||
## 周期涨跌幅 (Period Returns)
|
||||
| Enum | 说明 |
|
||||
|------|------|
|
||||
| `FiveMinutesChangeRate` | 5分钟涨跌幅 |
|
||||
| `FiveDayChangeRate` | 5日涨跌幅 |
|
||||
| `TenDayChangeRate` | 10日涨跌幅 |
|
||||
| `HalfYearChangeRate` | 半年涨跌幅 |
|
||||
| `YtdChangeRate` | 年初至今涨跌幅 |
|
||||
|
||||
## 期权相关 (Options)
|
||||
| Enum | 说明 |
|
||||
|------|------|
|
||||
| `ImpliedVolatility` | 隐含波动率 |
|
||||
| `Delta` | Delta |
|
||||
| `Gamma` | Gamma |
|
||||
| `Theta` | Theta |
|
||||
| `Vega` | Vega |
|
||||
| `Rho` | Rho |
|
||||
| `StrikePrice` | 行权价 |
|
||||
| `ExpiryDate` | 到期日 |
|
||||
| `Premium` | 溢价 |
|
||||
| `ItmOtm` | 价内/价外 |
|
||||
| `EffectiveLeverage` | 有效杠杆 |
|
||||
| `LeverageRatio` | 杠杆比率 |
|
||||
| `CallPrice` | 召回价 |
|
||||
| `ToCallPrice` | 距召回价 |
|
||||
| `ConversionRatio` | 换股比率 |
|
||||
| `BalancePoint` | 打和点 |
|
||||
| `OpenInterest` | 未平仓数 |
|
||||
| `OutstandingQty` | 街货量 |
|
||||
| `OutstandingRatio` | 街货占比 |
|
||||
| `UpperStrikePrice` | 上限价 |
|
||||
| `LowerStrikePrice` | 下限价 |
|
||||
| `WarrantDelta` | 窝轮Delta |
|
||||
|
||||
## static_info 字段
|
||||
| 字段 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `symbol` | 代码 | O.US |
|
||||
| `name_cn` | 中文名 | Realty Income MD |
|
||||
| `name_en` | 英文名 | Realty Income MD |
|
||||
| `name_hk` | 港股名 | Realty Income MD |
|
||||
| `currency` | 货币 | USD |
|
||||
| `lot_size` | 每手股数 | 1 |
|
||||
| `eps` | EPS | 1.135 |
|
||||
| `eps_ttm` | EPS TTM | 1.202 |
|
||||
| `bps` | 每股净资产 | 41.98 |
|
||||
| `dividend_yield` | 股息率 | 3.237 |
|
||||
| `total_shares` | 总股本 | 932492530 |
|
||||
| `circulating_shares` | 流通股 | 930306268 |
|
||||
| `exchange` | 交易所 | NYSE |
|
||||
| `board` | 板块 | SecurityBoard.USMain |
|
||||
|
||||
## 用法示例
|
||||
```python
|
||||
from longport import openapi
|
||||
from longport.openapi import CalcIndex
|
||||
|
||||
cfg = openapi.Config.from_env()
|
||||
ctx = openapi.QuoteContext(config=cfg)
|
||||
|
||||
# 估值指标
|
||||
resp = ctx.calc_indexes(['O.US'], [CalcIndex.PeTtmRatio, CalcIndex.PbRatio, CalcIndex.DividendRatioTtm])
|
||||
print(f'PE: {resp[0].pe_ttm_ratio}, PB: {resp[0].pb_ratio}, 股息率: {resp[0].dividend_ratio_ttm}%')
|
||||
|
||||
# 基本面
|
||||
info = ctx.static_info(['O.US'])[0]
|
||||
print(f'EPS_TTM: {info.eps_ttm}, BPS: {info.bps}')
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
# DCA Scanner & Monitoring Architecture
|
||||
|
||||
## Overview
|
||||
Pattern for automated high-dividend stock scanning across multiple markets (HK/US/CN), with DCA ladder buy-signal monitoring.
|
||||
|
||||
## Architecture
|
||||
|
||||
### Two script types:
|
||||
1. **Scanner** (`dca_scanner.py`) — Scans a candidate pool for high-yield stocks, pushes TOP5 with ladder prices
|
||||
2. **Monitor** (`dca_monitor.py`) — Watches existing positions for buy-signal triggers against ladder levels
|
||||
|
||||
### Market separation:
|
||||
- Each script accepts `--market=hk|us|cn` to filter positions/candidates
|
||||
- Cron jobs are split per market to avoid API collisions and match trading hours
|
||||
- Scanner candidate pools are hardcoded per market (24 HK / 15 US / 14 CN)
|
||||
|
||||
### Cron schedule pattern (EDT, staggered ≥15min):
|
||||
```
|
||||
A股扫描: 19:30 (= 北京 7:30AM, A股开盘前)
|
||||
港股扫描: 20:00 (= 北京 8:00AM, 港股开盘前)
|
||||
美股扫描: 21:30 (= 北京 9:30AM, 美股开盘前)
|
||||
美股监控1: 22:30 (美股盘中)
|
||||
美股监控2: 02:00 (美股盘中)
|
||||
```
|
||||
|
||||
### Rate limiting prevention:
|
||||
- No two LongPort jobs share the same minute
|
||||
- Scanner and Monitor never run simultaneously
|
||||
- RGTI price monitoring (if needed) at 30min intervals, NOT 10/15min
|
||||
|
||||
## Key design decisions:
|
||||
1. **User wants push-based scanning** — "你要扫描高股息的发通知给我,不是我选" — system scans and pushes candidates, user doesn't manually pick from lists
|
||||
2. **30min polling is enough** for price monitoring — user explicitly said "半小时吧,不需要太频繁"
|
||||
3. **Merge overlapping tasks** — price alert + auto order were merged into one (RGTI)
|
||||
4. **Pause mislabeled tasks** — "港股监控" that only had US stocks was paused
|
||||
5. **Add dividend frequency** to all output — `[季度]` / `[月度]` / `[半年]` suffix
|
||||
|
||||
## Data files:
|
||||
- `~/.hermes/scripts/dca_positions.json` — Current positions with ladder prices, yields, div_freq
|
||||
- `~/.hermes/scripts/dca_scanner.py` — Market scanner with candidate pools
|
||||
- `~/.hermes/scripts/dca_monitor.py` — Ladder monitor with market filter support
|
||||
@@ -0,0 +1,21 @@
|
||||
# LongPort API Error Codes
|
||||
|
||||
## Authentication Errors
|
||||
| Code | Meaning | Fix |
|
||||
|------|---------|-----|
|
||||
| 401004 | Token invalid | Token truncated/expired. Check bashrc has full token (1053 chars). Use Python to parse bashrc directly, don't rely on `source`. |
|
||||
| 403201 | Auth failed | Similar to 401004 — token masking by terminal tool. Use `execute_code` + SDK instead of CLI. |
|
||||
|
||||
## Geo-Restriction Errors
|
||||
| Code | Meaning | Fix |
|
||||
|------|---------|-----|
|
||||
| 602315 | Mainland China regulatory block | API detects mainland China IP. Must use VPN (HK/US/etc). Read-only may still work; trading is blocked. |
|
||||
|
||||
## Trading Errors
|
||||
| Code | Meaning | Fix |
|
||||
|------|---------|-----|
|
||||
| 301607 | Too many k-lines requested | Max ~1000 per `candlesticks()` call. Use `history_candlesticks_by_offset()` for pagination. |
|
||||
|
||||
## Common Error Patterns
|
||||
- **401004 + 602315**: Both appeared in same session. 401004 was from truncated token in .env, 602315 after token was fixed (real token loaded from bashrc).
|
||||
- **Token "..." truncation**: bashrc shows `m_eyJh...jb-k` in grep output even when full 1053-char token exists. The `...` is just display truncation by the shell/terminal, not in the actual file. Use `python3 -c "import os; ..."` to verify real length.
|
||||
@@ -0,0 +1,79 @@
|
||||
# High Dividend Yield Candidate Universe
|
||||
|
||||
Pre-curated symbol lists for dividend screener scripts. Last verified: 2026-06-06 via LongPort.
|
||||
|
||||
## US — BDC (Business Development Companies)
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| HRZN.US | ~25% | 0.3B | Horizon Technology Finance |
|
||||
| PSEC.US | ~24% | 1.1B | Prospect Capital |
|
||||
| FSK.US | ~22% | 3.0B | FS KKR Capital |
|
||||
| TSLX.US | ~11% | 1.7B | Sixth Street Specialty |
|
||||
| HTGC.US | ~10% | 2.8B | Hercules Capital |
|
||||
| ARCC.US | ~10% | 13.5B | Ares Capital (largest BDC) |
|
||||
| MAIN.US | ~6% | 4.8B | Main Street Capital |
|
||||
| GAIN.US | ~6% | 0.6B | Gladstone Investment |
|
||||
| GLAD.US | ~9% | 0.4B | Gladstone Capital |
|
||||
| PFLT.US | ~15% | 0.8B | PennantPark Floating |
|
||||
|
||||
## US — mREIT (Mortgage REITs)
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| ORC.US | ~21% | 1.3B | Orchid Island Capital |
|
||||
| IVR.US | ~21% | 0.7B | Invesco Mortgage Capital |
|
||||
| ARR.US | ~17% | 2.1B | ARMOUR Residential |
|
||||
| DX.US | ~16% | 2.6B | Dynex Capital |
|
||||
| AGNC.US | ~14% | 11.7B | AGNC Investment (largest mREIT) |
|
||||
| NLY.US | ~13% | 15.5B | Annaly Capital |
|
||||
| CIM.US | ~12% | 1.1B | Chimera Investment |
|
||||
| NYMT.US | ~11% | 0.6B | New York Mortgage Trust |
|
||||
|
||||
## US — High Dividend ETFs
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| SVOL.US | ~22% | 0.6B | Simplify Volatility Premium |
|
||||
| QQQI.US | ~14% | 11.0B | Defiance Nasdaq-100 Enhanced |
|
||||
| SPYI.US | ~12% | 9.1B | Neos S&P 500 High Income |
|
||||
| QYLD.US | ~12% | 8.3B | Global X NASDAQ-100 Covered Call |
|
||||
| PTY.US | ~12% | 2.5B | Pimco Corporate & Income |
|
||||
| JEPI.US | ~8% | 43.5B | JPMorgan Equity Premium Income |
|
||||
| JEPQ.US | ~10% | 36.7B | JPMorgan Nasdaq Equity Premium |
|
||||
| DIVO.US | ~6% | 6.9B | Amplify CWP Enhanced Dividend |
|
||||
|
||||
## US — MLP (Master Limited Partnerships)
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| USAC.US | ~8% | 4.0B | USA Compression Partners |
|
||||
| MPLX.US | ~7% | 57.3B | MPLX LP |
|
||||
| ET.US | ~7% | 66.7B | Energy Transfer |
|
||||
| EPD.US | ~6% | 81.8B | Enterprise Products Partners |
|
||||
|
||||
## US — Blue Chip Dividend
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| KHC.US | ~7% | 26.7B | Kraft Heinz |
|
||||
| VZ.US | ~6% | 189.4B | Verizon |
|
||||
| MO.US | ~6% | 120.5B | Altria |
|
||||
| O.US | ~5% | 56.7B | Realty Income (monthly dividend) |
|
||||
|
||||
## HK — High Dividend ETFs
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| 3417.HK | ~19% | 2.9B | 华夏沪深三百高股息ETF |
|
||||
| 3416.HK | ~19% | 24.1B | 华夏恒生高股息ETF |
|
||||
| 3419.HK | ~15% | 1.7B | 华夏沪深三百精选高股息 |
|
||||
|
||||
## HK — Blue Chip High Dividend
|
||||
| Symbol | Yield (TTM) | Mkt Cap | Notes |
|
||||
|--------|-------------|---------|-------|
|
||||
| 1088.HK | ~7% | 1000B | 中国神华 |
|
||||
| 0883.HK | ~5% | — | 中海油 |
|
||||
| 3968.HK | ~7% | 1215B | 招商银行 |
|
||||
| 1919.HK | ~7% | 230B | 中远海控 |
|
||||
| 2318.HK | ~5% | 1030B | 中国平安 |
|
||||
|
||||
## Key Insight
|
||||
**No stock reliably sustains 30%+ dividend yield.** The practical ceiling for "investable" high yield is:
|
||||
- US: ~10-15% (BDC/mREIT, with leverage risk)
|
||||
- HK: ~15-19% (high-div ETFs)
|
||||
- Anything >25% is almost certainly a special dividend, yield trap, or price collapse artifact.
|
||||
@@ -0,0 +1,58 @@
|
||||
# Hong Kong Dividend Investing Reference
|
||||
|
||||
## Key Facts
|
||||
- **No true monthly dividend stocks in HK** — unlike US (Realty Income O, AGNC), no individual HK stock pays monthly
|
||||
- Most HK stocks pay **semi-annually** (年报 + 中报), some pay **quarterly**
|
||||
- To get monthly cash flow, combine stocks with different payment months OR use monthly-dividend ETFs
|
||||
|
||||
## Monthly Dividend ETF (Hong Kong)
|
||||
| ETF | Code | Yield | Freq | Entry Cost |
|
||||
|---|---|---|---|---|
|
||||
| 恒生高息股30 ETF | 3466.HK | ~6.8% | Monthly | ~8,200 HKD |
|
||||
| 富邦沪深港高股息 | 3190.HK | ~6% | Quarterly | ~3,460 HKD |
|
||||
| GX亚太高股息 | 3116.HK | ~6% | Quarterly | ~3,000 HKD |
|
||||
|
||||
**3466** is the only true monthly-dividend HK ETF. Top holdings include 中国宏桥(1378), 裕元(551), 恒隆(101), 伟易达(303), 中远海控(1919).
|
||||
|
||||
## Quarterly Dividend HK Stocks (combine for monthly income)
|
||||
| Stock | Code | Payment Months | Yield |
|
||||
|---|---|---|---|
|
||||
| 中电控股 | 0002.HK | 3/6/9/12 | ~4.5% |
|
||||
| 汇丰控股 | 0005.HK | 4/6/9/12 | ~5% |
|
||||
| 宏利金融 | 0945.HK | 3/6/9/12 | ~4% |
|
||||
| 中银香港 | 2388.HK | 5/9/11/末期 | ~5.5% |
|
||||
| 港通控股 | 0032.HK | 6/7/9/12 | ~3% |
|
||||
|
||||
## Entry Price Analysis Methodology
|
||||
When user asks for entry price for dividend stocks:
|
||||
|
||||
1. **Gather data** (use LongPort SDK):
|
||||
- Current price, PE, PB, 52-week range
|
||||
- TTM dividend yield via `CalcIndex.DividendRatioTtm`
|
||||
2. **Get dividend history** from 理杏仁 (lixinger.com) or web search:
|
||||
- Recent years' per-share dividends
|
||||
- Payment schedule (年报/中报 split)
|
||||
- Payout ratio trend
|
||||
3. **Calculate yield at different price levels**:
|
||||
- 理想 (ideal): near 52-week low, yield >9%, PB <0.7
|
||||
- 合理 (fair): recent support, yield ~8%, PB <0.8
|
||||
- 可接受 (acceptable): current price, yield ~7-8%
|
||||
4. **Cross-reference**: analyst targets (中金/中信/华泰), consensus upside
|
||||
5. **Risk factors**: cycle risk, payout sustainability, short interest
|
||||
|
||||
## DCA Threshold for Dividend Stocks
|
||||
User's rule: only keep stocks with **≥7% dividend yield**. Below 7% → auto-filter out.
|
||||
Current DCA portfolio: NLY, HTGC, ARCC (all BDC/REIT, monthly payers).
|
||||
|
||||
## Data Sources (ranked by reliability for HK dividends)
|
||||
1. **LongPort SDK** — real-time yield, PE, PB (use `calc_indexes`)
|
||||
2. **理杏仁 (lixinger.com)** — best for historical dividend tables, payout rates
|
||||
3. **英为财情 (investing.com)** — dividend calendar, yield comparison
|
||||
4. **华盛通 (hstong.com)** — real-time quotes, news flow
|
||||
5. **券商研报** — target prices, payout forecasts
|
||||
|
||||
## Presentation Style (user preference)
|
||||
- 一句话总结 + 关键数据 + emoji标记
|
||||
- Card/table format, not wall of text
|
||||
- 3-tier entry price table (理想/合理/可接受) with yield at each level
|
||||
- Include risk section but keep it brief (2-3 bullet points)
|
||||
@@ -0,0 +1,155 @@
|
||||
# WireGuard Proxy for LongPort API (China Mainland Bypass)
|
||||
|
||||
## Problem
|
||||
LongPort API blocks trading from mainland China IPs with error 602315:
|
||||
> "Due to Mainland China regulatory requirements, you are currently located in Mainland China and cannot perform this action."
|
||||
|
||||
Read-only operations (quotes, positions) may still work, but order placement fails.
|
||||
|
||||
## Solution: WireGuard VPN with On-Demand Proxy
|
||||
|
||||
### Architecture
|
||||
```
|
||||
Server (China mainland) ──WireGuard──> VPS (HK/US/JP) ──> LongPort API
|
||||
```
|
||||
|
||||
WireGuard is faster and more stable than application-layer proxies (Clash, V2Ray) because it operates at the kernel level.
|
||||
|
||||
### Setup Steps
|
||||
|
||||
#### 1. Install WireGuard
|
||||
```bash
|
||||
sudo apt update && sudo apt install -y wireguard resolvconf
|
||||
```
|
||||
|
||||
#### 2. Get client config from WireGuard server
|
||||
The user provides a config like:
|
||||
```ini
|
||||
[Interface]
|
||||
PrivateKey = <key>
|
||||
Address = 10.8.0.7/32
|
||||
MTU = 1420
|
||||
DNS = 1.1.1.1
|
||||
|
||||
[Peer]
|
||||
PublicKey = <key>
|
||||
PresharedKey = <key>
|
||||
AllowedIPs = 0.0.0.0/0, ::/0
|
||||
PersistentKeepalive = 25
|
||||
Endpoint = wg.example.com:51820
|
||||
```
|
||||
|
||||
#### 3. Install config
|
||||
```bash
|
||||
sudo cp /tmp/wg0.conf /etc/wireguard/wg0.conf
|
||||
sudo chmod 600 /etc/wireguard/wg0.conf
|
||||
```
|
||||
|
||||
#### 4. Start WireGuard
|
||||
```bash
|
||||
sudo wg-quick up wg0
|
||||
```
|
||||
|
||||
#### 5. Enable on boot
|
||||
```bash
|
||||
sudo systemctl enable wg-quick@wg0
|
||||
```
|
||||
|
||||
#### 6. Verify
|
||||
```bash
|
||||
sudo wg show # Check handshake
|
||||
curl -s ifconfig.me # Should show VPS IP, not mainland IP
|
||||
```
|
||||
|
||||
### On-Demand Proxy Scripts
|
||||
|
||||
Instead of routing ALL traffic through VPN (slow), use on-demand scripts:
|
||||
|
||||
**`~/.local/bin/wg-trade`** — Run single command through VPN:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Usage: wg-trade <command>
|
||||
CMD="$1"
|
||||
shift
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: wg-trade <command>"
|
||||
exit 1
|
||||
fi
|
||||
if ! sudo wg show wg0 2>/dev/null | grep -q "latest handshake"; then
|
||||
echo "🔄 Starting WireGuard..."
|
||||
sudo wg-quick up wg0 2>/dev/null
|
||||
fi
|
||||
echo "🔒 Running via VPN: $@"
|
||||
"$@"
|
||||
```
|
||||
|
||||
**`~/.local/bin/wg-on`** / **`wg-off`** / **`wg-status`** — Toggle VPN:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# wg-on: enable full VPN
|
||||
sudo wg-quick up wg0 2>/dev/null
|
||||
echo "✅ WireGuard ON — IP: $(curl -s --max-time 5 ifconfig.me)"
|
||||
|
||||
#!/bin/bash
|
||||
# wg-off: disable VPN
|
||||
sudo wg-quick down wg0 2>/dev/null
|
||||
echo "❌ WireGuard OFF"
|
||||
|
||||
#!/bin/bash
|
||||
# wg-status: check VPN status
|
||||
if sudo wg show wg0 2>/dev/null | grep -q "latest handshake"; then
|
||||
echo "✅ WireGuard: Connected — VPN IP: $(curl -s --max-time 5 ifconfig.me)"
|
||||
else
|
||||
echo "❌ WireGuard: Disconnected"
|
||||
fi
|
||||
```
|
||||
|
||||
Make executable: `chmod +x ~/.local/bin/wg-trade ~/.local/bin/wg-on ~/.local/bin/wg-off ~/.local/bin/wg-status`
|
||||
|
||||
### Usage with LongPort Trading
|
||||
|
||||
```bash
|
||||
# Trade through VPN
|
||||
wg-trade python3 ~/.hermes/scripts/rgti_auto_t.py status
|
||||
|
||||
# Or use Python SDK directly (WireGuard is already routing all traffic when up)
|
||||
python3 -c "
|
||||
import os
|
||||
with open(os.path.expanduser('~/.bashrc')) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line.startswith('export LONGBRIDGE_') or line.startswith('export LONGPORT_'):
|
||||
parts = line.replace('export ', '').split('=', 1)
|
||||
if len(parts) == 2:
|
||||
os.environ[parts[0]] = parts[1]
|
||||
|
||||
from longport import openapi
|
||||
cfg = openapi.Config.from_env()
|
||||
ctx = openapi.TradeContext(config=cfg)
|
||||
resp = ctx.submit_order(
|
||||
symbol='SPCX.US',
|
||||
order_type=openapi.OrderType.LO,
|
||||
side=openapi.OrderSide.Buy,
|
||||
submitted_quantity=2,
|
||||
time_in_force=openapi.TimeInForceType.GoodTilCanceled,
|
||||
submitted_price=150.00,
|
||||
outside_rth=openapi.OutsideRTH.AnyTime,
|
||||
)
|
||||
print(f'Order ID: {resp.order_id}')
|
||||
"
|
||||
```
|
||||
|
||||
### Common WireGuard Commands
|
||||
```bash
|
||||
sudo wg-quick up wg0 # Start
|
||||
sudo wg-quick down wg0 # Stop
|
||||
sudo wg show # Status (handshake, transfer)
|
||||
sudo systemctl status wg-quick@wg0 # Service status
|
||||
```
|
||||
|
||||
### Pitfalls
|
||||
- **resolvconf not installed**: `wg-quick` fails with `resolvconf: command not found`. Fix: `sudo apt install -y resolvconf`
|
||||
- **wg0 already exists**: If WireGuard was up and you try `wg-quick up wg0` again, it fails. Use `sudo wg show wg0` to check status, or `sudo wg-quick down wg0 && sudo wg-quick up wg0` to restart.
|
||||
- **DNS leak**: With `AllowedIPs = 0.0.0.0/0`, DNS also goes through VPN. This is usually desired for geo-unblocking.
|
||||
- **PersistentKeepalive**: Set to 25 for NAT traversal. Without it, idle tunnels may drop.
|
||||
- **Speed**: WireGuard is kernel-level and fast, but still limited by VPS bandwidth. For non-trading traffic, consider split tunneling (only route LongPort IPs through VPN).
|
||||
Reference in New Issue
Block a user