Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/binance-strategy27-events.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Binance Strategy 27 Events

on:
pull_request:
paths:
- ".github/workflows/binance-strategy27-events.yml"
- "package.json"
- "package-lock.json"
- "scripts/build-userscript.mjs"
- "scripts/userscript-release-contract.mjs"
- "src/binance-strategy27-events/**"
- "src/shared/binance-futures-route.js"
- "src/shared/spa-route-change.js"
- "scripts/binance-strategy27-events.user.js"
- "test/unit/binance-strategy27-events/**"
- "test/dom/binance-strategy27-events/**"
- "test/unit/userscript-metadata-icons.test.js"
- "test/unit/userscript-release-contract.test.js"
push:
branches:
- main
paths:
- ".github/workflows/binance-strategy27-events.yml"
- "package.json"
- "package-lock.json"
- "scripts/build-userscript.mjs"
- "scripts/userscript-release-contract.mjs"
- "src/binance-strategy27-events/**"
- "src/shared/binance-futures-route.js"
- "src/shared/spa-route-change.js"
- "scripts/binance-strategy27-events.user.js"
- "test/unit/binance-strategy27-events/**"
- "test/dom/binance-strategy27-events/**"
- "test/unit/userscript-metadata-icons.test.js"
- "test/unit/userscript-release-contract.test.js"

permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run test:binance-strategy27-events
- run: npm run build:binance-strategy27-events
- run: git diff --exit-code -- scripts/binance-strategy27-events.user.js
- run: npm run check:binance-userscripts
- run: node scripts/userscript-release-contract.mjs scripts/binance-strategy27-events.user.js

6 changes: 5 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
- `src/binance-orderbook-trade/` 是 `scripts/binance-orderbook-trade.user.js` 的开发真源。
- `src/binance-trading-data/` 是 `scripts/binance-trading-data.user.js` 的开发真源。
- `src/binance-coinmarketcap-data/` 是 `scripts/binance-coinmarketcap-data.user.js` 的开发真源。
- `src/binance-strategy27-events/` 是 `scripts/binance-strategy27-events.user.js` 的开发真源。
- `src/m3u8-downloader/` 是 `scripts/m3u8-downloader.user.js` 的开发真源。
- `scripts/binance-orderbook-trade.user.js`、`scripts/binance-trading-data.user.js`、`scripts/binance-coinmarketcap-data.user.js`、`scripts/m3u8-downloader.user.js` 是生成后的单文件安装/更新入口,必须保持可读、非压缩、非混淆。
- `scripts/binance-orderbook-trade.user.js`、`scripts/binance-trading-data.user.js`、`scripts/binance-coinmarketcap-data.user.js`、`scripts/binance-strategy27-events.user.js`、`scripts/m3u8-downloader.user.js` 是生成后的单文件安装/更新入口,必须保持可读、非压缩、非混淆。
- 其它 userscript 在迁移前仍以 `scripts/*.user.js` 为真源。
- `README.md` 只维护安装入口、真源说明和发布约束,不承载开发细节。
- 非真源仓库不复制脚本源码,只放安装链接。
Expand All @@ -20,6 +21,8 @@
Binance 合约交易数据面板,核心风险在 5 分钟调度、缓存回退、前后台切换。
- `scripts/binance-coinmarketcap-data.user.js`
Binance CoinMarketCap 数据面板,核心风险在 symbol 解析、CMC 资产映射、跨页误注入。
- `scripts/binance-strategy27-events.user.js`
Binance Strategy 27 图表标注,核心风险在网关 cursor / epoch、symbol / 秒坐标、生命周期和脚本实体归属。
- `scripts/m3u8-downloader.user.js`
m3u8 下载增强脚本,核心风险在通用 m3u8 拦截、Brooks 媒体索引、失败重试、暂停/继续状态、active runtime 计时和 Bunny caption URL 推导。
- `scripts/auto_refresh.user.js`
Expand All @@ -37,6 +40,7 @@

