新版仿ok交易所-后端
1
zj
2025-10-30 14c1946eae86a86f8d1edee6cf3bdaf7572fc966
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package com.yami.trading.bean.data.domain;
 
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.yami.trading.common.domain.UUIDEntity;
import com.yami.trading.common.util.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
 
/**
 * 实时价格Entity
 *
 * @author lucas
 * @version 2023-03-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_realtime")
@ApiModel
@Slf4j
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class Realtime extends UUIDEntity implements Comparable<Realtime>, Cloneable {
 
    private static final long serialVersionUID = 1L;
    /**
     * 产品代码
     */
    @ApiModelProperty("产品代码")
    private String symbol;
    /**
     * 时间戳
     */
    @ApiModelProperty("时间戳")
    private Long ts;
    /**
     * 产品名称
     */
    @ApiModelProperty("产品名称")
    private String name;
    /**
     * 开盘价
     */
    @ApiModelProperty("开盘价")
    private BigDecimal open;
    /**
     * 最高价
     */
    @ApiModelProperty("最高价")
    private BigDecimal high;
    /**
     * 最低价
     */
    @ApiModelProperty("最低价")
    private BigDecimal low;
    /**
     * 最新价
     */
    @ApiModelProperty("最新价")
    private BigDecimal close;
    /**
     * 成交量 币个数
     */
 
    @ApiModelProperty(" 成交量 币个数")
    private BigDecimal amount;
    /**
     * 成交额 金额
     *
     */
 
    @ApiModelProperty(" 成交额 金额")
    private BigDecimal volume;
    /**
     * type
     */
    private String type;
 
    /**
     * 涨跌幅
     */
    @TableField(exist = false)
    @ApiModelProperty("涨跌幅")
    private BigDecimal changeRatio;
 
    /**
     * 净值涨跌幅
     */
    @TableField(exist = false)
    @ApiModelProperty("净值涨跌幅")
    private BigDecimal netChange;
 
    /**
     * 市值
     */
    @TableField(exist = false)
    @JSONField(name = "market_capital")
    private Long marketCapital;
 
    /**
     * 流通市值
     */
    @TableField(exist = false)
    @JSONField(name = "float_market_capital")
    private Long floatMarketCapital;
 
    /**
     * 市盈率
     */
    @TableField(exist = false)
    @JSONField(name = "pe_forecast")
    private BigDecimal peForecast;
 
    /**
     * 量比
     */
    @TableField(exist = false)
    @JSONField(name = "volume_ratio")
    private BigDecimal volumeRatio ;
 
    /**
     * 换手率
     */
    @TableField(exist = false)
    @JSONField(name = "turnover_rate")
    private BigDecimal turnoverRate ;
 
    @TableField(exist = false)
    @ApiModelProperty("产品代码")
    private String symbolData;
    /**
     * 时间戳的"yyyy-MM-dd HH:mm:ss"格式
     */
    @TableField(exist = false)
    private String currentTime;
    /**
     * 卖价
     */
    private BigDecimal bid;
 
    /**
     * 买价格
     */
    private BigDecimal ask;
 
 
    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
 
    @Override
    public int compareTo(Realtime realtime) {
        if (this.ts > realtime.getTs()) {
            return 1;
        } else if (this.ts < realtime.getTs()) {
            return -1;
        }
        return 0;
    }
 
    public BigDecimal getChangeRatio() {
        if (BigDecimal.ZERO.compareTo(open) == 0) {
            return BigDecimal.ZERO;
 
        }
        BigDecimal changeRatio = close.subtract(open).divide(open, 10, RoundingMode.DOWN);
        changeRatio = changeRatio.multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN);
        return changeRatio;
 
 
    }
 
    public BigDecimal getNetChange() {
        BigDecimal netChange = close.multiply(getChangeRatio()).divide(new BigDecimal(100), 10, RoundingMode.DOWN);
        netChange = netChange.setScale(4, RoundingMode.DOWN);
        return netChange;
    }
 
    public String getCurrentTime() {
        currentTime = DateUtils.timeStamp2Date(String.valueOf(ts));
        return currentTime;
    }
 
 
}