gitee.com/quant1x/engine@v1.8.4/factors/feature_f10_base.go (about) 1 package factors 2 3 import ( 4 "gitee.com/quant1x/engine/datasource/base" 5 "gitee.com/quant1x/gotdx/quotes" 6 "gitee.com/quant1x/gotdx/securities" 7 "gitee.com/quant1x/gox/api" 8 "gitee.com/quant1x/gox/concurrent" 9 ) 10 11 func checkoutCapital(list []quotes.XdxrInfo, date string) *quotes.XdxrInfo { 12 for _, v := range list { 13 if v.IsCapitalChange() && date >= v.Date { 14 return &v 15 } 16 } 17 return nil 18 } 19 20 type f10SecurityInfo struct { 21 TotalCapital float64 22 Capital float64 23 VolUnit int 24 DecimalPoint int 25 Name_ string 26 IpoDate string 27 SubNew bool 28 UpdateDate string 29 } 30 31 var ( 32 //__mapListingDate = map[string]string{} 33 __mapListingDate = concurrent.NewHashMap[string, string]() 34 ) 35 36 func checkoutSecurityBasicInfo(securityCode, featureDate string) f10SecurityInfo { 37 list := base.GetCacheXdxrList(securityCode) 38 api.SliceSort(list, func(a, b quotes.XdxrInfo) bool { 39 return a.Date > b.Date 40 }) 41 // 计算流通盘 42 cover := checkoutCapital(list, featureDate) 43 var f10 f10SecurityInfo 44 if cover != nil { 45 f10.TotalCapital = cover.HouZongGuBen * 10000 46 f10.Capital = cover.HouLiuTong * 10000 47 } else { 48 f10.Capital, f10.TotalCapital, f10.IpoDate, f10.UpdateDate = getFinanceInfo(securityCode, featureDate) 49 } 50 if len(f10.IpoDate) == 0 { 51 ipoDate, ok := __mapListingDate.Get(securityCode) 52 if !ok { 53 ipoDate = getIpoDate(securityCode, featureDate) 54 } 55 f10.IpoDate = ipoDate 56 if len(f10.IpoDate) > 0 { 57 __mapListingDate.Set(securityCode, f10.IpoDate) 58 } 59 } 60 if len(f10.UpdateDate) == 0 || f10.UpdateDate > featureDate { 61 f10.UpdateDate = featureDate 62 } 63 64 if len(f10.IpoDate) > 0 { 65 f10.SubNew = IsSubNewStockByIpoDate(securityCode, f10.IpoDate, featureDate) 66 } 67 68 securityInfo, found := securities.CheckoutSecurityInfo(securityCode) 69 if found { 70 f10.VolUnit = int(securityInfo.VolUnit) 71 f10.DecimalPoint = int(securityInfo.DecimalPoint) 72 f10.Name_ = securityInfo.Name 73 } else { 74 f10.VolUnit = 100 75 f10.DecimalPoint = 2 76 f10.Name_ = securities.GetStockName(securityCode) 77 } 78 79 return f10 80 }