- 修改 `src/binance-orderbook-trade/**` 后必须运行 `npm run build:binance-orderbook-trade` 生成 `scripts/binance-orderbook-trade.user.js`。
- 修改 `src/binance-trading-data/**`、`src/binance-coinmarketcap-data/**` 或 `src/shared/**` 后必须运行 `npm run build:binance-userscripts` 或对应单脚本 build 命令生成 `scripts/*.user.js`。
- 修改 `src/binance-strategy27-events/**` 后必须运行 `npm run build:binance-strategy27-events` 生成 `scripts/binance-strategy27-events.user.js`。
- 修改 `src/m3u8-downloader/**` 后必须运行 `npm run build:m3u8-downloader` 生成 `scripts/m3u8-downloader.user.js`。
- 修改已迁移的 `src/binance-*`、`src/m3u8-downloader/**` 或 `src/shared/**` 且改变行为时,必须同步 bump 对应生成 userscript 头部 `@version`。
- 修改尚未迁移的 `scripts/` 下任意 userscript,必须同步 bump 该文件头部 `@version`。
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This repository is the source of truth and distribution point for the scripts. G
| Binance orderbook one-click order entry | Binance Futures | Click an orderbook price, infer the current open/close tab, fill quantity, and submit an order with a multiplier panel | This repository | [Install][install-binance-orderbook-trade] |
| Binance Futures data panel | Binance Futures | Overlay open interest, long/short ratios, funding rate, basis, and directional signals | This repository | [Install][install-binance-trading-data] |
| Binance CoinMarketCap data panel | Binance Futures | Show CoinMarketCap valuation, supply, and liquidity data for the current symbol | This repository | [Install][install-binance-coinmarketcap-data] |
| Binance Strategy 27 event annotations | Binance Futures | Draw VPS-computed Strategy 27 event markers and outcome notes on the matching one-second chart | This repository | [Install][install-binance-strategy27-events] |
| Auto refresh | Any page | Refresh selected pages on a configurable schedule | This repository | [Install][install-auto-refresh] |
| CoinMarketCap valuation labels | CoinMarketCap | Label and highlight circulating market cap and FDV / total valuation in the Chinese UI | This repository | [Install][install-coinmarketcap-valuation-helper] |
| m3u8 downloader | Video pages | Enhanced m3u8 detection and export workflow for allowlisted video sites | This repository | [Install][install-m3u8] |
Expand All @@ -59,6 +60,12 @@ This repository is the source of truth and distribution point for the scripts. G
- Displays values and simple directional signals inside the trading page.
- Reduces context switching between Binance and external data pages.

### Binance Strategy 27 event annotations

- Reads only the authenticated loopback gateway through an SSH local forward.
- Adds no Binance market-data WebSocket or Binance API key to Chrome.
- Draws bounded, transient event markers and objective four-force notes on the matching one-second chart.

### m3u8 downloader

- Detects and exports m3u8 media sources for allowlisted sites.
Expand Down Expand Up @@ -87,7 +94,7 @@ npm run build:binance-userscripts
## Maintenance Rules

1. Each script has exactly one source of truth.
2. `src/binance-orderbook-trade/`, `src/binance-trading-data/`, `src/binance-coinmarketcap-data/`, and `src/m3u8-downloader/` are source directories for the corresponding generated scripts.
2. `src/binance-orderbook-trade/`, `src/binance-trading-data/`, `src/binance-coinmarketcap-data/`, `src/binance-strategy27-events/`, and `src/m3u8-downloader/` are source directories for the corresponding generated scripts.
3. Public install entry points remain generated files under `scripts/*.user.js`.
4. Do not copy script source into secondary repositories.
5. Bump `@version` when behavior changes.
Expand All @@ -96,6 +103,7 @@ npm run build:binance-userscripts
## Documentation

- [Binance orderbook trade development](docs/binance-orderbook-trade-development.md)
- [Binance Strategy 27 event annotations](docs/binance-strategy27-events-development.md)
- [Brooks media sync workflow](docs/brooks-media-sync-workflow.md)

