|
@@ -15,6 +15,7 @@ import (
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
+ "github.com/shopspring/decimal"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// HistoryData 历史数据
|
|
// HistoryData 历史数据
|
|
@@ -105,13 +106,14 @@ func QueryHistoryDatas(c *gin.Context) {
|
|
|
// 计算最终价格
|
|
// 计算最终价格
|
|
|
rst := make([]HistoryData, 0)
|
|
rst := make([]HistoryData, 0)
|
|
|
for _, v := range cycleDatas {
|
|
for _, v := range cycleDatas {
|
|
|
|
|
+ tt, _ := decimal.NewFromFloat(utils.IntToFloat64(v.TT, dcplace)).Round(2).Float64() // 按行情服务要求,金额类需要先除以商品报价小数位再按2位小数四舍五入
|
|
|
historyData := HistoryData{
|
|
historyData := HistoryData{
|
|
|
Opened: utils.IntToFloat64(v.Open, dcplace),
|
|
Opened: utils.IntToFloat64(v.Open, dcplace),
|
|
|
Highest: utils.IntToFloat64(v.High, dcplace),
|
|
Highest: utils.IntToFloat64(v.High, dcplace),
|
|
|
Lowest: utils.IntToFloat64(v.Low, dcplace),
|
|
Lowest: utils.IntToFloat64(v.Low, dcplace),
|
|
|
Closed: utils.IntToFloat64(v.Close, dcplace),
|
|
Closed: utils.IntToFloat64(v.Close, dcplace),
|
|
|
TotleVolume: v.TV,
|
|
TotleVolume: v.TV,
|
|
|
- TotleTurnover: float64(v.TT),
|
|
|
|
|
|
|
+ TotleTurnover: tt,
|
|
|
HoldVolume: v.HV,
|
|
HoldVolume: v.HV,
|
|
|
Settle: utils.IntToFloat64(v.SP, dcplace),
|
|
Settle: utils.IntToFloat64(v.SP, dcplace),
|
|
|
TimeStamp: time.Unix(int64(v.ST), 0),
|
|
TimeStamp: time.Unix(int64(v.ST), 0),
|
|
@@ -185,6 +187,7 @@ func QueryHistoryDatas(c *gin.Context) {
|
|
|
v := quoteDays[0]
|
|
v := quoteDays[0]
|
|
|
if len(rst) == 0 {
|
|
if len(rst) == 0 {
|
|
|
logger.GetLogger().Debugf("[checkTiks] no tiks, add a tik:%v", v)
|
|
logger.GetLogger().Debugf("[checkTiks] no tiks, add a tik:%v", v)
|
|
|
|
|
+ tt, _ := decimal.NewFromFloat(utils.IntToFloat64(int(v.Totalturnover), dcplace)).Round(2).Float64() // 按行情服务要求,金额类需要先除以商品报价小数位再按2位小数四舍五入
|
|
|
// 历史数据当前没数据则直接加当前盘面数据
|
|
// 历史数据当前没数据则直接加当前盘面数据
|
|
|
historyData := HistoryData{
|
|
historyData := HistoryData{
|
|
|
Opened: utils.IntToFloat64(int(v.Opened), dcplace),
|
|
Opened: utils.IntToFloat64(int(v.Opened), dcplace),
|
|
@@ -192,7 +195,7 @@ func QueryHistoryDatas(c *gin.Context) {
|
|
|
Lowest: utils.IntToFloat64(int(v.Lowest), dcplace),
|
|
Lowest: utils.IntToFloat64(int(v.Lowest), dcplace),
|
|
|
Closed: utils.IntToFloat64(int(v.Last), dcplace),
|
|
Closed: utils.IntToFloat64(int(v.Last), dcplace),
|
|
|
TotleVolume: int(v.Totalvolume),
|
|
TotleVolume: int(v.Totalvolume),
|
|
|
- TotleTurnover: float64(v.Totalturnover),
|
|
|
|
|
|
|
+ TotleTurnover: tt,
|
|
|
HoldVolume: int(v.Holdvolume),
|
|
HoldVolume: int(v.Holdvolume),
|
|
|
Settle: utils.IntToFloat64(int(v.Settle), dcplace),
|
|
Settle: utils.IntToFloat64(int(v.Settle), dcplace),
|
|
|
TimeStamp: fisrtDate,
|
|
TimeStamp: fisrtDate,
|
|
@@ -221,13 +224,14 @@ func QueryHistoryDatas(c *gin.Context) {
|
|
|
// #3424 当日未开市显示了K线
|
|
// #3424 当日未开市显示了K线
|
|
|
// 修改:这里增加判断盘面是否有开盘价
|
|
// 修改:这里增加判断盘面是否有开盘价
|
|
|
if v.Opened > 0 && v.Last > 0 {
|
|
if v.Opened > 0 && v.Last > 0 {
|
|
|
|
|
+ tt, _ := decimal.NewFromFloat(utils.IntToFloat64(int(v.Totalturnover), dcplace)).Round(2).Float64() // 按行情服务要求,金额类需要先除以商品报价小数位再按2位小数四舍五入
|
|
|
historyData := HistoryData{
|
|
historyData := HistoryData{
|
|
|
Opened: utils.IntToFloat64(int(v.Opened), dcplace),
|
|
Opened: utils.IntToFloat64(int(v.Opened), dcplace),
|
|
|
Highest: utils.IntToFloat64(int(v.Highest), dcplace),
|
|
Highest: utils.IntToFloat64(int(v.Highest), dcplace),
|
|
|
Lowest: utils.IntToFloat64(int(v.Lowest), dcplace),
|
|
Lowest: utils.IntToFloat64(int(v.Lowest), dcplace),
|
|
|
Closed: utils.IntToFloat64(int(v.Last), dcplace),
|
|
Closed: utils.IntToFloat64(int(v.Last), dcplace),
|
|
|
TotleVolume: int(v.Totalvolume),
|
|
TotleVolume: int(v.Totalvolume),
|
|
|
- TotleTurnover: float64(v.Totalturnover),
|
|
|
|
|
|
|
+ TotleTurnover: tt,
|
|
|
HoldVolume: int(v.Holdvolume),
|
|
HoldVolume: int(v.Holdvolume),
|
|
|
Settle: utils.IntToFloat64(int(v.Settle), dcplace),
|
|
Settle: utils.IntToFloat64(int(v.Settle), dcplace),
|
|
|
TimeStamp: fisrtDate,
|
|
TimeStamp: fisrtDate,
|
|
@@ -348,11 +352,12 @@ func QueryHistoryTikDatas(c *gin.Context) {
|
|
|
if v.TDR == 83 { // (Ascii) B-66 S-83
|
|
if v.TDR == 83 { // (Ascii) B-66 S-83
|
|
|
buyOrSell = 1
|
|
buyOrSell = 1
|
|
|
}
|
|
}
|
|
|
|
|
+ tt, _ := decimal.NewFromFloat(utils.IntToFloat64(v.TT, dcplace)).Round(2).Float64() // 按行情服务要求,金额类需要先除以商品报价小数位再按2位小数四舍五入
|
|
|
rst = append(rst, HistoryTikData{
|
|
rst = append(rst, HistoryTikData{
|
|
|
TimeStamp: time.Unix(int64(v.AT), 0),
|
|
TimeStamp: time.Unix(int64(v.AT), 0),
|
|
|
PE: utils.IntToFloat64(v.PE, dcplace),
|
|
PE: utils.IntToFloat64(v.PE, dcplace),
|
|
|
Vol: v.Vol,
|
|
Vol: v.Vol,
|
|
|
- TT: float64(v.TT),
|
|
|
|
|
|
|
+ TT: tt,
|
|
|
Bid: utils.IntToFloat64(v.Bid, dcplace),
|
|
Bid: utils.IntToFloat64(v.Bid, dcplace),
|
|
|
BV: v.BV,
|
|
BV: v.BV,
|
|
|
Ask: utils.IntToFloat64(v.Ask, dcplace),
|
|
Ask: utils.IntToFloat64(v.Ask, dcplace),
|
|
@@ -799,13 +804,14 @@ func QueryTSData(c *gin.Context) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if needAdd {
|
|
if needAdd {
|
|
|
|
|
+ tt, _ := decimal.NewFromFloat(utils.IntToFloat64(cycleData.TT, int(goods.Decimalplace))).Round(2).Float64() // 按行情服务要求,金额类需要先除以商品报价小数位再按2位小数四舍五入
|
|
|
historyDatas = append(historyDatas, HistoryData{
|
|
historyDatas = append(historyDatas, HistoryData{
|
|
|
Opened: utils.IntToFloat64(cycleData.Open, int(goods.Decimalplace)),
|
|
Opened: utils.IntToFloat64(cycleData.Open, int(goods.Decimalplace)),
|
|
|
Highest: utils.IntToFloat64(cycleData.High, int(goods.Decimalplace)),
|
|
Highest: utils.IntToFloat64(cycleData.High, int(goods.Decimalplace)),
|
|
|
Lowest: utils.IntToFloat64(cycleData.Low, int(goods.Decimalplace)),
|
|
Lowest: utils.IntToFloat64(cycleData.Low, int(goods.Decimalplace)),
|
|
|
Closed: utils.IntToFloat64(cycleData.Close, int(goods.Decimalplace)),
|
|
Closed: utils.IntToFloat64(cycleData.Close, int(goods.Decimalplace)),
|
|
|
TotleVolume: cycleData.TV,
|
|
TotleVolume: cycleData.TV,
|
|
|
- TotleTurnover: float64(cycleData.TT),
|
|
|
|
|
|
|
+ TotleTurnover: tt,
|
|
|
HoldVolume: cycleData.HV,
|
|
HoldVolume: cycleData.HV,
|
|
|
Settle: utils.IntToFloat64(cycleData.SP, int(goods.Decimalplace)),
|
|
Settle: utils.IntToFloat64(cycleData.SP, int(goods.Decimalplace)),
|
|
|
TimeStamp: time.Unix(int64(cycleData.ST), 0),
|
|
TimeStamp: time.Unix(int64(cycleData.ST), 0),
|