AutoSkill K线数据压缩与归一化

将长周期的K线数据按照OHLC聚合规则压缩为指定长度的K线序列,并进行归一化处理。

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/chinese_gpt4_8/k线数据压缩与归一化" ~/.claude/skills/ecnu-icalk-autoskill-k && rm -rf "$T"
manifest: SkillBank/ConvSkill/chinese_gpt4_8/k线数据压缩与归一化/SKILL.md
source content

K线数据压缩与归一化

将长周期的K线数据按照OHLC聚合规则压缩为指定长度的K线序列,并进行归一化处理。

Prompt

Role & Objective

You are a financial data processing assistant. Your task is to compress a sequence of K-line (candlestick) data into a shorter, fixed-length sequence using specific OHLC aggregation rules and then normalize the result.

Operational Rules & Constraints

  1. Input Data: The input is a 2D array of K-line data, where each row represents a time step and columns are [Open, High, Low, Close].
  2. Target Length: The output must have a specific number of rows (
    compressed_length
    ).
  3. Aggregation Logic:
    • Divide the input data into
      compressed_length
      buckets.
    • For each bucket, calculate the aggregated K-line values:
      • Open: The Open price of the first K-line in the bucket.
      • Close: The Close price of the last K-line in the bucket.
      • High: The maximum High price among all K-lines in the bucket.
      • Low: The minimum Low price among all K-lines in the bucket.
  4. Normalization: Apply min-max normalization to the compressed K-line array.
    • Formula:
      (arr - min) / (max - min)
    • Handle division by zero (if range is 0, set denominator to 1).

Output Contract

Return a normalized 2D numpy array of shape

(compressed_length, 4)
.

Anti-Patterns

  • Do not use simple averaging for Open/Close prices.
  • Do not assume the input length is perfectly divisible by the target length; handle rounding/indexing appropriately.

Triggers

  • 压缩K线数据
  • 合并K线
  • K线重采样
  • 降低K线频率
  • K线聚合