## License
Expand All @@ -105,6 +113,7 @@ MIT. See [LICENSE](LICENSE).
[install-binance-orderbook-trade]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-orderbook-trade.user.js
[install-binance-trading-data]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-trading-data.user.js
[install-binance-coinmarketcap-data]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-coinmarketcap-data.user.js
[install-binance-strategy27-events]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-strategy27-events.user.js
[install-auto-refresh]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/auto_refresh.user.js
[install-coinmarketcap-valuation-helper]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/coinmarketcap-valuation-helper.user.js
[install-m3u8]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/m3u8-downloader.user.js
11 changes: 10 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
| 【自写】Binance 订单簿单击下单 | Binance Futures | 单击订单簿价格,按当前开仓/平仓 tab 自动填数量并执行下单,内置数量倍率面板 | 本仓库 | [`点击安装`][install-binance-orderbook-trade] |
| 【自写】Binance 合约交易数据面板 | Binance Futures | 在合约交易页面叠加浮动面板,定时拉取交易数据(持仓量、多空比、资金费率等)并显示当前值 + 多空信号 | 本仓库 | [`点击安装`][install-binance-trading-data] |
| 【自写】Binance CoinMarketCap 数据面板 | Binance Futures | 在 Binance 合约页面显示当前币种的 CoinMarketCap 估值、供应量和流动性数据 | 本仓库 | [`点击安装`][install-binance-coinmarketcap-data] |
| 【自写】Binance Strategy 27 事件标注 | Binance Futures | 在匹配币种的一秒图表标注 VPS 已计算的 Strategy 27 事件和后续结果 | 本仓库 | [`点击安装`][install-binance-strategy27-events] |
| 【自写】定时刷新指定页面 | Any page | 指定页面按设定时间自动刷新 | 本仓库 | [`点击安装`][install-auto-refresh] |
| 【自写】CoinMarketCap 估值口径命名 | CoinMarketCap | 在中文币种页面左上角统计区标注并高亮流通市值和 FDV / 总估值 | 本仓库 | [`点击安装`][install-coinmarketcap-valuation-helper] |
| 【改写】m3u8-downloader | Video pages | m3u8 下载增强脚本,仅在白名单视频站启用 | 本仓库 | [`点击安装`][install-m3u8] |
Expand All @@ -57,6 +58,12 @@
- 使用浮动面板展示当前值和多空信号。
- 适合在交易页面内快速判断市场结构,不需要频繁切换数据网站。

### Binance Strategy 27 事件标注

- 只通过 SSH 本地转发读取带认证的本机网关。
- 不在 Chrome 中新增 Binance 行情 WebSocket,也不使用 Binance API Key。
- 在匹配币种的一秒图表上绘制数量和保留时间均受限的事件标记及四力客观备注。

### m3u8-downloader

- 针对白名单视频站增强 m3u8 识别和导出。
Expand Down Expand Up @@ -85,7 +92,7 @@ npm run build:binance-userscripts
## 维护规则

1. 同一脚本只允许一个真源仓库改代码。
2. `src/binance-orderbook-trade/`、`src/binance-trading-data/`、`src/binance-coinmarketcap-data/`、`src/m3u8-downloader/` 是对应脚本的开发真源。
2. `src/binance-orderbook-trade/`、`src/binance-trading-data/`、`src/binance-coinmarketcap-data/`、`src/binance-strategy27-events/`、`src/m3u8-downloader/` 是对应脚本的开发真源。
3. 公开安装入口仍是生成后的 `scripts/*.user.js`;修改对应 `src/` 后运行 `npm run build:binance-userscripts` 或单脚本 build 命令。
4. 非真源仓库只放安装链接,不复制脚本源码。
5. 每次发布递增 `@version`,并保留 `@updateURL/@downloadURL` 指向真源 raw 地址。
Expand All @@ -94,11 +101,13 @@ npm run build:binance-userscripts
开发手册:

- [Binance orderbook trade development](docs/binance-orderbook-trade-development.md)
- [Binance Strategy 27 event annotations](docs/binance-strategy27-events-development.md)
- [Brooks media sync workflow](docs/brooks-media-sync-workflow.md)

[install-binance-orderbook-trade]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-orderbook-trade.user.js
[install-binance-trading-data]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-trading-data.user.js
[install-binance-coinmarketcap-data]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-coinmarketcap-data.user.js
[install-binance-strategy27-events]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/binance-strategy27-events.user.js
[install-auto-refresh]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/auto_refresh.user.js
[install-coinmarketcap-valuation-helper]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/coinmarketcap-valuation-helper.user.js
[install-m3u8]: https://raw.githubusercontent.com/jackhai9/userscripts/main/scripts/m3u8-downloader.user.js
65 changes: 65 additions & 0 deletions docs/binance-strategy27-events-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Binance Strategy 27 Event Annotations

## Purpose

`binance-strategy27-events.user.js` is a rendering client for the Strategy 27
V10 live projection. The VPS remains the only market-data and event-analysis
authority. The userscript opens no Binance market-data WebSocket, uses no
Binance API key, and does not recalculate the four force groups.

The script reads an authenticated, loopback-only long-poll endpoint through an
SSH local forward. It draws transient entities only when the Binance route,
TradingView symbol, and `1S` chart interval all match the requested Strategy 27
symbol.

## Operator Setup

1. Keep an SSH local forward open from `127.0.0.1:<local-port>` to the VPS
Strategy 27 gateway on `127.0.0.1:8765`.
2. Install `scripts/binance-strategy27-events.user.js` in Tampermonkey.
3. Use the userscript menu to set the loopback gateway origin. The default is
`http://127.0.0.1:18765`.
4. Use the userscript menu to set the gateway installation secret. Tampermonkey
stores it in this script's private value storage; it is never embedded in
source, URL parameters, chart text, console messages, or status text.
5. Open the matching Binance futures route and select the one-second chart.

