gitee.com/quant1x/engine@v1.8.4/models/features.go (about) 1 package models 2 3 import ( 4 "gitee.com/quant1x/engine/factors" 5 "gitee.com/quant1x/exchange" 6 "gitee.com/quant1x/num" 7 "time" 8 ) 9 10 // FeatureToSnapshot 特征缓存数据转快照 11 func FeatureToSnapshot(feature factors.SecurityFeature, securityCode string) factors.QuoteSnapshot { 12 id, _, symbol := exchange.DetectMarket(securityCode) 13 qs := factors.QuoteSnapshot{ 14 Date: feature.Date, 15 SecurityCode: securityCode, 16 //Market uint8 // 市场 17 Market: id, 18 //Code string `name:"证券代码"` // 代码 19 Code: symbol, 20 //Name string `name:"证券名称"` // 证券名称 21 //Active uint16 `name:"活跃度"` // 活跃度 22 //LastClose float64 `name:"昨收"` // 昨收 23 LastClose: feature.LastClose, 24 //Open float64 `name:"开盘价"` // 开盘 25 Open: feature.Open, 26 //OpeningChangeRate float64 `name:"开盘涨幅%"` // 开盘 27 OpeningChangeRate: num.NetChangeRate(feature.LastClose, feature.Open), 28 //Price float64 `name:"现价"` // 现价 29 Price: feature.Close, 30 //ChangeRate float64 `name:"涨跌幅%"` // 涨跌幅 31 ChangeRate: num.NetChangeRate(feature.LastClose, feature.Close), 32 //PremiumRate float64 `name:"溢价率%"` // 集合竞价买入溢价, hedgeRatio 33 PremiumRate: num.NetChangeRate(feature.Open, feature.Close), 34 //High float64 // 最高 35 High: feature.High, 36 //Low float64 // 最低 37 Low: feature.Low, 38 //ServerTime string // 时间 39 //ReversedBytes0 int // 保留(时间 ServerTime) 40 //ReversedBytes1 int // 保留 41 //Vol int // 总量 42 Vol: int(feature.Volume), 43 //CurVol int // 现量 44 //Amount float64 // 总金额 45 Amount: feature.Amount, 46 //SVol int // 内盘 47 SVol: int(feature.InnerVolume), 48 //BVol int // 外盘 49 BVol: int(feature.OuterVolume), 50 //IndexOpenAmount int // 指数-集合竞价成交金额=开盘成交金额 51 //StockOpenAmount int // 个股-集合竞价成交金额=开盘成交金额 52 StockOpenAmount: int(float64(feature.OpenVolume) * feature.Open), 53 //OpenVolume int `name:"开盘量"` // 集合竞价-开盘量, 单位是股 54 OpenVolume: int(feature.OpenVolume), 55 //Rate float64 // 涨速 56 //Active2 uint16 // 活跃度 57 //TopNo int // 板块排名 58 //TopCode string // 领涨个股 59 //TopName string // 领涨个股名称 60 //TopRate float64 // 领涨个股涨幅 61 //ZhanTing int // 涨停数 62 //Ling int // 平盘数 63 //Count int // 总数 64 //Capital float64 `name:"流通盘"` // 流通盘 65 //FreeCapital float64 `name:"自由流通股本"` // 自由流通股本 66 //OpenTurnZ float64 `name:"开盘换手Z%"` // 开盘换手 67 //OpenQuantityRatio float64 `name:"开盘量比"` 68 //NextOpen float64 // 仅回测有效: 下一个交易日开盘价 69 NextOpen: feature.Open, 70 //NextClose float64 // 仅回测有效: 下一个交易日收盘价 71 NextClose: feature.Close, 72 //NextHigh float64 // 仅回测有效: 下一个交易日最高价 73 NextHigh: feature.High, 74 //NextLow float64 // 仅回测有效: 下一个交易日最低价 75 NextLow: feature.Low, 76 } 77 78 if exchange.TradeSessionHasEnd(qs.Date) { 79 qs.ServerTime = "15:00:59.999" 80 qs.UpdateTime = qs.Date + " " + qs.ServerTime 81 } else { 82 now := time.Now() 83 qs.ServerTime = now.Format(exchange.CN_SERVERTIME_FORMAT) 84 qs.UpdateTime = now.Format(exchange.TimeStampMilli) 85 } 86 87 f10 := factors.GetL5F10(securityCode) 88 if f10 != nil { 89 qs.Capital = f10.Capital 90 qs.FreeCapital = f10.FreeCapital 91 qs.OpenTurnZ = f10.TurnZ(qs.OpenVolume) 92 } 93 extend := factors.GetL5History(securityCode) 94 if extend != nil && extend.MV5 > 0 { 95 qs.OpenQuantityRatio = num.ChangeRate(extend.MV5, qs.OpenVolume) 96 } 97 return qs 98 }