---
title: "ruflo-market-data"
url: "https://claudemods.dev/zh-tw/builds/ruflo-market-data-00345b"
source: "https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-market-data"
source_type: "github"
repo: "https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-market-data"
author: "ruvnet"
author_handle: "ruvnet"
stars: 82435
category: "安全與隱私"
categories: ["security"]
tags: ["claude-code-plugin", "credential-guard", "hnsw", "hooks", "market-data"]
permission_level: 2
scan_complete: true
install: "claude plugin marketplace add ruvnet/ruflo\nclaude plugin install ruflo-market-data"
added: "2026-10-05T08:13:49.458Z"
updated: "2026-11-25T14:44:06Z"
locale: "zh-tw"
content_locale: "zh-tw"
---

# ruflo-market-data

市場資料擷取──行情來源正規化、OHLCV 向量化，以及以 HNSW 建立索引的型態比對。

## Description

# ruflo-market-data

市場資料擷取──行情來源正規化、OHLCV 向量化，以及以 HNSW 建立索引的型態比對。

## 概覽

從 REST API 與 WebSocket feed 擷取市場資料，將其正規化為縮放一致的 OHLCV 向量，並把 K 線型態向量化，以供 HNSW 相似度搜尋。透過可靠度評分，偵測單根 K 線（doji、hammer）及多根 K 線（engulfing、morning star、head & shoulders）組合。

## 安裝

```bash
claude --plugin-dir plugins/ruflo-market-data
```

## Agents

| Agent | Model | 角色 |
|-------|-------|------|
| data-engineer | sonnet | 擷取行情來源、正規化 OHLCV、將 K 線型態向量化，並進行以 HNSW 建立索引的型態比對 |

## Skills

| Skill | 用法 | 說明 |
|-------|------|------|
| market-ingest | /market-ingest <symbol> [--source api] | 擷取並正規化市場資料，建立含 HNSW 索引的 OHLCV 向量 |
| market-pattern | /market-pattern <symbol> [--period 1D] | 從已擷取的資料偵測並分類 K 線型態 |

## Commands (5 subcommands)

```bash
market ingest <symbol> [--period 1D]    # Ingest and normalize OHLCV data
market patterns <symbol>                 # Detect candlestick patterns
market search <pattern-name>             # Search historical pattern occurrences
market history <symbol>                  # Show ingestion history and data coverage
market compare <sym1> <sym2>             # Compare pattern profiles between symbols
```

## OHLCV 正規化

| 欄位 | 正規化方式 |
|------|------------|
| Open | 相對於前一筆收盤價：(open - prev_close) / prev_close |
| High | 相對於開盤價：(high - open) / open |
| Low | 相對於開盤價：(low - open) / open |
| Close | 相對於開盤價：(close - open) / open |
| Volume | Z-score：(vol - mean_vol) / std_vol |

## 型態函式庫

| 型態 | 類型 | K 線數量 | 可靠度 |
|------|------|----------|--------|
| Doji | 反轉 | 1 | 中等 |
| Hammer | 反轉 | 1 | 中高 |
| Engulfing | 反轉 | 2 | 高 |
| Morning/Evening Star | 反轉 | 3 | 高 |
| Three White Soldiers | 延續 | 3 | 高 |
| Head & Shoulders | 反轉 | 5-7 | 極高 |
| Double Top/Bottom | 反轉 | 可變 | 高 |

每種型態都會編碼成 64 維填充向量，用於 HNSW 索引。

## 相容性

- **CLI：**固定使用 @claude-flow/cli 的 v3.6 主版本與次版本。
- **驗證：**bash plugins/ruflo-market-data/scripts/smoke.sh 是契約。

## 命名空間協調

此外掛擁有兩個 AgentDB 命名空間（使用 kebab-case，並遵循 ruflo-agentdb ADR-0001 的「Namespace convention」慣例）：

