JohnDaWalka/WE-CFM-Orchestrator
GitHub: JohnDaWalka/WE-CFM-Orchestrator
一个自学习的加密货币预测引擎,利用实时市场数据和自适应算法优化15分钟价格涨跌预测。
Stars: 2 | Forks: 3
# 🚀 WE-CRYPTO: 自学习加密货币预测引擎
Markets (Every 30s)
Kalshi, Polymarket
Coinbase"] -->|Settlement Data| B["🧮 Calculate
Signal Accuracy
9 Indicators
Per Coin"] B -->|Win Rate %| C["📈 Auto-Tune
Weights
Boost/Reduce
Signal Strength"] C -->|Apply New Weights| D["🎲 Generate
Live Predictions
15-Min Direction
Confidence Score"] D -->|Display| E["✅ User Sees
Real-Time Card
Portfolio WR
Accuracy Trending"] E -->|Feedback Loop| A style A fill:#1e90ff,color:#fff,stroke:#000,stroke-width:2px style B fill:#228b22,color:#fff,stroke:#000,stroke-width:2px style C fill:#ff8c00,color:#fff,stroke:#000,stroke-width:2px style D fill:#9370db,color:#fff,stroke:#000,stroke-width:2px style E fill:#20b2aa,color:#fff,stroke:#000,stroke-width:2px ```
## 🏗️ 三层自适应学习栈
```
graph TD
subgraph rt["🔴 Real-Time Layer (30 seconds)"]
RT1["Poll Historical Markets"]
RT2["Rapid Accuracy Check"]
RT3["Fast Gate Adjustments ±4-8%"]
end
subgraph ss["🟠 Snapshot Layer (1 hour)"]
SS1["Aggregate 60 Minutes"]
SS2["Market Regime Detection"]
SS3["Weight Tuning ±8%"]
end
subgraph wf["🟡 Walk-Forward Layer (Daily)"]
WF1["14-Day Sliding Window"]
WF2["Baseline Optimization"]
WF3["Seasonal Adjustment"]
end
RT1 --> RT2 --> RT3 --> PRED["🎲 Generate
Live Predictions"] SS1 --> SS2 --> SS3 --> PRED WF1 --> WF2 --> WF3 --> PRED PRED --> ACC["📊 Accuracy
Scorecard
Portfolio WR"] ACC --> LEARN["🧠 Learning
Engine
Records Outcomes"] LEARN --> RT1 style rt fill:#ffcccc,stroke:#cc0000,stroke-width:2px style ss fill:#ffe6cc,stroke:#ff8800,stroke-width:2px style wf fill:#ffffcc,stroke:#cccc00,stroke-width:2px style PRED fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style ACC fill:#ccffcc,stroke:#00cc00,stroke-width:2px style LEARN fill:#ffccff,stroke:#cc00cc,stroke-width:2px ```
**性能:**
- **实时层** 在 <60 秒内检测错误(比之前快 15-60 倍)
- **快照层** 每小时适应市场体制变化
- **前向推进层** 每日防止季节性过拟合
## 🧬 预测信号流:9 个指标 → 1 个分数
```
graph TD
subgraph inputs["📥 Input Layer"]
C1["Close Price"]
H["High/Low"]
V["Volume"]
BP["Book Pressure"]
end
subgraph layer1["🔧 Indicator Layer — 9 Signals"]
RSI["RSI
(Momentum)"] MACD["MACD
(Trend)"] CCI["CCI
(Cycles)"] FISHER["Fisher
(Reversal)"] ADX["ADX
(Strength)"] ATR["ATR
(Volatility)"] OB["Order Book
(Imbalance)"] KALSHI["Kalshi %
(Market Prob)"] CF["Crowd Fade
(Contrarian)"] end subgraph layer2["⚖️ Weighting Layer — Adaptive"] W1["RSI Weight
×1.2"] W2["MACD Weight
×0.9"] W3["CCI Weight
×1.0"] W4["Others..."] end subgraph layer3["🎯 Aggregation"] AGG["Weighted Sum
+ Regime Filter
+ Gate Check"] end subgraph output["🎲 Output"] SCORE["Confidence
0-100"] DIR["Direction
UP or DOWN"] end C1 --> RSI H --> MACD V --> CCI BP --> FISHER RSI --> W1 MACD --> W2 CCI --> W3 FISHER --> W4 ADX --> W4 ATR --> W4 OB --> W4 KALSHI --> W4 CF --> W4 W1 --> AGG W2 --> AGG W3 --> AGG W4 --> AGG AGG --> SCORE AGG --> DIR SCORE --> output DIR --> output style inputs fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style layer1 fill:#fff0f5,stroke:#cc0066,stroke-width:2px style layer2 fill:#fff8dc,stroke:#cccc00,stroke-width:2px style layer3 fill:#f0fff0,stroke:#00cc00,stroke-width:2px style output fill:#ffcccc,stroke:#cc0000,stroke-width:2px ```
## 📊 数据流:Electron → 渲染器 → 预测引擎
```
graph LR
subgraph electron["⚛️ Electron Main"]
MAIN["main.js
BrowserWindow"] IPC["Electron IPC
Secure Bridge"] end subgraph renderer["🎨 Renderer Process"] APP["app.js
UI Controller"] BRIDGE["kalshi-renderer-bridge.js
API Handler"] end subgraph engine["🔧 Prediction Engine"] PRED["predictions.js
Signal Calculation"] LEARNER["adaptive-learning-engine.js
Weight Tuning"] FETCHER["historical-settlement-fetcher.js
Market Data"] end subgraph apis["🌐 External APIs"] KALSHI["Kalshi API
Settled Contracts"] POLY["Polymarket API
Resolved Markets"] COIN["Coinbase API
Predictions"] BINANCE["Binance/Kraken
OHLCV Candles"] PYTH["Pyth Network
Price Feeds & CI"] end MAIN --> IPC IPC --> APP APP --> BRIDGE BRIDGE --> PRED PRED --> LEARNER LEARNER --> FETCHER FETCHER --> KALSHI FETCHER --> POLY FETCHER --> COIN FETCHER --> BINANCE FETCHER --> PYTH style electron fill:#1e90ff,color:#fff,stroke:#000,stroke-width:2px style renderer fill:#228b22,color:#fff,stroke:#000,stroke-width:2px style engine fill:#ff8c00,color:#fff,stroke:#000,stroke-width:2px style apis fill:#4169e1,color:#fff,stroke:#000,stroke-width:2px ```
## 🔄 30 秒轮询周期:心跳
```
sequenceDiagram
participant Clock as ⏱️ Clock
participant Fetcher as 📡 Fetcher
participant Learner as 🧠 Learner
participant Engine as 🔧 Engine
participant UI as 📊 UI
Clock->>Fetcher: Every 30 seconds
Fetcher->>Fetcher: 1️⃣ Fetch Kalshi settled
Fetcher->>Fetcher: 2️⃣ Fetch Polymarket resolved
Fetcher->>Fetcher: 3️⃣ Calculate per-coin accuracy
Fetcher->>Learner: Pass 300+ settled trades
Learner->>Learner: 4️⃣ Record signal contributions
Learner->>Learner: 5️⃣ Calculate per-indicator WR
Learner->>Learner: 6️⃣ Detect outperformers
alt Every 2 Minutes
Learner->>Learner: 7️⃣ AUTO-TUNE WEIGHTS
Learner->>Learner: • Boost >55% WR (+5%)
Learner->>Learner: • Reduce <45% WR (-5%)
Learner->>Learner: • Trending acceleration ×1.5
end
Learner->>Engine: Apply updated weights
Engine->>Engine: 8️⃣ Generate live predictions
Engine->>Engine: • All 9 signals
Engine->>Engine: • Apply gates/filters
Engine->>Engine: • Score confidence
Engine->>UI: New predictions ready
UI->>UI: 9️⃣ Update dashboard
UI->>UI: • Accuracy card
UI->>UI: • Per-coin stats
UI->>UI: • Tuning badge
```
## 🎓 自适应学习:自学习循环
```
graph TD
A["📚 Fetch Historical
Markets (30s)"] -->|"Settlement Data
Kalshi, Polymarket"| B["🧮 Calculate
Accuracy"] B -->|"Per-coin
Per-signal WR"| C["📊 Track
Trending"] C -->|"Need 5+
samples?"| D{Signal
Improving?} D -->|"YES ✅
WR > 55%"| E["BOOST
Weight ×1.05"] D -->|"NO ❌
WR < 45%"| F["REDUCE
Weight ÷1.05"] D -->|"MAYBE ⏸️
45-55%"| G["HOLD
Weight"] E -->|"Trending +5%?
Apply Accel"| H["⚡ ×1.5
Multiplier"] F -->|"Trending -5%?
Apply Penalty"| I["⛔ ×1.3
Penalty"] H -->|"Next Prediction"| J["🎲 Generate
New Scores"] I -->|"Next Prediction"| J G -->|"Next Prediction"| J J -->|"Compare vs
Market Outcome"| K["📈 Accuracy
Improved?"] K -->|"Loop back
in 2 minutes"| A style A fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style B fill:#fff0f5,stroke:#cc0066,stroke-width:2px style C fill:#fff8dc,stroke:#cccc00,stroke-width:2px style D fill:#ffe4e1,stroke:#ff0000,stroke-width:2px style E fill:#90ee90,stroke:#00cc00,stroke-width:2px style F fill:#ffcccc,stroke:#cc0000,stroke-width:2px style G fill:#fffacd,stroke:#cccc00,stroke-width:2px style H fill:#98fb98,stroke:#00aa00,stroke-width:2px style I fill:#ffa07a,stroke:#ff8800,stroke-width:2px style J fill:#dda0dd,stroke:#cc00cc,stroke-width:2px style K fill:#87ceeb,stroke:#0099ff,stroke-width:2px ```
## 🌍 市场体制检测
```
graph TD
A["📊 Calculate Volatility
Std Dev of Price Changes"] -->|"Measurement"| B{Volatility
Level?} B -->|"< 0.3%"| C["🟢 LOW
Stable Markets
Tight Gates"] B -->|"0.3-0.8%"| D["🟡 MODERATE
Normal Conditions
Standard Gates"] B -->|"0.8-1.5%"| E["🟠 HIGH
Choppy Markets
Loose Gates"] B -->|"> 1.5%"| F["🔴 EXTREME
Whipsaw Risk
Conservative"] C -->|"Applied"| G["📍 Adjust Gates
& Filters"] D -->|"Applied"| G E -->|"Applied"| G F -->|"Applied"| G G -->|"Regime-Aware"| H["🎲 Generate
Predictions"] style A fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style B fill:#fff0f5,stroke:#cc0066,stroke-width:2px style C fill:#90ee90,stroke:#00cc00,stroke-width:2px style D fill:#fffacd,stroke:#cccc00,stroke-width:2px style E fill:#ffa07a,stroke:#ff8800,stroke-width:2px style F fill:#ffcccc,stroke:#cc0000,stroke-width:2px style G fill:#dda0dd,stroke:#cc00cc,stroke-width:2px style H fill:#87ceeb,stroke:#0099ff,stroke-width:2px ```
## 🔮 Pyth Network:一方金融预言机
WE-CRYPTO 正在与 **[Pyth Network](https://pyth.network/)** 集成 — 一个去中心化的一方金融预言机,直接在链上提供机构级价格数据。与依赖第三方聚合器的传统预言机不同,Pyth 的数据直接来源于产生数据的市场参与者:交易公司、做市商和交易所。
### 为什么选择 Pyth?
传统金融市场数据被机构访问权限锁在墙后。Pyth Network 通过激励一方发布者 — 即在这些市场中交易的相同实体 — 共享其实时价格数据,实现了数据的民主化。这些数据在链上聚合,并提供给 DeFi 应用程序和像 WE-CRYPTO 这样的工具。
```
graph LR
subgraph publishers["📡 First-Party Publishers"]
MM["Market Makers"]
EX["Exchanges"]
TF["Trading Firms"]
end
subgraph pythnet["⛓️ Pythnet (Solana Appchain)"]
AGG["Price Aggregation
(Weighted Median)"] MB["Message Buffer
Program"] MKL["Merkle Tree
Root"] end subgraph broadcast["🌐 Cross-Chain Broadcast"] WH["Wormhole Network
(Decentralized Bridge)"] end subgraph targets["🎯 Target Chains"] ETH["Ethereum"] SOL["Solana"] OTHER["Other EVM Chains"] end MM -->|"price ± confidence"| AGG EX -->|"price ± confidence"| AGG TF -->|"price ± confidence"| AGG AGG --> MB MB --> MKL MKL --> WH WH --> ETH WH --> SOL WH --> OTHER style publishers fill:#1e90ff,color:#fff,stroke:#000,stroke-width:2px style pythnet fill:#228b22,color:#fff,stroke:#000,stroke-width:2px style broadcast fill:#ff8c00,color:#fff,stroke:#000,stroke-width:2px style targets fill:#9370db,color:#fff,stroke:#000,stroke-width:2px ```
## ⚡ 独特之处
### 🧠 它会学习
WE-CRYPTO 不是静态预测权重,而是从数千个已结算的预测合约中 **实时学习**:
- 分析每个信号 (RSI, MACD, CCI 等) 的准确率
- 自动提升高准确率信号(每周期 +5%)
- 自动降低低准确率信号(每周期 -5%)
- **每 2 分钟** 根据实时市场表现调整权重
### 📊 它很准确
初始准确率:**52-55%** vs 50% 随机猜测
1 周后:**54-58%** (自适应调整后)
目标:**60%+** (在稳定的市场体制中)
### 🔗 无处不在的集成
从以下来源获取历史结算数据:
- **Kalshi** — 预测市场
- **Polymarket** — 加密货币预测合约
- **Coinbase** — 预测市场数据
- **Pyth Network** — 一方金融预言机(实时价格数据源和置信区间)*(计划中)*
### ⚙️ 自动运行
- 30 秒轮询周期
- 实时准确率记分卡
- 自动权重调整(无需人工干预)
- 浏览器控制台中的完整调试面板
## 🎯 用例
✅ **短期交易** — 15 分钟方向预测
✅ **对冲信号** — 快速市场情绪分析
✅ **投资组合再平衡** — 微型市值币风险评估
✅ **研究** — 历史准确率趋势分析
## 🔥 主要功能
| 功能 | 详情 |
|---------|---------|
| **🎲 预测** | 15 分钟涨跌,附置信分数 (0-100) |
| **🧬 多信号** | 9 个指标:RSI, MACD, CCI, Fisher, ADX, ATR, 订单簿, Kalshi %, 人群反向 |
| **📚 历史数据** | 来自 Kalshi, Polymarket, Coinbase 的 300+ 已结算合约 |
| **⚡ 实时** | 30 秒轮询,60 秒决策窗口 |
| **🎓 自动学习** | 每 2 分钟调整权重,带趋势加速 |
| **🔐 安全** | Electron IPC 桥接,基于环境的 API 密钥 |
| **📈 仪表盘** | 实时准确率趋势,投资组合胜率,调整日志 |
| **🔧 调试** | 用于检查和手动权重调整的控制台命令 |
| **🌍 多交易所** | Kalshi, Polymarket, Coinbase, Binance, Kraken, CoinGecko, Pyth Network |
| **🔮 Pyth 预言机** | 通过 Pyth Network 拉取式预言机提供的一方价格数据源 + 置信区间 *(计划中)* |
| **💾 缓存** | 5 分钟价格缓存,24 小时准确率历史 |
## 🚀 快速开始
### 安装
```
# 克隆 & 安装
git clone https://github.com/JohnDaWalka/WE-CFM-Orchestrator.git
cd WE-CFM-Orchestrator
pnpm install
# 配置
cp .env.example .env
# 编辑 .env 并配置 API 凭证
# 无需云端预检即可本地运行
pnpm run start:dev
```
### 首次运行
1. 打开预测仪表盘 (http://localhost:3000)
2. 启动 30 秒轮询周期
3. 获取历史已结算合约(前 60 秒)
4. 约 120 秒后显示准确率记分卡
5. 开始自动权重调整
### 生产环境
```
# 构建发行便携式可执行文件(带预检检查)
pnpm run build:portable:release
# 结果:dist/WE-CRYPTO-Kalshi-15m-v2.15.5-portable--x64.exe
# 部署并运行 — 无需任何依赖!
```
## 💡 工作原理
### 学习循环
```
Step 1: Fetch settled contracts (Kalshi, Polymarket, Coinbase)
↓
Step 2: Calculate signal accuracy vs actual market outcome
↓
Step 3: Identify high-accuracy signals (52%+)
↓
Step 4: Identify low-accuracy signals (45%-)
↓
Step 5: Boost high performers, reduce underperformers
↓
Step 6: Next prediction uses new weights
↓
Step 7: Repeat every 2 minutes
```
### 实时示例
```
Time: 14:32:00
- Fetch last 5 hours of settled markets
- RSI accuracy: 58% (20 contracts) → BOOST by 5%
- MACD accuracy: 42% (20 contracts) → REDUCE by 5%
- CCI accuracy: 50% (20 contracts) → HOLD (neutral)
- Fisher: 56% but trending down → REDUCE by 8% (faster)
Weights updated in real-time:
RSI: 1.00 → 1.05 ✅
MACD: 1.00 → 0.95 ❌
CCI: 1.00 → 1.00 ⏸️
Fisher: 1.05 → 0.97 ❌
Time: 14:34:00 (new prediction)
Uses new weights automatically!
```
## 📊 真实性能
### 历史准确率(30 天平均)
| 投资组合 | 准确率 | 状态 |
|-----------|----------|--------|
| **基线** (随机) | 50.0% | 对照 |
| **v2.9.0** (固定权重) | 52.1% | 稳定 |
| **v2.10.0** (带调整) | 50.6% | 早期学习 |
| **v2.15.5** (实时 + 发布安全) | 52-55% | 📈 提升中 |
### 每种币明细(最近 7 天)
```
BTC: 57% ↑ (2.2% improvement from tuning)
ETH: 52% → (stable, good tuning)
SOL: 61% ↑↑ (strong momentum detection)
XRP: 48% ↓ (needs more data, tuning active)
DOGE: 55% → (stable crowd fade strategy)
BNB: 50% → (baseline, needs signal work)
```
## 🔧 控制台命令
### 检查当前状态
```
// View historical accuracy scorecard
window._historicalScorecard
// View current adaptive weights
window._adaptiveWeights
// Get learning diagnostics
window.AdaptiveLearner.getDiagnostics()
```
### 手动调整
```
// Force immediate tuning cycle
window.AdaptiveLearner.autoTuneWeights()
// Get per-signal accuracy report
window.AdaptiveLearner.getAllReports()
// Reset learning history (recovery)
window.AdaptiveLearner.reset()
```
## 📖 文档
按主题组织的完整文档:
- **[🏗️ 架构](./docs/ARCHITECTURE.md)** — 含 Mermaid 图的系统设计
- **[📚 信号指南](./docs/SIGNALS.md)** — 9 个指标中每个的工作原理
- **[🎓 学习引擎](./docs/LEARNING-ENGINE.md)** — 自适应调整深入探讨
- **[📋 索引](./docs/INDEX.md)** — 完整文档导航
**→ [查看完整文档](./docs/INDEX.md)**
## 🎓 v2.15.5 的当前内容
### 🔒 **发布卫生与时钟安全**
- TimeAPI 纽约响应使用时区感知解析进行转换,以对齐 15 分钟结算
- 本地启动/构建命令不再隐式运行云检查
- 发布/生产命令显式运行云、Firebase 和密钥扫描预检
- Electron 运行时和构建器打包固定到相同的 Electron 版本
### ✨ **自适应学习系统**
- 基于准确率的自动权重调整
- 历史结算获取器(Kalshi + Polymarket + Coinbase)
- 实时准确率记分卡
- 信号表现的趋势分析
### 🔧 **IPC 桥接修复**
- 修复了丢失的 Kalshi API 上下文桥接
- 恢复了 `window.KalshiAPI` 访问
- 所有三个 Electron 预加载脚本已更新
### 📊 **增强的仪表盘**
- 实时调整事件日志
- 每信号准确率跟踪
- 置信分数可视化
- 完整的调试面板
### ⚡ **性能**
- 30 秒轮询周期(之前为 15 分钟)
- <500ms 调整计算
- 缓存中 300+ 合约
- 错误的指数退避
## 🤝 贡献
我们欢迎贡献!可增强的领域:
- [ ] 额外的信号类型(成交量、链上数据等)
- [ ] 机器学习优化
- [ ] 多时间框架分析
- [ ] 跨链关联
- [ ] WebSocket 实时更新
- [ ] Pyth Network 价格数据源集成(实时拉取预言机调用)
参见 [CONTRIBUTING.md](./CONTRIBUTING.md) 了解指南。
## 🔐 安全性
✅ 凭据存储在环境变量中
✅ 源代码中无 API 密钥
✅ Electron IPC 安全加固
✅ 所有预测数据均为公开(Kalshi/Polymarket)
✅ API 调用仅使用 HTTPS
## 📜 许可证
MIT 许可证 — 请参阅 [LICENSE](./LICENSE) 文件
## 📞 支持与社区
- **💬 讨论** — [GitHub 讨论区](#)
- **🐛 问题** — [报告错误](#)
- **💡 请求** — [功能请求](#)
- **📧 邮箱** — support@example.com



**实时市场涨跌预测,具备自动自适应学习功能**
[📖 完整文档](./docs/INDEX.md) • [🏗️ 架构](./docs/ARCHITECTURE.md) • [🧬 信号指南](./docs/SIGNALS.md) • [🎓 学习引擎](./docs/LEARNING-ENGINE.md)
### 📱 最佳体验
**使用 GitHub 移动应用** 在 iPhone/Android 上完美呈现图表
→ [下载 iOS 应用](https://apps.apple.com/app/id1477376905) • [下载 Android 应用](https://play.google.com/store/apps/details?id=com.github.android)
## 🎯 系统概述:30 秒学习循环
```
graph LR
A["📊 Fetch HistoricalMarkets (Every 30s)
Kalshi, Polymarket
Coinbase"] -->|Settlement Data| B["🧮 Calculate
Signal Accuracy
9 Indicators
Per Coin"] B -->|Win Rate %| C["📈 Auto-Tune
Weights
Boost/Reduce
Signal Strength"] C -->|Apply New Weights| D["🎲 Generate
Live Predictions
15-Min Direction
Confidence Score"] D -->|Display| E["✅ User Sees
Real-Time Card
Portfolio WR
Accuracy Trending"] E -->|Feedback Loop| A style A fill:#1e90ff,color:#fff,stroke:#000,stroke-width:2px style B fill:#228b22,color:#fff,stroke:#000,stroke-width:2px style C fill:#ff8c00,color:#fff,stroke:#000,stroke-width:2px style D fill:#9370db,color:#fff,stroke:#000,stroke-width:2px style E fill:#20b2aa,color:#fff,stroke:#000,stroke-width:2px ```
📋 文本视图(便于复制)
``` 📊 Fetch (30s) → 🧮 Calc → 📈 Tune → 🎲 Predict → ✅ Display ↓ Every 30s: Loop back ← ```Live Predictions"] SS1 --> SS2 --> SS3 --> PRED WF1 --> WF2 --> WF3 --> PRED PRED --> ACC["📊 Accuracy
Scorecard
Portfolio WR"] ACC --> LEARN["🧠 Learning
Engine
Records Outcomes"] LEARN --> RT1 style rt fill:#ffcccc,stroke:#cc0000,stroke-width:2px style ss fill:#ffe6cc,stroke:#ff8800,stroke-width:2px style wf fill:#ffffcc,stroke:#cccc00,stroke-width:2px style PRED fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style ACC fill:#ccffcc,stroke:#00cc00,stroke-width:2px style LEARN fill:#ffccff,stroke:#cc00cc,stroke-width:2px ```
📋 文本视图(便于复制)
``` 🔴 Real-Time (30s) 🟠 Snapshot (1h) 🟡 Walk-Forward (daily) ↓ ↓ ↓ Poll Markets Aggregate 60m 14-day Window ↓ ↓ ↓ Rapid Check Regime Detect Baseline Opt ↓ ↓ ↓ Gate Adjust Weight Tune Seasonal Adj ↓ ↓ ↓ └─────────────────┬──────────────────┬─────────────┘ ↓ 🎲 Generate Predictions ↓ 📊 Accuracy Scorecard ↓ 🧠 Learning Engine ↓ ← Loop Back (30s) ```(Momentum)"] MACD["MACD
(Trend)"] CCI["CCI
(Cycles)"] FISHER["Fisher
(Reversal)"] ADX["ADX
(Strength)"] ATR["ATR
(Volatility)"] OB["Order Book
(Imbalance)"] KALSHI["Kalshi %
(Market Prob)"] CF["Crowd Fade
(Contrarian)"] end subgraph layer2["⚖️ Weighting Layer — Adaptive"] W1["RSI Weight
×1.2"] W2["MACD Weight
×0.9"] W3["CCI Weight
×1.0"] W4["Others..."] end subgraph layer3["🎯 Aggregation"] AGG["Weighted Sum
+ Regime Filter
+ Gate Check"] end subgraph output["🎲 Output"] SCORE["Confidence
0-100"] DIR["Direction
UP or DOWN"] end C1 --> RSI H --> MACD V --> CCI BP --> FISHER RSI --> W1 MACD --> W2 CCI --> W3 FISHER --> W4 ADX --> W4 ATR --> W4 OB --> W4 KALSHI --> W4 CF --> W4 W1 --> AGG W2 --> AGG W3 --> AGG W4 --> AGG AGG --> SCORE AGG --> DIR SCORE --> output DIR --> output style inputs fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style layer1 fill:#fff0f5,stroke:#cc0066,stroke-width:2px style layer2 fill:#fff8dc,stroke:#cccc00,stroke-width:2px style layer3 fill:#f0fff0,stroke:#00cc00,stroke-width:2px style output fill:#ffcccc,stroke:#cc0000,stroke-width:2px ```
📋 信号参考与权重
### 🔧 9 个技术指标 | 指标 | 用途 | 公式 | 当前权重 | |-----------|---------|---------|-----------------| | **RSI** | 动量 | 14 周期超买/超卖 | ×1.2 ✅ (强) | | **MACD** | 趋势跟踪 | 12/26 指数背离 | ×0.9 ⚠️ (弱) | | **CCI** | 周期检测 | 顺势指标 | ×1.0 ➜ (中性) | | **Fisher** | 反转信号 | 归一化价格转换 | ×1.1 ✅ (好) | | **ADX** | 趋势强度 | 平均趋向指数 | ×0.8 ⚠️ (弱) | | **ATR** | 波动率衡量 | 平均真实范围 | ×1.05 ✅ (可以) | | **订单簿** | 市场失衡 | 买卖压力比 | ×1.3 ✅ (强) | | **Kalshi %** | 市场概率 | 实时合约赔率 | ×1.15 ✅ (强) | | **人群反向** | 逆向操作 | 与人群倾向相反 | ×0.95 ➜ (中性) | ### ⚖️ 加权层(自适应) - **当前权重** 如上所示(每 2 分钟更新) - 根据近期准确率调整权重 - 范围:0.3x (最小提升) 至 2.0x (最大提升) - 趋势加速:如果改善则 ×1.5,如果恶化则 ×1.3 惩罚 ### 🎯 聚合与输出 **公式:** ``` Score = (RSI×1.2 + MACD×0.9 + CCI×1.0 + ... + Fade×0.95) / 9 × RegimeMultiplier × ConfidenceGate ``` **输出:** - **分数** (0-100) — 预测的置信度 - **方向** (UP/DOWN) — 市场方向预测 → **[查看详细信号文档](./docs/SIGNALS.md)**BrowserWindow"] IPC["Electron IPC
Secure Bridge"] end subgraph renderer["🎨 Renderer Process"] APP["app.js
UI Controller"] BRIDGE["kalshi-renderer-bridge.js
API Handler"] end subgraph engine["🔧 Prediction Engine"] PRED["predictions.js
Signal Calculation"] LEARNER["adaptive-learning-engine.js
Weight Tuning"] FETCHER["historical-settlement-fetcher.js
Market Data"] end subgraph apis["🌐 External APIs"] KALSHI["Kalshi API
Settled Contracts"] POLY["Polymarket API
Resolved Markets"] COIN["Coinbase API
Predictions"] BINANCE["Binance/Kraken
OHLCV Candles"] PYTH["Pyth Network
Price Feeds & CI"] end MAIN --> IPC IPC --> APP APP --> BRIDGE BRIDGE --> PRED PRED --> LEARNER LEARNER --> FETCHER FETCHER --> KALSHI FETCHER --> POLY FETCHER --> COIN FETCHER --> BINANCE FETCHER --> PYTH style electron fill:#1e90ff,color:#fff,stroke:#000,stroke-width:2px style renderer fill:#228b22,color:#fff,stroke:#000,stroke-width:2px style engine fill:#ff8c00,color:#fff,stroke:#000,stroke-width:2px style apis fill:#4169e1,color:#fff,stroke:#000,stroke-width:2px ```
📋 组件分解
**⚛️ Electron 主进程** - `main.js` — 创建 BrowserWindow 并管理应用生命周期 - Electron IPC — 安全的进程间通信桥梁 **🎨 渲染器进程 (UI)** - `app.js` — 主 UI 控制器,所有视图和逻辑 - `kalshi-renderer-bridge.js` — IPC 处理器,桥接到后端 API - `window.KalshiAPI` — 暴露的 API,用于安全的渲染器访问 **🔧 预测引擎 (核心逻辑)** - `predictions.js` — 计算所有 9 个信号,生成分数 - `adaptive-learning-engine.js` — 每 2 分钟调整权重 - `historical-settlement-fetcher.js` — 从 3 个交易所获取已结算合约 **🌐 外部 API** - Kalshi API — 预测市场合约 - Polymarket API — 已解决的市场数据 - Coinbase API — 预测结果 - Binance/Kraken — 用于技术分析的 OHLCV K线数据 - Pyth Network — 带有置信区间的一方价格数据源 **流程:** 主进程 → IPC → 渲染器 → 预测引擎 → 外部 API → 返回 UI 显示 → **[查看详细架构](./docs/ARCHITECTURE.md)**📋 时间线视图(便于复制)
``` Time: 0s – 5s | FETCHER PHASE 1️⃣ Fetch Kalshi settled contracts 2️⃣ Fetch Polymarket resolved markets 3️⃣ Calculate per-coin accuracy Time: 5s – 15s | LEARNER PHASE 4️⃣ Record signal contributions 5️⃣ Calculate per-indicator win rate 6️⃣ Detect outperformers/underperformers Time: 15s – 25s | TUNING DECISION (Every 2 minutes) 7️⃣ AUTO-TUNE WEIGHTS • Boost high-accuracy signals (+5%) • Reduce low-accuracy signals (-5%) • Apply trending acceleration (×1.5 or ×1.3) Time: 25s – 30s | ENGINE & DISPLAY 8️⃣ Generate live predictions • Calculate all 9 signals • Apply gate filters • Score confidence (0-100) 9️⃣ Display to user • Show prediction (UP/DOWN) • Update accuracy scorecard • Show tuning badge ``` 每个周期 (30 秒):更好的数据 → 更好的调整 → 更好的预测Markets (30s)"] -->|"Settlement Data
Kalshi, Polymarket"| B["🧮 Calculate
Accuracy"] B -->|"Per-coin
Per-signal WR"| C["📊 Track
Trending"] C -->|"Need 5+
samples?"| D{Signal
Improving?} D -->|"YES ✅
WR > 55%"| E["BOOST
Weight ×1.05"] D -->|"NO ❌
WR < 45%"| F["REDUCE
Weight ÷1.05"] D -->|"MAYBE ⏸️
45-55%"| G["HOLD
Weight"] E -->|"Trending +5%?
Apply Accel"| H["⚡ ×1.5
Multiplier"] F -->|"Trending -5%?
Apply Penalty"| I["⛔ ×1.3
Penalty"] H -->|"Next Prediction"| J["🎲 Generate
New Scores"] I -->|"Next Prediction"| J G -->|"Next Prediction"| J J -->|"Compare vs
Market Outcome"| K["📈 Accuracy
Improved?"] K -->|"Loop back
in 2 minutes"| A style A fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style B fill:#fff0f5,stroke:#cc0066,stroke-width:2px style C fill:#fff8dc,stroke:#cccc00,stroke-width:2px style D fill:#ffe4e1,stroke:#ff0000,stroke-width:2px style E fill:#90ee90,stroke:#00cc00,stroke-width:2px style F fill:#ffcccc,stroke:#cc0000,stroke-width:2px style G fill:#fffacd,stroke:#cccc00,stroke-width:2px style H fill:#98fb98,stroke:#00aa00,stroke-width:2px style I fill:#ffa07a,stroke:#ff8800,stroke-width:2px style J fill:#dda0dd,stroke:#cc00cc,stroke-width:2px style K fill:#87ceeb,stroke:#0099ff,stroke-width:2px ```
📋 详细学习过程(逐步)
### 7 步自学习周期 **步骤 1:获取历史市场数据 (每 30 秒)** ``` ├─ Kalshi API: /markets?status=settled ├─ Polymarket API: resolved contracts └─ Coinbase API: prediction outcomes ``` **步骤 2:计算每种币的准确率** ``` ├─ Compare model prediction to market outcome ├─ Track: RSI, MACD, CCI... (9 indicators) └─ Maintain rolling history (last 20 samples) ``` **步骤 3:每 2 分钟 — 检查信号表现** ``` ├─ RSI: 58% WR → OUTPERFORMER ✅ ├─ MACD: 42% WR → UNDERPERFORMER ❌ ├─ CCI: 50% WR → NEUTRAL ⏸️ └─ Fisher: 56% WR, trending DOWN → PENALIZE ❌ ``` **步骤 4:应用调整规则** ``` ├─ IF WR > 55%: BOOST by 5% │ └─ IF trend improving +5%: Apply ×1.5 acceleration ├─ IF WR < 45%: REDUCE by 5% │ └─ IF trend degrading -5%: Apply ×1.3 penalty └─ IF 45-55%: HOLD current weight ``` **步骤 5:更新权重 (上限:最小 0.3x,最大 2.0x)** ``` ├─ window._adaptiveWeights updated ├─ Tuning event logged └─ Next prediction uses new weights IMMEDIATELY ``` **步骤 6:生成新预测 (30 秒周期)** ``` ├─ All 9 signals calculated ├─ New weights applied └─ Score updated ``` **步骤 7:与市场结果对比** ``` ├─ Prediction vs actual market result ├─ Accuracy recorded └─ LOOP BACK to STEP 1 (every 30s) ``` ### 示例:实时调整事件 ``` Time: 14:32:00 - Fetch last 5 hours of settled markets - RSI accuracy: 58% (20 contracts) → BOOST by 5% - MACD accuracy: 42% (20 contracts) → REDUCE by 5% - CCI accuracy: 50% (20 contracts) → HOLD (neutral) - Fisher: 56% but trending down → REDUCE by 8% (faster) Weights updated in real-time: RSI: 1.00 → 1.05 ✅ MACD: 1.00 → 0.95 ❌ CCI: 1.00 → 1.00 ⏸️ Fisher: 1.05 → 0.97 ❌ Time: 14:34:00 (new prediction) Uses new weights automatically! ``` → **[查看详细架构图](./docs/diagrams.md)**Std Dev of Price Changes"] -->|"Measurement"| B{Volatility
Level?} B -->|"< 0.3%"| C["🟢 LOW
Stable Markets
Tight Gates"] B -->|"0.3-0.8%"| D["🟡 MODERATE
Normal Conditions
Standard Gates"] B -->|"0.8-1.5%"| E["🟠 HIGH
Choppy Markets
Loose Gates"] B -->|"> 1.5%"| F["🔴 EXTREME
Whipsaw Risk
Conservative"] C -->|"Applied"| G["📍 Adjust Gates
& Filters"] D -->|"Applied"| G E -->|"Applied"| G F -->|"Applied"| G G -->|"Regime-Aware"| H["🎲 Generate
Predictions"] style A fill:#e6f3ff,stroke:#0066cc,stroke-width:2px style B fill:#fff0f5,stroke:#cc0066,stroke-width:2px style C fill:#90ee90,stroke:#00cc00,stroke-width:2px style D fill:#fffacd,stroke:#cccc00,stroke-width:2px style E fill:#ffa07a,stroke:#ff8800,stroke-width:2px style F fill:#ffcccc,stroke:#cc0000,stroke-width:2px style G fill:#dda0dd,stroke:#cc00cc,stroke-width:2px style H fill:#87ceeb,stroke:#0099ff,stroke-width:2px ```
📋 体制分类与响应
### 市场体制如何影响预测 **🟢 低波动率 (< 0.3%)** - 市场稳定且可预测 - 使用严格的置信度阈值 (90%+) - 完全信任信号准确率 - 预期高准确率 **🟡 中等波动率 (0.3-0.8%)** - 正常市场状况 - 使用标准置信度阈值 (75%) - 平衡信号加权 - 良好的准确率基线 **🟠 高波动率 (0.8-1.5%)** - 市场震荡,有虚假信号 - 使用宽松的置信度阈值 (60%) - 将信号权重降低 20% - 预期准确率较低 **🔴 极端波动率 (> 1.5%)** - 锯齿风险,强烈反转 - 使用非常宽松的阈值 (50%) - 仅进行保守预测 - 准确率可能降至 48-50% ### 实时调整 每种体制自动调整: 1. **置信度阈值** — 分数需要多高才能预测? 2. **信号权重** — 多大程度信任每个指标 3. **阈值过滤器** — 什么结果可接受用于显示 4. **预测频率** — 何时持有并等待 → **[查看详细体制分析](./docs/LEARNING-ENGINE.md)**(Weighted Median)"] MB["Message Buffer
Program"] MKL["Merkle Tree
Root"] end subgraph broadcast["🌐 Cross-Chain Broadcast"] WH["Wormhole Network
(Decentralized Bridge)"] end subgraph targets["🎯 Target Chains"] ETH["Ethereum"] SOL["Solana"] OTHER["Other EVM Chains"] end MM -->|"price ± confidence"| AGG EX -->|"price ± confidence"| AGG TF -->|"price ± confidence"| AGG AGG --> MB MB --> MKL MKL --> WH WH --> ETH WH --> SOL WH --> OTHER style publishers fill:#1e90ff,color:#fff,stroke:#000,stroke-width:2px style pythnet fill:#228b22,color:#fff,stroke:#000,stroke-width:2px style broadcast fill:#ff8c00,color:#fff,stroke:#000,stroke-width:2px style targets fill:#9370db,color:#fff,stroke:#000,stroke-width:2px ```
📋 Pyth 如何工作(架构细节)
### 🏗️ 跨链架构(拉取式预言机) Pyth 使用三部分 **拉取式预言机** 工作流,保持低成本和最小延迟: **1. 在 Pythnet 上发布** - 获得许可的发布者在 Pythnet(一个 Solana 分叉)上免费提交 `价格 ± 置信度` 更新 - 链上预言机程序在每个 slot(约 400ms)聚合价格 **2. 通过 Wormhole 广播** - Pythnet 验证者在每个 slot 后构建聚合价格的 Merkle 树 - Merkle 根通过 Wormhole 去中心化桥广播到所有目标链 - 完整的价格数据在 Pythnet 上公开可访问,有一个滚动的历史窗口 **3. 在目标链上拉取(按需)** - 每个目标链都有一个 Pyth 接收器合约,存储每个数据源的最新价格 - 任何人都可以通过提供:经认证的 Merkle 根 + 价格叶 + Merkle 路径,无权限地更新链上价格 - **消费者仅在实际需要价格时支付 gas** — 不是持续支付 这种拉取模型意味着 Pyth 可以在许多资产和链上支持高频更新(每 400ms),而无需持续消耗 gas。 ### 🧮 价格聚合算法 Pyth 的聚合旨在具有 **抗操纵性** 和 **准确度加权**: 每个发布者提交 `价格 ± 置信度`。聚合算法: 1. **给每个发布者 3 票:** 一票在 `价格`,一票在 `价格 + 置信度`,一票在 `价格 - 置信度` 2. **对所有票进行质押加权取中位数** → **聚合价格** 3. **计算** 聚合价格到质押加权的第 25 和第 75 百分位数的距离 → **聚合置信区间**(取较大距离) 此方法最小化目标函数: ``` Score(R) = (1/3) × Σᵢ sᵢ|R − pᵢ| + (2/3) × Σᵢ sᵢ max(|R − pᵢ| − cᵢ, 0) ``` 其中 `sᵢ` 是质押权重,`pᵢ` 是价格,`cᵢ` 是发布者 `i` 的置信度。 **关键特性:** - 单个离群发布者无法显著移动聚合价格 - 置信区间更窄(流动性更强的场所)的发布者影响力更大 - 聚合置信度反映了各场所间的真实价格分散 ### 📊 WE-CRYPTO 如何使用 Pyth | Pyth 特性 | WE-CRYPTO 用途 | |---|---| | **价格数据源** | 用于信号计算的实时资产价格 | | **置信区间** | 用于市场体制检测的波动率代理 | | **高频 (400ms)** | 实现精确的 EMA 和动量计算 | | **跨链数据** | 所有支持资产间的一致价格 | | **一方数据源** | 比第三方预言机数据源更高的数据质量 | → **[了解更多关于 Pyth Network](https://docs.pyth.network/)**
**为加密货币交易者用 ❤️ 构建**
*每分钟都在变得更智能的预测*
[📖 阅读完整文档](./docs/INDEX.md) • [🐛 报告问题](#) • [⭐ 给本仓库点星](#)
标签:15分钟预测, Apex, Coinbase, Kalshi, MITM代理, Polymarket, UP/DOWN合约, 信号准确率, 信号处理, 加密货币, 合约交易, 实时预测, 市场预测, 数据可视化, 数据获取, 机器学习, 置信度评分, 自动学习系统, 自动调参, 自定义脚本, 自适应学习, 软件开发工具, 金融技术, 预测引擎, 预测显示