gitee.com/quant1x/engine@v1.8.4/tracker/mod_sort.go (about) 1 package tracker 2 3 import ( 4 "gitee.com/quant1x/engine/factors" 5 "gitee.com/quant1x/num" 6 ) 7 8 func tickWeight(snapshot factors.QuoteSnapshot) float64 { 9 // 1. 板块涨幅 10 weight1 := snapshot.ChangeRate 11 // 2. 涨速 12 weight2 := snapshot.Rate 13 14 return num.Mean([]float64{weight1, weight2}) 15 } 16 17 // SectorSortForTick 板块排序, 盘中 18 func SectorSortForTick(a, b factors.QuoteSnapshot) bool { 19 aWeight := tickWeight(a) 20 bWeight := tickWeight(b) 21 return aWeight > bWeight 22 } 23 24 // SectorSortForHead 板块排序, 早盘 25 func SectorSortForHead(a, b factors.QuoteSnapshot) bool { 26 if a.OpeningChangeRate > b.OpeningChangeRate { 27 return true 28 } 29 if a.OpeningChangeRate == b.OpeningChangeRate && a.Amount > b.Amount { 30 return true 31 } 32 if a.OpeningChangeRate == b.OpeningChangeRate && a.Amount == b.Amount && a.OpenTurnZ > b.OpenTurnZ { 33 return true 34 } 35 return false 36 } 37 38 // StockSort 个股排序 39 func StockSort(a, b factors.QuoteSnapshot) bool { 40 if a.ChangeRate > b.ChangeRate { 41 return true 42 } 43 if a.ChangeRate == b.ChangeRate && a.OpenTurnZ > b.OpenTurnZ { 44 return true 45 } 46 return false 47 }