- market-data — 每個 symbol+date 對應的正規化 OHLCV 向量
- market-patterns — 附有可靠度評分的已偵測 K 線型態

兩者都透過依命名空間路由的 memory_* 存取。保留的命名空間（pattern、claude-memories、default）絕對不能被覆蓋。

> **路由說明：**這些技能的早期版本使用帶有命名空間引數的 agentdb_hierarchical-* 與 agentdb_pattern-*；這些工具系列會依層級/ReasoningBank 路由，忽略命名空間字串。ADR-0001 已修正這些技能，改用 memory_* 進行含命名空間的讀寫。

## 驗證

```bash
bash plugins/ruflo-market-data/scripts/smoke.sh
# Expected: "11 passed, 0 failed"
```

## 架構決策

- [ADR-0001 — ruflo-market-data plugin contract (3 functional bug fixes + namespace coordination + smoke as contract)](./docs/adrs/0001-market-data-contract.md)

## 相關外掛

- ruflo-agentdb — 命名空間慣例的擁有者；定義 ADR-0001 修正違規所依據的路由規則
- ruflo-neural-trader -- 將市場型態作為策略訊號使用
- ruflo-ruvector -- 用於型態相似度搜尋的 HNSW 索引引擎
- ruflo-observability -- 資料 feed 健康度與擷取延遲儀表板

## 授權條款

MIT

## 作為 mod

此外掛提供一個函式掛鉤 mod（ADR-445，hooks/register.ts）。它不發出網路呼叫、不產生程序，也不呼叫模型。

- **Guard**（僅收緊，預設開啟）：拒絕寫入 market* 命名空間（memory_store、agentdb_pattern-store、agentdb_hierarchical-store、ruvllm_hnsw_add）中含有金鑰或 token 的內容，也拒絕查詢字串帶有認證資訊，或使用 user:pass@host 認證資訊的 feed URL。其他命名空間不受影響。拒絕時絕不回傳機密內容。
- **/market-mod**：status、recent、tools（此外掛連接了哪些工具）與 scan <text>（Guard 是否會拒絕這段文字）。這些回應都在本機完成。
- **狀態檔案**：.claude-flow/market-mod/status.json（{version: 1, updatedMs, guard, calls, total, blocked, recent}，只有計數器，絕不記錄工具輸入），在工作階段開始時，以及每次呼叫此外掛工具後寫入。

選項（userConfig）：guard（on）。

測試方式：claude plugin validate plugins/ruflo-market-data、claude plugin test plugins/ruflo-market-data、bash plugins/ruflo-market-data/scripts/smoke.sh。

## Install

```
claude plugin marketplace add ruvnet/ruflo
claude plugin install ruflo-market-data
```

## Original README

# ruflo-market-data

Market data ingestion -- feed normalization, OHLCV vectorization, and HNSW-indexed pattern matching.

## Overview

Ingests market data from REST APIs and WebSocket feeds, normalizes to OHLCV vectors with consistent scaling, and vectorizes candlestick patterns for HNSW similarity search. Detects single-candle (doji, hammer) and multi-candle (engulfing, morning star, head & shoulders) formations with reliability scoring.

## Installation

```bash
claude --plugin-dir plugins/ruflo-market-data
```

## Agents

| Agent | Model | Role |
|-------|-------|------|
| `data-engineer` | sonnet | Ingest market feeds, normalize OHLCV, vectorize candlestick patterns, HNSW-indexed pattern matching |

## Skills

| Skill | Usage | Description |
|-------|-------|-------------|
| `market-ingest` | `/market-ingest <symbol> [--source api]` | Ingest and normalize market data into OHLCV vectors with HNSW indexing |
| `market-pattern` | `/market-pattern <symbol> [--period 1D]` | Detect and classify candlestick patterns from ingested data |

## Commands (5 subcommands)

