model.go 959 B

12345678910111213141516171819202122232425262728293031323334
  1. package factor_edb_series
  2. // FactorEdbSeriesCorrelationMatrixValues 因子指标系列-相关性矩阵XY值
  3. type FactorEdbSeriesCorrelationMatrixValues struct {
  4. XData int `description:"X轴数据"`
  5. YData float64 `description:"Y轴数据"`
  6. }
  7. // FactorEdbSeriesCorrelationMatrixOrder 排序规则[0 1 2 3 -1 -2 -3]
  8. type FactorEdbSeriesCorrelationMatrixOrder []FactorEdbSeriesCorrelationMatrixValues
  9. func (a FactorEdbSeriesCorrelationMatrixOrder) Len() int {
  10. return len(a)
  11. }
  12. func (a FactorEdbSeriesCorrelationMatrixOrder) Swap(i, j int) {
  13. a[i], a[j] = a[j], a[i]
  14. }
  15. func (a FactorEdbSeriesCorrelationMatrixOrder) Less(i, j int) bool {
  16. // 非负数优先
  17. if a[i].XData >= 0 && a[j].XData < 0 {
  18. return true
  19. }
  20. if a[i].XData < 0 && a[j].XData >= 0 {
  21. return false
  22. }
  23. // 非负数升序排序
  24. if a[i].XData >= 0 {
  25. return a[i].XData < a[j].XData
  26. }
  27. // 负数按绝对值的降序排序(即数值的升序)
  28. return a[i].XData > a[j].XData
  29. }