Alpha158因子构建公式

Qlib 官方原版 Alpha158 全158因子

一、K线基础因子(9)

  1. KMID = (close - open) / open

  2. KLEN = (high - low) / open

  3. KMID2 = (close - open) / (high - low)

  4. KUP = (high - Max(open, close)) / open

  5. KUP2 = (high - Max(open, close)) / (high - low)

  6. KLOW = (Min(open, close) - low) / open

  7. KLOW2 = (Min(open, close) - low) / (high - low)

  8. KSFT = (2 * close - high - low) / open

  9. KSFT2 = (2 * close - high - low) / (high - low)

二、静态价格因子(4)

  1. OPEN0 = open / close

  2. HIGH0 = high / close

  3. LOW0 = low / close

  4. VWAP0 = vwap / close(未赋权数据)

三、趋势类因子(5×5=25)

  1. ROC5 = Ref(close, 5) / close

  2. ROC10 = Ref(close, 10) / close

  3. ROC20 = Ref(close, 20) / close

  4. ROC30 = Ref(close, 30) / close

  5. ROC60 = Ref(close, 60) / close

  6. MA5 = Mean(close, 5) / close

  7. MA10 = Mean(close, 10) / close

  8. MA20 = Mean(close, 20) / close

  9. MA30 = Mean(close, 30) / close

  10. MA60 = Mean(close, 60) / close

  11. BETA5 = Slope(close, 5) / close

  12. BETA10 = Slope(close, 10) / close

  13. BETA20 = Slope(close, 20) / close

  14. BETA30 = Slope(close, 30) / close

  15. BETA60 = Slope(close, 60) / close

  16. RSQR5 = Rsquare(close, 5)

  17. RSQR10 = Rsquare(close, 10)

  18. RSQR20 = Rsquare(close, 20)

  19. RSQR30 = Rsquare(close, 30)

  20. RSQR60 = Rsquare(close, 60)

  21. RESI5 = Resi(close, 5) / close

  22. RESI10 = Resi(close, 10) / close

  23. RESI20 = Resi(close, 20) / close

  24. RESI30 = Resi(close, 30) / close

  25. RESI60 = Resi(close, 60) / close

四、波动类因子(6×5=30)

  1. STD5 = Std(close, 5) / close

  2. STD10 = Std(close, 10) / close

  3. STD20 = Std(close, 20) / close

  4. STD30 = Std(close, 30) / close

  5. STD60 = Std(close, 60) / close

  6. MAX5 = Max(high, 5) / close

  7. MAX10 = Max(high, 10) / close

  8. MAX20 = Max(high, 20) / close

  9. MAX30 = Max(high, 30) / close

  10. MAX60 = Max(high, 60) / close

  11. MIN5 = Min(low, 5) / close

  12. MIN10 = Min(low, 10) / close

  13. MIN20 = Min(low, 20) / close

  14. MIN30 = Min(low, 30) / close

  15. MIN60 = Min(low, 60) / close

  16. QTLU5 = Quantile(close, 5, 0.8) / close

  17. QTLU10 = Quantile(close, 10, 0.8) / close

  18. QTLU20 = Quantile(close, 20, 0.8) / close

  19. QTLU30 = Quantile(close, 30, 0.8) / close

  20. QTLU60 = Quantile(close, 60, 0.8) / close

  21. QTLD5 = Quantile(close, 5, 0.2) / close

  22. QTLD10 = Quantile(close, 10, 0.2) / close

  23. QTLD20 = Quantile(close, 20, 0.2) / close

  24. QTLD30 = Quantile(close, 30, 0.2) / close

  25. QTLD60 = Quantile(close, 60, 0.2) / close

  26. RSV5 = (close - Min(low, 5)) / (Max(high, 5) - Min(low, 5))

  27. RSV10 = (close - Min(low, 10)) / (Max(high, 10) - Min(low, 10))

  28. RSV20 = (close - Min(low, 20)) / (Max(high, 20) - Min(low, 20))

  29. RSV30 = (close - Min(low, 30)) / (Max(high, 30) - Min(low, 30))

  30. RSV60 = (close - Min(low, 60)) / (Max(high, 60) - Min(low, 60))

五、极值位置类因子(3×5=15)

  1. IMAX5 = IdxMax(high, 5) / 5

  2. IMAX10 = IdxMax(high, 10) / 10

  3. IMAX20 = IdxMax(high, 20) / 20

  4. IMAX30 = IdxMax(high, 30) / 30

  5. IMAX60 = IdxMax(high, 60) / 60

  6. IMIN5 = IdxMin(low, 5) / 5

  7. IMIN10 = IdxMin(low, 10) / 10

  8. IMIN20 = IdxMin(low, 20) / 20

  9. IMIN30 = IdxMin(low, 30) / 30

  10. IMIN60 = IdxMin(low, 60) / 60

  11. IMXD5 = (IdxMax(high, 5) - IdxMin(low, 5)) / 5

  12. IMXD10 = (IdxMax(high, 10) - IdxMin(low, 10)) / 10

  13. IMXD20 = (IdxMax(high, 20) - IdxMin(low, 20)) / 20

  14. IMXD30 = (IdxMax(high, 30) - IdxMin(low, 30)) / 30

  15. IMXD60 = (IdxMax(high, 60) - IdxMin(low, 60)) / 60

