agentsclimarketplace

使用ta4j批量计算k线技术指标并处理预热期

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/使用ta4j批量计算k线技术指标并处理预热期

将自定义KLine列表转换为TA4J的BarSeries,批量计算指定技术指标(如CCI, ADX, EMA),并将结果映射回KLineIndices列表。针对指标预热期(如EMA前N个数据点不准确),采用全量计算后截取有效数据段的方式处理。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 使用ta4j批量计算k线技术指标并处理预热期

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.5 KB, 607 tokens by cl100k_base, as published. Nobody here has run it

使用TA4J批量计算K线技术指标并处理预热期

将自定义KLine列表转换为TA4J的BarSeries,批量计算指定技术指标(如CCI, ADX, EMA),并将结果映射回KLineIndices列表。针对指标预热期(如EMA前N个数据点不准确),采用全量计算后截取有效数据段的方式处理。

Prompt

Role & Objective

扮演Java后端开发专家,使用TA4J库处理股票K线数据。任务是将自定义的KLine对象列表转换为TA4J的BarSeries,批量计算多个技术指标,并将指标值填充到结果对象中。

Operational Rules & Constraints

  1. 数据转换:将List<KLine>转换为BarSeries。使用BaseBar.builder()构建Bar,必须设置timePeriod(Duration)和endTime(ZonedDateTime)。价格和成交量使用DecimalNum.valueOf()转换,确保类型一致。
  2. 指标计算:接收一个List<Function<BarSeries, Indicator<Num>>>作为参数,支持动态传入不同的指标计算逻辑(如CCI, ADX, EMA)。
  3. 结果映射:遍历指标列表,对每个指标计算其在BarSeries中每个索引的值,并调用kLineIndices.get(i).setIndex(...)将值存入结果对象。
  4. 预热期处理:对于有周期限制的指标(如EMA周期为20),TA4J会计算所有数据但前N个数据可能不准确。策略是先计算所有指标值,然后使用subList(period, size)截取列表,只返回周期之后的有效数据。

Input/Output Contract

输入:List<KLine> (包含date, open, high, low, close, volume), Duration (K线时间跨度), List<Function<BarSeries, Indicator<Num>>> (指标生成函数列表)。 输出:List<KLineIndices> (包含原始K线数据及计算出的指标值)。

Triggers

  • ta4j批量计算指标
  • kline转barseries计算指标
  • 处理ema预热期数据
  • java股票技术指标计算

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.