npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yangguang1988/forex-suite

v1.0.2

Published

MT5 外汇量化交易面板 — 完整项目(mt5_client 已整合进 mt5_panel)

Downloads

43

Readme

翡冷翠 MT5 量化交易面板 · @yangguang1988/forex-suite

一套连接本地 MetaTrader 5 终端的外汇 / 贵金属量化交易面板:实时行情仪表盘、技术分析图表、财经资讯、自动交易引擎(543 策略宇宙)、量化研究回测套件,以及「全界面只读」的手机 APP(PWA + 安卓 APK)。


一、功能总览(新版)

当前发布版本为 单版本 business(商务版),强调色 #39d0d8,内置 7 个界面 + 手机端第 8 页(开户):

| 界面 | 路径 | 说明 | |------|------|------| | 仪表盘 | / | 实时账户、持仓、自选报价、信号概览 | | 技术分析 | /analysis | K 线 + RSI / MACD / 布林带 SVG 图表,多周期切换 | | 财经资讯 | /news | 财经快讯流 + 分类筛选条 + 占比可视化 | | 自动交易 | /strategy | TOP 6 精品策略一键启停、实盘守护、信号面板 | | 研究 | /research | 量化回测套件(单策 / 网格寻优 / 并排 / Walk-forward / 矩阵) | | 说明 | /guide | 使用文档与策略原理 | | 设置 | /settings | 终端、账户、风控、主题配置 | | 开户(手机端) | APP 底部「开户」 | EXNESS 专属推广开户入口(外部链接,非交易控制) |

所有写操作(下单 / 回测 / 启停)仅 business / strategy 版本放行;system / research 仅做只读研究。


二、整体架构

本地 Windows 主机
┌─────────────────────────────────────────────┐
│  MT5 终端 (MetaTrader 5)  ← 已登录账户       │
│        │  MetaTrader5 Python 包 (mt5)         │
│  server.py  (ThreadingHTTPServer, 零依赖)     │  ← 端口 9999 (profiles.json)
│        │  REST API + 策略引擎 + 信号内核        │
│  bridge_relay.py  (每 2s 拉只读接口→推送)       │
└────────┬──────────────────────────────────────┘
         │  POST /api/ingest (归一化快照)
         ▼
   云端 bj5 后端 (白名单 9 字段 + 重归一化)
         │  GET /api/state
         ▼
   手机 APP = PWA (app_full/)  ── WebView 壳 ──► 安卓 APK
         (全界面只读,无 POST / 下单 / 回测)
  • 单代码库 + Profile 驱动profiles.json 定义版本 port、页面白名单、apis 前缀白名单、nav、品牌。当前仅 business 一个版本(端口 9999),呼出面板必须用 profiles 里的端口。
  • 服务端server.py 用标准库 ThreadingHTTPServer零第三方依赖do_GETinject_nav 注入导航 / 品牌,do_POSTapi_allowed() 前缀白名单鉴权。
  • MT5 接入MetaTrader5(mt5) 包仅装在系统 Python 3.11;核心逻辑用 import server 直接调函数验证,绕开端口 / 沙箱网络问题。

三、策略宇宙与信号内核

