/**
|
* 价格数据实体类
|
* <p>
|
* 用于存储K线的价格数据及其衍生指标值。作为MACD和MA策略计算过程中的数据载体,
|
* 包含收盘价、指数移动平均线、MACD指标等关键价格和指标信息。
|
*/
|
package com.xcong.excoin.modules.okxNewPrice.indicator.macdAndMatrategy;
|
|
import java.math.BigDecimal;
|
|
/**
|
* 价格数据类,封装单条K线的价格信息及相关技术指标数据
|
* 使用BigDecimal确保金融计算的精确性
|
*/
|
public class PriceData {
|
/** 收盘价 */
|
private BigDecimal close;
|
|
/** 短期指数移动平均线(通常为12周期) */
|
private BigDecimal emaShort;
|
|
/** 长期指数移动平均线(通常为26周期) */
|
private BigDecimal emaLong;
|
|
/** DIF值(短期EMA与长期EMA的差值) */
|
private BigDecimal dif;
|
|
/** DEA值(DIF的移动平均线,通常为9周期EMA) */
|
private BigDecimal dea;
|
|
/** MACD柱状图值(DIF与DEA的差值) */
|
private BigDecimal macdHist;
|
|
/**
|
* 构造函数,创建价格数据对象
|
*
|
* @param close 收盘价
|
*/
|
public PriceData(BigDecimal close) {
|
this.close = close;
|
}
|
|
/**
|
* 获取收盘价
|
*
|
* @return 收盘价
|
*/
|
public BigDecimal getClose() {
|
return close;
|
}
|
|
/**
|
* 设置收盘价
|
*
|
* @param close 收盘价
|
*/
|
public void setClose(BigDecimal close) {
|
this.close = close;
|
}
|
|
/**
|
* 获取短期EMA值
|
*
|
* @return 短期EMA值
|
*/
|
public BigDecimal getEmaShort() {
|
return emaShort;
|
}
|
|
/**
|
* 设置短期EMA值
|
*
|
* @param emaShort 短期EMA值
|
*/
|
public void setEmaShort(BigDecimal emaShort) {
|
this.emaShort = emaShort;
|
}
|
|
/**
|
* 获取长期EMA值
|
*
|
* @return 长期EMA值
|
*/
|
public BigDecimal getEmaLong() {
|
return emaLong;
|
}
|
|
/**
|
* 设置长期EMA值
|
*
|
* @param emaLong 长期EMA值
|
*/
|
public void setEmaLong(BigDecimal emaLong) {
|
this.emaLong = emaLong;
|
}
|
|
/**
|
* 获取DIF值
|
*
|
* @return DIF值
|
*/
|
public BigDecimal getDif() {
|
return dif;
|
}
|
|
/**
|
* 设置DIF值
|
*
|
* @param dif DIF值
|
*/
|
public void setDif(BigDecimal dif) {
|
this.dif = dif;
|
}
|
|
/**
|
* 获取DEA值
|
*
|
* @return DEA值
|
*/
|
public BigDecimal getDea() {
|
return dea;
|
}
|
|
/**
|
* 设置DEA值
|
*
|
* @param dea DEA值
|
*/
|
public void setDea(BigDecimal dea) {
|
this.dea = dea;
|
}
|
|
/**
|
* 获取MACD柱状图值
|
*
|
* @return MACD柱状图值
|
*/
|
public BigDecimal getMacdHist() {
|
return macdHist;
|
}
|
|
/**
|
* 设置MACD柱状图值
|
*
|
* @param macdHist MACD柱状图值
|
*/
|
public void setMacdHist(BigDecimal macdHist) {
|
this.macdHist = macdHist;
|
}
|
|
/**
|
* 转换为字符串表示
|
*
|
* @return 格式化的字符串表示
|
*/
|
@Override
|
public String toString() {
|
return String.format("PriceData{close=%.2f, EMA_short=%.2f, EMA_long=%.2f, DIF=%.2f, DEA=%.2f, MACD_hist=%.2f}",
|
close.doubleValue(), emaShort.doubleValue(), emaLong.doubleValue(),
|
dif.doubleValue(), dea.doubleValue(), macdHist.doubleValue());
|
}
|
}
|