## Rendering Contract

- `event_opened` creates one marker.
- `event_updated` updates that marker and the compact status strip without
creating a note.
- `event_closed` creates or updates one objective note with the event interval,
four-force facts, immediate price response, trigger reasons, and close reason.
- `event_outcome` updates that same note with the ordered outcome horizons.
- Incomplete or input-gap facts are marked as incomplete and carry no
directional conclusion.

Every created entity uses the second obtained by flooring the projection's
`event_time_ms`. The script reads the entity point back after each create or
update. If TradingView shifts the point to a different bar, the entity is
removed and visualization stops with an alignment error.

The script stores only its own returned entity IDs. Route, symbol, interval,
epoch, cursor, or sequence discontinuities abort the request and remove only
those transient entities. Event count and age are bounded in memory and on the
chart.

## Development

Source lives under `src/binance-strategy27-events/`; the generated installable
artifact is `scripts/binance-strategy27-events.user.js`.

```bash
npm run test:binance-strategy27-events
npm run build:binance-strategy27-events
npm run check:binance-userscripts
node scripts/userscript-release-contract.mjs scripts/binance-strategy27-events.user.js
git diff --check
```

Live validation must confirm the current Binance main-world chart API, exact
`1S` resolution, exact route symbol, successful create/readback/remove behavior,
Tampermonkey source readback, and the actually loaded source after a hard
reload. A source-level method name alone is not end-to-end proof.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
"type": "module",
"scripts": {
"build:userscripts": "node scripts/build-userscript.mjs",
"build:binance-userscripts": "node scripts/build-userscript.mjs binance-orderbook-trade binance-trading-data binance-coinmarketcap-data",
"build:binance-userscripts": "node scripts/build-userscript.mjs binance-orderbook-trade binance-trading-data binance-coinmarketcap-data binance-strategy27-events",
"build:binance-orderbook-trade": "node scripts/build-userscript.mjs binance-orderbook-trade",
"build:binance-trading-data": "node scripts/build-userscript.mjs binance-trading-data",
"build:binance-coinmarketcap-data": "node scripts/build-userscript.mjs binance-coinmarketcap-data",
"build:binance-strategy27-events": "node scripts/build-userscript.mjs binance-strategy27-events",
"build:m3u8-downloader": "node scripts/build-userscript.mjs m3u8-downloader",
"audit:brooks-media": "node scripts/brooks-media-audit.mjs",
"import:brooks-media-index": "node scripts/brooks-media-import-index.mjs",
"download:brooks-media": "node scripts/brooks-media-download.mjs",
"inspect:binance-orderbook-trade": "node scripts/userscript-release-contract.mjs scripts/binance-orderbook-trade.user.js",
"inspect:binance-strategy27-events": "node scripts/userscript-release-contract.mjs scripts/binance-strategy27-events.user.js",
"verify:binance-orderbook-stage3": "node scripts/binance-stage3-evidence.mjs",
"assemble:binance-orderbook-live": "node scripts/binance-live-capture.mjs",
"summarize:binance-orderbook-live": "node scripts/binance-live-performance.mjs",
"check:binance-userscripts": "node --check scripts/binance-orderbook-trade.user.js && node --check scripts/binance-trading-data.user.js && node --check scripts/binance-coinmarketcap-data.user.js",
"check:binance-userscripts": "node --check scripts/binance-orderbook-trade.user.js && node --check scripts/binance-trading-data.user.js && node --check scripts/binance-coinmarketcap-data.user.js && node --check scripts/binance-strategy27-events.user.js",
"check:binance-orderbook-trade": "node --check scripts/binance-orderbook-trade.user.js",
"check:m3u8-downloader": "node --check scripts/m3u8-downloader.user.js",
"test": "node --test",
"test:binance-orderbook-trade": "node --test test/unit/binance-orderbook-trade/*.test.js test/dom/binance-orderbook-trade/*.test.js",
"test:binance-orderbook-ui-toolchain": "node --test test/unit/binance-orderbook-trade/*.test.js test/dom/binance-orderbook-trade/*.test.js test/unit/binance-*.test.js",
"test:binance-strategy27-events": "node --test test/unit/binance-strategy27-events/*.test.js test/dom/binance-strategy27-events/*.test.js test/unit/userscript-metadata-icons.test.js test/unit/userscript-release-contract.test.js",
"test:ui": "playwright test",
"test:ui:headed": "playwright test --headed",
"test:ui:debug": "playwright test --debug"
Expand Down
Loading
Loading