六、价量统计类因子(9×5=45)

  1. CORR5 = Corr(close, Log(volume+1), 5)

  2. CORR10 = Corr(close, Log(volume+1), 10)

  3. CORR20 = Corr(close, Log(volume+1), 20)

  4. CORR30 = Corr(close, Log(volume+1), 30)

  5. CORR60 = Corr(close, Log(volume+1), 60)

  6. CORD5 = Corr(close/Ref(close,1), Log(volume/Ref(volume,1)+1), 5)

  7. CORD10 = Corr(close/Ref(close,1), Log(volume/Ref(volume,1)+1), 10)

  8. CORD20 = Corr(close/Ref(close,1), Log(volume/Ref(volume,1)+1), 20)

  9. CORD30 = Corr(close/Ref(close,1), Log(volume/Ref(volume,1)+1), 30)

  10. CORD60 = Corr(close/Ref(close,1), Log(volume/Ref(volume,1)+1), 60)

  11. CNTP5 = Mean(close > Ref(close,1), 5)

  12. CNTP10 = Mean(close > Ref(close,1), 10)

  13. CNTP20 = Mean(close > Ref(close,1), 20)

  14. CNTP30 = Mean(close > Ref(close,1), 30)

  15. CNTP60 = Mean(close > Ref(close,1), 60)

  16. CNTN5 = Mean(close < Ref(close,1), 5)

  17. CNTN10 = Mean(close < Ref(close,1), 10)

  18. CNTN20 = Mean(close < Ref(close,1), 20)

  19. CNTN30 = Mean(close < Ref(close,1), 30)

  20. CNTN60 = Mean(close < Ref(close,1), 60)

  21. CNTD5 = Mean(close>Ref(close,1),5) - Mean(close<Ref(close,1),5)

  22. CNTD10 = Mean(close>Ref(close,1),10) - Mean(close<Ref(close,1),10)

  23. CNTD20 = Mean(close>Ref(close,1),20) - Mean(close<Ref(close,1),20)

  24. CNTD30 = Mean(close>Ref(close,1),30) - Mean(close<Ref(close,1),30)

  25. CNTD60 = Mean(close>Ref(close,1),60) - Mean(close<Ref(close,1),60)

  26. SUMP5 = Sum(Max(close-Ref(close,1),0),5) / Sum(Abs(close-Ref(close,1)),5)

  27. SUMP10 = Sum(Max(close-Ref(close,1),0),10) / Sum(Abs(close-Ref(close,1)),10)

  28. SUMP20 = Sum(Max(close-Ref(close,1),0),20) / Sum(Abs(close-Ref(close,1)),20)

  29. SUMP30 = Sum(Max(close-Ref(close,1),0),30) / Sum(Abs(close-Ref(close,1)),30)

  30. SUMP60 = Sum(Max(close-Ref(close,1),0),60) / Sum(Abs(close-Ref(close,1)),60)

  31. SUMN5 = Sum(Max(Ref(close,1)-close,0),5) / Sum(Abs(close-Ref(close,1)),5)

  32. SUMN10 = Sum(Max(Ref(close,1)-close,0),10) / Sum(Abs(close-Ref(close,1)),10)

  33. SUMN20 = Sum(Max(Ref(close,1)-close,0),20) / Sum(Abs(close-Ref(close,1)),20)

  34. SUMN30 = Sum(Max(Ref(close,1)-close,0),30) / Sum(Abs(close-Ref(close,1)),30)

  35. SUMN60 = Sum(Max(Ref(close,1)-close,0),60) / Sum(Abs(close-Ref(close,1)),60)

  36. SUMD5 = (Sum(Max(close-Ref(close,1),0),5) - Sum(Max(Ref(close,1)-close,0),5)) / Sum(Abs(close-Ref(close,1)),5)

  37. SUMD10 = (Sum(Max(close-Ref(close,1),0),10) - Sum(Max(Ref(close,1)-close,0),10)) / Sum(Abs(close-Ref(close,1)),10)

  38. SUMD20 = (Sum(Max(close-Ref(close,1),0),20) - Sum(Max(Ref(close,1)-close,0),20)) / Sum(Abs(close-Ref(close,1)),20)

  39. SUMD30 = (Sum(Max(close-Ref(close,1),0),30) - Sum(Max(Ref(close,1)-close,0),30)) / Sum(Abs(close-Ref(close,1)),30)

  40. SUMD60 = (Sum(Max(close-Ref(close,1),0),60) - Sum(Max(Ref(close,1)-close,0),60)) / Sum(Abs(close-Ref(close,1)),60)

  41. RANK5 = Rank(close ,5)

  42. RANK10 = Rank(close ,10)

  43. RANK20 = Rank(close ,20)

  44. RANK30 = Rank(close ,30)

  45. RANK60 = Rank(close ,60)