```bash
market ingest <symbol> [--period 1D]    # Ingest and normalize OHLCV data
market patterns <symbol>                 # Detect candlestick patterns
market search <pattern-name>             # Search historical pattern occurrences
market history <symbol>                  # Show ingestion history and data coverage
market compare <sym1> <sym2>             # Compare pattern profiles between symbols
```

## OHLCV Normalization

| Field | Normalization |
|-------|--------------|
| Open | Relative to previous close: `(open - prev_close) / prev_close` |
| High | Relative to open: `(high - open) / open` |
| Low | Relative to open: `(low - open) / open` |
| Close | Relative to open: `(close - open) / open` |
| Volume | Z-score: `(vol - mean_vol) / std_vol` |

## Pattern Library

| Pattern | Type | Candles | Reliability |
|---------|------|---------|-------------|
| Doji | Reversal | 1 | Medium |
| Hammer | Reversal | 1 | Medium-High |
| Engulfing | Reversal | 2 | High |
| Morning/Evening Star | Reversal | 3 | High |
| Three White Soldiers | Continuation | 3 | High |
| Head & Shoulders | Reversal | 5-7 | Very High |
| Double Top/Bottom | Reversal | Variable | High |

Each pattern is encoded as a 64-dimension padded vector for HNSW indexing.

## Compatibility

- **CLI:** pinned to `@claude-flow/cli` v3.6 major+minor.
- **Verification:** `bash plugins/ruflo-market-data/scripts/smoke.sh` is the contract.

## Namespace coordination

This plugin owns two AgentDB namespaces (kebab-case, follows the convention from [ruflo-agentdb ADR-0001 §"Namespace convention"](../ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md)):

- `market-data` — normalized OHLCV vectors per symbol+date
- `market-patterns` — detected candlestick patterns with reliability scores

Both accessed via `memory_*` (namespace-routed). Reserved namespaces (`pattern`, `claude-memories`, `default`) MUST NOT be shadowed.

> **Routing note:** Earlier versions of these skills used `agentdb_hierarchical-*` and `agentdb_pattern-*` with namespace arguments — those tool families route by tier/ReasoningBank and ignore namespace strings. ADR-0001 fixed the skills to use `memory_*` for namespaced reads/writes.

## Verification

```bash
bash plugins/ruflo-market-data/scripts/smoke.sh
# Expected: "11 passed, 0 failed"
```

## Architecture Decisions

- [`ADR-0001` — ruflo-market-data plugin contract (3 functional bug fixes + namespace coordination + smoke as contract)](./docs/adrs/0001-market-data-contract.md)

## Related Plugins

- `ruflo-agentdb` — namespace convention owner; defines the routing rules ADR-0001 fixes violations of
- `ruflo-neural-trader` -- Consumes market patterns as strategy signals
- `ruflo-ruvector` -- HNSW indexing engine for pattern similarity search
- `ruflo-observability` -- Data feed health and ingestion latency dashboards

## License

MIT

## As a mod

This plugin ships a function-hook mod (ADR-445, `hooks/register.ts`). It makes no network call, spawns no process and makes no model call.

- **Guard** (tighten-only, on by default): Refuses writes to a `market*` namespace (`memory_store`, `agentdb_pattern-store`, `agentdb_hierarchical-store`, `ruvllm_hnsw_add`) that hold a key or token, or a feed URL with a credential in its query string or as `user:pass@host`. Other namespaces are untouched. A refusal never echoes the secret.
- **`/market-mod`**: `status`, `recent`, `tools` (which of this plugin's tools are connected) and `scan <text>` (would the guard refuse it). Answered locally.
- **Status file**: `.claude-flow/market-mod/status.json` (`{version: 1, updatedMs, guard, calls, total, blocked, recent}`, counters only, never tool input), written at session start and after every call to this plugin's tools.

Options (`userConfig`): `guard` (on).

Test it: `claude plugin validate plugins/ruflo-market-data`, `claude plugin test plugins/ruflo-market-data`, `bash plugins/ruflo-market-data/scripts/smoke.sh`.
