From 4884ebffeed775d63dbf7bb7d0ece8182f10c344 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 26 Dec 2025 18:19:46 +0800
Subject: [PATCH] fix(okxNewPrice): 解决交易订单为空时的空指针异常
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/indicator/macdAndMatrategy/PriceData.java | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 162 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/indicator/macdAndMatrategy/PriceData.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/indicator/macdAndMatrategy/PriceData.java
new file mode 100644
index 0000000..38f61e8
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/indicator/macdAndMatrategy/PriceData.java
@@ -0,0 +1,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());
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1