七、成交量波动类因子(2×5=10)

  1. VMA5 = Mean(volume, 5) / volume

  2. VMA10 = Mean(volume, 10) / volume

  3. VMA20 = Mean(volume, 20) / volume

  4. VMA30 = Mean(volume, 30) / volume

  5. VMA60 = Mean(volume, 60) / volume

  6. VSTD5 = Std(volume, 5) / volume

  7. VSTD10 = Std(volume, 10) / volume

  8. VSTD20 = Std(volume, 20) / volume

  9. VSTD30 = Std(volume, 30) / volume

  10. VSTD60 = Std(volume, 60) / volume

八、量价加权统计因子(4×5=20)

  1. WVMA5 = Std(Abs(close/Ref(close,1)-1)*volume,5) / Mean(Abs(close/Ref(close,1)-1)*volume,5)

  2. WVMA10 = Std(Abs(close/Ref(close,1)-1)*volume,10) / Mean(Abs(close/Ref(close,1)-1)*volume,10)

  3. WVMA20 = Std(Abs(close/Ref(close,1)-1)*volume,20) / Mean(Abs(close/Ref(close,1)-1)*volume,20)

  4. WVMA30 = Std(Abs(close/Ref(close,1)-1)*volume,30) / Mean(Abs(close/Ref(close,1)-1)*volume,30)

  5. WVMA60 = Std(Abs(close/Ref(close,1)-1)*volume,60) / Mean(Abs(close/Ref(close,1)-1)*volume,60)

  6. VSUMP5 = Sum(Max(volume-Ref(volume,1),0),5) / Sum(Abs(volume-Ref(volume,1)),5)

  7. VSUMP10 = Sum(Max(volume-Ref(volume,1),0),10) / Sum(Abs(volume-Ref(volume,1)),10)

  8. VSUMP20 = Sum(Max(volume-Ref(volume,1),0),20) / Sum(Abs(volume-Ref(volume,1)),20)

  9. VSUMP30 = Sum(Max(volume-Ref(volume,1),0),30) / Sum(Abs(volume-Ref(volume,1)),30)

  10. VSUMP60 = Sum(Max(volume-Ref(volume,1),0),60) / Sum(Abs(volume-Ref(volume,1)),60)

  11. VSUMN5 = Sum(Max(Ref(volume,1)-volume,0),5) / Sum(Abs(volume-Ref(volume,1)),5)

  12. VSUMN10 = Sum(Max(Ref(volume,1)-volume,0),10) / Sum(Abs(volume-Ref(volume,1)),10)

  13. VSUMN20 = Sum(Max(Ref(volume,1)-volume,0),20) / Sum(Abs(volume-Ref(volume,1)),20)

  14. VSUMN30 = Sum(Max(Ref(volume,1)-volume,0),30) / Sum(Abs(volume-Ref(volume,1)),30)

  15. VSUMN60 = Sum(Max(Ref(volume,1)-volume,0),60) / Sum(Abs(volume-Ref(volume,1)),60)

  16. VSUMD5 = (Sum(Max(volume-Ref(volume,1),0),5) - Sum(Max(Ref(volume,1)-volume,0),5)) / Sum(Abs(volume-Ref(volume,1)),5)

  17. VSUMD10 = (Sum(Max(volume-Ref(volume,1),0),10) - Sum(Max(Ref(volume,1)-volume,0),10)) / Sum(Abs(volume-Ref(volume,1)),10)

  18. VSUMD20 = (Sum(Max(volume-Ref(volume,1),0),20) - Sum(Max(Ref(volume,1)-volume,0),20)) / Sum(Abs(volume-Ref(volume,1)),20)

  19. VSUMD30 = (Sum(Max(volume-Ref(volume,1),0),30) - Sum(Max(Ref(volume,1)-volume,0),30)) / Sum(Abs(volume-Ref(volume,1)),30)

  20. VSUMD60 = (Sum(Max(volume-Ref(volume,1),0),60) - Sum(Max(Ref(volume,1)-volume,0),60)) / Sum(Abs(volume-Ref(volume,1)),60)


完整因子加工源码:


BigQuant CodeShare