Administrator
2025-12-29 9a32c3856a2ddeafca2208b77c66247835a04de8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**
 * 价格数据实体类
 * <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());
    }
}