gitee.com/quant1x/engine@v1.8.4/factors/feature_f10_shareholder.go (about)

     1  package factors
     2  
     3  import (
     4  	"gitee.com/quant1x/engine/datasource/base"
     5  	"gitee.com/quant1x/engine/datasource/dfcf"
     6  	"gitee.com/quant1x/exchange"
     7  	"gitee.com/quant1x/gotdx/quotes"
     8  	"gitee.com/quant1x/gox/api"
     9  )
    10  
    11  type top10ShareHolder struct {
    12  	Code           string
    13  	FreeCapital    float64
    14  	Top10Capital   float64
    15  	Top10Change    float64
    16  	ChangeCapital  float64
    17  	IncreaseRatio  float64
    18  	ReductionRatio float64
    19  }
    20  
    21  func checkoutShareHolder(securityCode, featureDate string) *top10ShareHolder {
    22  	xdxrs := base.GetCacheXdxrList(securityCode)
    23  	api.SliceSort(xdxrs, func(a, b quotes.XdxrInfo) bool {
    24  		return a.Date > b.Date
    25  	})
    26  	xdxrInfo := checkoutCapital(xdxrs, featureDate)
    27  	if xdxrInfo != nil && exchange.AssertStockBySecurityCode(securityCode) {
    28  		list := dfcf.GetCacheShareHolder(securityCode, featureDate)
    29  		capital := xdxrInfo.HouLiuTong * 10000
    30  		totalCapital := xdxrInfo.HouZongGuBen * 10000
    31  		top10Capital, freeCapital, capitalChanged, increaseRatio, reductionRatio := ComputeFreeCapital(list, capital)
    32  		if freeCapital < 0 {
    33  			top10Capital, freeCapital, capitalChanged, increaseRatio, reductionRatio = ComputeFreeCapital(list, totalCapital)
    34  		}
    35  		frontList := dfcf.GetCacheShareHolder(securityCode, featureDate, 2)
    36  		frontTop10Capital, _, _, _, _ := ComputeFreeCapital(frontList, totalCapital)
    37  		shareHolder := top10ShareHolder{
    38  			Code:           securityCode,
    39  			FreeCapital:    freeCapital,
    40  			Top10Capital:   top10Capital,
    41  			Top10Change:    top10Capital - frontTop10Capital,
    42  			ChangeCapital:  capitalChanged,
    43  			IncreaseRatio:  increaseRatio,
    44  			ReductionRatio: reductionRatio,
    45  		}
    46  		return &shareHolder
    47  	}
    48  	return nil
    49  }