策略宇宙(543 条)

  • premium1–premium23:精品策略(黄金 / 外汇,magic 7100+
  • _GOLD_500_DEFS:500 条黄金批量策略(magic 9000+
  • _TOP5_DEFS:进化 TOP5 策略(magic 9500+

面板仅展示 TOP 6TOP_STRATEGY_IDS,数据过滤,不影响引擎启停):

  • 黄金:premium4 / premium6 / premium8
  • 外汇:premium17 / premium18 / premium19

三套信号内核(算法路由)

eval_strategy(sid, ...)STRATEGY_DEFS_BY_ID[sid]["algo"] 分流:

  • fusion(综判) — EMA + RSI + 布林带 + ADX + 多因子共振 + 冲突检测
  • pulse(动能突破) — Donchian 通道突破 + ADX 趋势强度 + ATR 波动扩张 + 大周期过滤
  • scalp(高频回归) — 微通道突破 + RSI 动量 + 布林带宽窄区间过滤 + 极短线持有

实盘启动守卫

StrategyEngine.start(sid)blocked 字典拦截未验证 / 信号未接入的策略(如占位 gold7/8/9fx_*),返回 {"ok":False,"error":...},前端提示「N 套暂未开放实盘」。接入新策略 = 补 eval_strategy 信号分支 + 从 blocked 移除 id。


四、量化研究回测套件(研究版)

API:/api/backtest(单策略)、/optimize(网格寻优 Top12)、/compare(多策略并排)、/walkforward(分段防过拟合)、/matrix(十策矩阵,默认点差 240)。

  • 内核纯函数_bt_core() 逐根盯市回测;_opt_core() 网格遍历;run_walkforward() 锚定分段;run_matrix() 对 10 套策略按夏普降序。
  • 策略库STRATEGY_LIB / ALL_STRATEGY_IDS 共 10 套(boll_breakout / ma_channel / atr_channel / cci / stoch / keltner / donchian / price_breakout / ma_rsi / momentum)。
  • 数据诚实性:回测一律用 pip 换算点差(黄金 240 点差 = 2.4 价格单位 / 笔),权益曲线逐根盯市,点差真实拖累 headline 收益。
  • 执行模型:第 i-1 根信号于第 i 根开盘执行(无未来函数)。
  • 指标:总收益 / 最大回撤 / 夏普 / 胜率 / 交易数 / 盈亏比 / 期末权益。

五、手机端:全界面只读 APP

手机端是 PWA(mt5_panel/app_full/)经 WebView 壳加载,本质是「全界面只读预览」——仅 GET /api/state,所有交易 / 回测按钮为禁用态 + toast 提示。

  • 8 个页面:仪表盘 / 分析 / 资讯 / 交易 / 研究 / 说明 / 设置 / 开户(EXNESS 专属链接 https://one.exnessonelink.com/a/shlouoac,命中即跳系统浏览器)。
  • 图表可视化:分析页用原生 SVG 绘制价格 / RSI / MACD;资讯页含分类筛选 + 占比可视化。
  • 安卓 APKD:/mt5android/MainActivity.java WebView 加载云端 PWA URL,包名 com.feicuicui.mt5,桌面名「翡冷翠 MT5」)。

云端实时链路

server.py(9999) → bridge_relay.py(每 2s 拉多接口 → POST 云端 /api/ingest) → 云端 bj5 存储 → PWA fetch /api/state → 手机 WebView 渲染。

  • 云端 PWA(浏览器「添加到主屏幕」即 App):https://03183293fa764410873e82f9adb6191a.app.workbuddy.link/
  • APK 下载页(点按钮下最新 APK):https://bd31c75377f349abab7c6af2c9c8901e.app.workbuddy.link/

注:MT5 无头未交互登录时,实时 tick 报价品种可能为 0,但技术分析 / 图表基于历史计算正常;本机桌面登录 EXNESS 账户后即恢复跳动行情。


六、API 参考

只读(GET)

/api/config · /api/news · /api/datasources · /api/datasources_config · /api/quotes · /api/signals · /api/analysis · /api/analysis_detail · /api/stream · /api/analysis_chart?symbol=XAUUSD&tf=H1&bars=120 · /api/strategies · /api/strategies/db · /api/indicators · /api/indicators/compute · /api/signal/v2/regime · /api/signal/v2/score · /api/signal/v2/eval · /api/backtests · /api/trades · /api/db/stats · /api/backtest/strategies · /api/iteration · /api/iteration/top5 · /api/autotrade · /api/logs · /api/health

控制(POST,仅 business / strategy 放行)

/api/strategies/start · /stop · /start_all · /stop_all · /toggle · /start_enabled · /liquidate · /db/save · /trades/log · /datasources_config · /backtest/matrix · /backtest/matrix_batch · /backtest/matrix_batch/status · /backtest/matrix_batch/stop · /iteration/start · /stop · /run · /manage · /liquidate · /config · /evolve · /evolve/next · /evolve/stop · /evolve/status · /autotrade


七、安装与运行

1)本地面板(需本机已装 MT5 终端 + Python 3.11 + mt5 包)

cd mt5_panel
python server.py            # 默认 VERSION=business,端口 9999
# 或指定版本: VERSION=business python server.py

浏览器打开 http://127.0.0.1:9999/

2)守护 / 常驻(宿主进程)

用系统 Python 3.11 + PowerShell Start-Process 拉起(脱离 agent 会话真常驻):

$env:VERSION="business"
Start-Process python server.py

实时数据链路:server.py(9999) + MT5 终端 + bridge_relay.py(每 2s 推送云端)。

3)npm 包

npm install @yangguang1988/forex-suite
# 启动(等价于 python server.py)
npm run panel
# 构建前端 bundle
npm run build

包当前发布为 @yangguang1988/forex-suite(yangguang1988 用户名下的 scope,必定可发)。早期曾以非 scope 名 mt5-quant-forex-suite 发过 1.0.0/1.0.1(arong8888 账号);@mt5-quant/forex-suite scope 因未注册被 npm 拒。下次发版请先 npm version patchnpm publish


八、项目结构

翡冷翠/
├── package.json                 # 根包(@yangguang1988/forex-suite,已发布)
├── .npmignore                   # 排除 MT5 安装 / .workbuddy / log / db
├── mt5_panel/
│   ├── server.py                # 零依赖 Python 服务端 + 策略引擎 + 信号内核
│   ├── profiles.json            # 单版本 business 配置(port/页面/apis/nav)
│   ├── bridge_relay.py          # 本地→云端 实时数据桥接(每 2s)
│   ├── app_full/                # 全界面只读 PWA(8 页,手机 APP 内核)
│   │   ├── index.html  app.js  manifest.webmanifest  sw.js  icon.svg
│   ├── gold_500_batch.py        # 500 条黄金批量策略
│   ├── top5_ALL_STRATEGY_DEFS.py# TOP5 进化策略
│   ├── backtest_*.py            # 各类回测脚本
│   ├── strategy_evolution.py    # 策略进化
│   ├── *_STRATEGY_DEFS.py       # 各品种策略定义
│   └── README.md
├── D:/mt5android/               # 安卓原生 APK 工程(WebView 壳)
│   ├── app/src/main/java/com/feicuicui/mt5/
│   ├── build_apk.sh  gen_dl.py  dist/index.html(内嵌 APK 下载页)
└── docs/                        # 策略设计 / 回测报告文档

九、依赖

  • Python ≥ 3.11(系统 Python,装 MetaTrader5 包)
  • MetaTrader 5 桌面终端(已登录交易账户)
  • Node ≥ 16(仅用于前端 bundle 构建与 CLI)

十、License

MIT