fwquant 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. config/__init__.py +0 -0
  2. config//345/270/270/351/207/217.py +12 -0
  3. fuwen_adaptor/__init__.py +24 -0
  4. fuwen_adaptor/alpha/__init__.py +17 -0
  5. fuwen_adaptor/alpha/dataset/__init__.py +21 -0
  6. fuwen_adaptor/alpha/dataset/cs_function.py +64 -0
  7. fuwen_adaptor/alpha/dataset/datasets/__init__.py +0 -0
  8. fuwen_adaptor/alpha/dataset/datasets/alpha_101.py +330 -0
  9. fuwen_adaptor/alpha/dataset/datasets/alpha_158.py +130 -0
  10. fuwen_adaptor/alpha/dataset/math_function.py +167 -0
  11. fuwen_adaptor/alpha/dataset/processor.py +125 -0
  12. fuwen_adaptor/alpha/dataset/ta_function.py +42 -0
  13. fuwen_adaptor/alpha/dataset/template.py +305 -0
  14. fuwen_adaptor/alpha/dataset/ts_function.py +328 -0
  15. fuwen_adaptor/alpha/dataset/utility.py +192 -0
  16. fuwen_adaptor/alpha/lab.py +480 -0
  17. fuwen_adaptor/alpha/logger.py +12 -0
  18. fuwen_adaptor/alpha/model/__init__.py +6 -0
  19. fuwen_adaptor/alpha/model/models/__init__.py +0 -0
  20. fuwen_adaptor/alpha/model/models/lasso_model.py +139 -0
  21. fuwen_adaptor/alpha/model/models/lgb_model.py +170 -0
  22. fuwen_adaptor/alpha/model/models/mlp_model.py +683 -0
  23. fuwen_adaptor/alpha/model/template.py +30 -0
  24. fuwen_adaptor/alpha/strategy/__init__.py +8 -0
  25. fuwen_adaptor/alpha/strategy/backtesting.py +944 -0
  26. fuwen_adaptor/alpha/strategy/strategies/__init__.py +0 -0
  27. fuwen_adaptor/alpha/strategy/strategies/equity_demo_strategy.py +101 -0
  28. fuwen_adaptor/alpha/strategy/template.py +205 -0
  29. fuwen_adaptor/chart/__init__.py +9 -0
  30. fuwen_adaptor/chart/axis.py +44 -0
  31. fuwen_adaptor/chart/base.py +21 -0
  32. fuwen_adaptor/chart/item.py +333 -0
  33. fuwen_adaptor/chart/manager.py +170 -0
  34. fuwen_adaptor/chart/widget.py +556 -0
  35. fuwen_adaptor/event/__init__.py +8 -0
  36. fuwen_adaptor/event/engine.py +145 -0
  37. fuwen_adaptor/py.typed +0 -0
  38. fuwen_adaptor/rpc/__init__.py +8 -0
  39. fuwen_adaptor/rpc/client.py +169 -0
  40. fuwen_adaptor/rpc/common.py +10 -0
  41. fuwen_adaptor/rpc/server.py +140 -0
  42. fuwen_adaptor/trader/__init__.py +0 -0
  43. fuwen_adaptor/trader/app.py +21 -0
  44. fuwen_adaptor/trader/constant.py +160 -0
  45. fuwen_adaptor/trader/converter.py +402 -0
  46. fuwen_adaptor/trader/database.py +159 -0
  47. fuwen_adaptor/trader/datafeed.py +68 -0
  48. fuwen_adaptor/trader/engine.py +633 -0
  49. fuwen_adaptor/trader/event.py +14 -0
  50. fuwen_adaptor/trader/gateway.py +272 -0
  51. fuwen_adaptor/trader/locale/__init__.py +9 -0
  52. fuwen_adaptor/trader/locale/build_hook.py +23 -0
  53. fuwen_adaptor/trader/logger.py +55 -0
  54. fuwen_adaptor/trader/object.py +427 -0
  55. fuwen_adaptor/trader/optimize.py +250 -0
  56. fuwen_adaptor/trader/setting.py +43 -0
  57. fuwen_adaptor/trader/ui/__init__.py +12 -0
  58. fuwen_adaptor/trader/ui/ico/__init__.py +0 -0
  59. fuwen_adaptor/trader/ui/mainwindow.py +333 -0
  60. fuwen_adaptor/trader/ui/qt.py +125 -0
  61. fuwen_adaptor/trader/ui/widget.py +1292 -0
  62. fuwen_adaptor/trader/utility.py +1281 -0
  63. fuwen_ctabacktester/__init__.py +49 -0
  64. fuwen_ctabacktester/engine.py +499 -0
  65. fuwen_ctabacktester/locale/__init__.py +7 -0
  66. fuwen_ctabacktester/locale/build_hook.py +23 -0
  67. fuwen_ctabacktester/ui/__init__.py +4 -0
  68. fuwen_ctabacktester/ui/widget.py +1468 -0
  69. fuwen_ctastrategy/__init__.py +67 -0
  70. fuwen_ctastrategy/backtesting.py +1267 -0
  71. fuwen_ctastrategy/base.py +58 -0
  72. fuwen_ctastrategy/engine.py +970 -0
  73. fuwen_ctastrategy/fw_strategies/__init__.py +0 -0
  74. fuwen_ctastrategy/fw_strategies/atr_rsi_strategy.py +143 -0
  75. fuwen_ctastrategy/fw_strategies/boll_channel_strategy.py +142 -0
  76. fuwen_ctastrategy/fw_strategies/double_ma_strategy.py +117 -0
  77. fuwen_ctastrategy/fw_strategies/dual_thrust_strategy.py +149 -0
  78. fuwen_ctastrategy/fw_strategies/king_keltner_strategy.py +149 -0
  79. fuwen_ctastrategy/fw_strategies/multi_signal_strategy.py +231 -0
  80. fuwen_ctastrategy/fw_strategies/multi_timeframe_strategy.py +138 -0
  81. fuwen_ctastrategy/fw_strategies/random_strategy.py +28 -0
  82. fuwen_ctastrategy/fw_strategies/test_strategy.py +133 -0
  83. fuwen_ctastrategy/fw_strategies/turtle_signal_strategy.py +160 -0
  84. fuwen_ctastrategy/locale/__init__.py +9 -0
  85. fuwen_ctastrategy/locale/build_hook.py +23 -0
  86. fuwen_ctastrategy/template.py +496 -0
  87. fuwen_ctastrategy/ui/__init__.py +4 -0
  88. fuwen_ctastrategy/ui/rollover.py +270 -0
  89. fuwen_ctastrategy/ui/widget.py +523 -0
  90. fuwen_ctp/1.py +11 -0
  91. fuwen_ctp/__init__.py +0 -0
  92. fuwen_ctp/fw_ctp/__init__.py +35 -0
  93. fuwen_ctp/fw_ctp/api/1.py +26 -0
  94. fuwen_ctp/fw_ctp/api/__init__.py +3 -0
  95. fuwen_ctp/fw_ctp/api/ctp_constant.py +1331 -0
  96. fuwen_ctp/fw_ctp/gateway/__init__.py +4 -0
  97. fuwen_ctp/fw_ctp/gateway/ctp_gateway.py +903 -0
  98. fuwen_ctp/install.py +542 -0
  99. fuwen_ctp/setup_config.py +132 -0
  100. fuwen_datamanager/__init__.py +48 -0
  101. fuwen_datamanager/engine.py +244 -0
  102. fuwen_datamanager/ui/__init__.py +4 -0
  103. fuwen_datamanager/ui/widget.py +617 -0
  104. fuwen_frame/__init__.py +4 -0
  105. fuwen_frame/gateway/__init__.py +0 -0
  106. fuwen_frame/gateway/fuwen/__init__.py +1 -0
  107. fuwen_frame/gateway/fuwen/trader/__init__.py +0 -0
  108. fuwen_frame/gateway/fuwen/trader/engine.py +159 -0
  109. fuwen_frame/gateway/fuwen/trader/ui/__init__.py +0 -0
  110. fuwen_frame/gateway/fuwen/trader/ui/mainwindow.py +36 -0
  111. fuwen_frame/gateway/fuwen/trader/ui/widget.py +88 -0
  112. fuwen_frame/gateway/fw_ctp/__init__.py +0 -0
  113. fuwen_frame/gateway/fw_ctp/ctp_gateway.py +40 -0
  114. fuwen_frame/gateway/fw_okx/OKX/345/237/272/347/261/273/__init__.py +31 -0
  115. fuwen_frame/gateway/fw_okx/OKX/345/237/272/347/261/273/okx_gateway.py +2295 -0
  116. fuwen_frame/gateway/fw_okx/OkxGateway.py +230 -0
  117. fuwen_frame/gateway/fw_okx/__init__.py +5 -0
  118. fuwen_frame/gateway/fw_riskmanager/__init__.py +8 -0
  119. fuwen_frame/gateway/fw_riskmanager/engine.py +34 -0
  120. fuwen_frame/gateway/fw_riskmanager/ui/__init__.py +4 -0
  121. fuwen_frame/gateway/fw_riskmanager/ui/widget.py +38 -0
  122. fuwen_frame//345/205/254/345/205/261/345/272/223/__init__.py +0 -0
  123. fuwen_frame//345/205/254/345/205/261/345/272/223//346/211/223/345/215/260/346/227/245/345/277/227_/347/246/217/347/272/271/346/241/206/346/236/266.py +218 -0
  124. fuwen_frame//345/205/254/345/205/261/345/272/223//347/231/273/345/275/225/350/207/252/345/212/250/350/277/236/346/216/245.py +146 -0
  125. fuwen_frame//345/205/254/345/205/261/345/272/223//350/257/255/350/250/200/__init__.py +1 -0
  126. fuwen_frame//345/205/254/345/205/261/345/272/223//350/257/255/350/250/200/main.py +103 -0
  127. fuwen_frame//345/205/254/345/205/261/345/272/223//351/205/215/347/275/256.py +8 -0
  128. fuwen_frame//345/220/257/345/212/250/347/250/213/345/272/217/__init__.py +24 -0
  129. fuwen_frame//345/220/257/345/212/250/347/250/213/345/272/217/run.py +93 -0
  130. fuwen_frame//345/220/257/345/212/250/347/250/213/345/272/217//345/220/257/345/212/250_/347/246/217/347/272/271/347/263/273/347/273/237.py +96 -0
  131. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260/__init__.py +0 -0
  132. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260/other/__init__.py +0 -0
  133. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260/other//344/273/205/345/271/263/344/273/223.py +2136 -0
  134. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260//345/205/266/345/256/203/347/213/254/347/253/213/347/263/273/347/273/237/HSI2601_1.23.1#.py +2250 -0
  135. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260//345/205/266/345/256/203/347/213/254/347/253/213/347/263/273/347/273/237/__init__.py +0 -0
  136. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260//345/205/266/345/256/203/347/213/254/347/253/213/347/263/273/347/273/237//347/255/226/347/225/245/344/270/203/345/260/217/347/246/217/BS123A-bak.py +1233 -0
  137. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260//345/205/266/345/256/203/347/213/254/347/253/213/347/263/273/347/273/237//347/255/226/347/225/245/344/270/203/345/260/217/347/246/217/__init__.py +0 -0
  138. fuwen_frame//345/256/236/351/252/214/345/237/272/345/234/260//345/205/266/345/256/203/347/213/254/347/253/213/347/263/273/347/273/237//347/255/226/347/225/245/344/270/203/345/260/217/347/246/217//345/215/225/344/270/200/346/226/207/344/273/266.py +1254 -0
  139. fuwen_frame//345/267/245/345/205/267/__init__.py +0 -0
  140. fuwen_frame//345/267/245/345/205/267//345/257/214/351/200/224/347/211/233/347/211/233/350/216/267/345/276/227k/347/272/277_futunn_/346/234/200/347/256/200.py +25 -0
  141. fuwen_frame//345/267/245/345/205/267//345/267/262OK/346/255/243/344/275/277/347/224/250/344/270/255/347/232/204/347/211/210/346/234/254/__init__.py +0 -0
  142. fuwen_frame//345/267/245/345/205/267//345/267/262OK/346/255/243/344/275/277/347/224/250/344/270/255/347/232/204/347/211/210/346/234/254//345/257/214/351/200/224/347/211/233/347/211/233/350/216/267/345/276/227k/347/272/277_futunn.py +334 -0
  143. fuwen_frame//345/267/245/345/205/267//345/267/262OK/346/255/243/344/275/277/347/224/250/344/270/255/347/232/204/347/211/210/346/234/254//345/257/214/351/200/224/347/211/233/347/211/233/350/216/267/345/276/227k/347/272/277/345/210/260vnpy/344/270/255/345/216/273_futunn.py +528 -0
  144. fuwen_frame//345/267/245/345/205/267//350/216/267/345/217/226k/347/272/277_tushare.py +288 -0
  145. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245/__init__.py +0 -0
  146. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//344/277/241/345/217/267/346/235/245/346/272/220_/351/200/202/351/205/215/345/231/250/__init__.py +0 -0
  147. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//344/277/241/345/217/267/346/235/245/346/272/220_/351/200/202/351/205/215/345/231/250/main.py +55 -0
  148. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//345/205/254/345/205/261/345/207/275/346/225/260/__init__.py +0 -0
  149. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//345/205/254/345/205/261/345/207/275/346/225/260//345/205/254/345/205/261/345/270/270/351/207/217.py +5 -0
  150. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//345/205/254/345/205/261/345/207/275/346/225/260//345/233/236/346/265/213/344/272/244/346/230/223/350/256/260/345/275/225/345/231/250.py +784 -0
  151. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//345/237/272/347/261/273/__init__.py +0 -0
  152. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//345/237/272/347/261/273//347/255/226/347/225/245.py +333 -0
  153. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/344/270/203/347/246/217.py +817 -0
  154. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/344/270/203/347/246/217_20260407.py +430 -0
  155. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/344/270/203/347/246/217_/347/273/247/346/211/277/__init__.py +1 -0
  156. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/344/270/203/347/246/217_/347/273/247/346/211/277/main.py +194 -0
  157. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/344/270/203/347/246/217_/347/273/247/346/211/277//347/244/272/344/276/213_/344/270/203/347/246/217_/346/211/271/351/207/217/344/277/235/345/255/230.py +897 -0
  158. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/345/217/214/345/235/207/347/272/277.py +147 -0
  159. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/345/217/214/345/235/207/347/272/277_/346/226/260.py +102 -0
  160. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/345/217/214/345/235/207/347/272/277_/347/273/247/346/211/277/__init__.py +0 -0
  161. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/345/217/214/345/235/207/347/272/277_/347/273/247/346/211/277/main.py +41 -0
  162. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/345/270/270/347/224/250.py +217 -0
  163. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/346/214/207/345/256/232/346/227/266/351/227/264/344/272/244/346/230/223.py +351 -0
  164. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/346/214/207/345/256/232/346/227/266/351/227/264/344/272/244/346/230/223_bak.py +72 -0
  165. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/346/234/200/347/256/200.py +28 -0
  166. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/351/232/217/346/234/272.py +28 -0
  167. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/351/232/217/346/234/272_/347/273/247/346/211/277/__init__.py +0 -0
  168. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/244/272/344/276/213_/351/232/217/346/234/272_/347/273/247/346/211/277/main.py +39 -0
  169. fuwen_frame//346/210/221/347/232/204/347/255/226/347/225/245//347/273/274/345/220/210.py +35 -0
  170. fuwen_okx/__init__.py +29 -0
  171. fuwen_okx/okx_gateway.py +2292 -0
  172. fuwen_okx/py.typed +0 -0
  173. fuwen_rest/__init__.py +33 -0
  174. fuwen_rest/rest_client.py +355 -0
  175. fuwen_riskmanager/__init__.py +47 -0
  176. fuwen_riskmanager/base.py +7 -0
  177. fuwen_riskmanager/engine.py +252 -0
  178. fuwen_riskmanager/rules/__init__.py +0 -0
  179. fuwen_riskmanager/rules/active_order_rule.py +49 -0
  180. fuwen_riskmanager/rules/daily_limit_rule.py +121 -0
  181. fuwen_riskmanager/rules/duplicate_order_rule.py +46 -0
  182. fuwen_riskmanager/rules/order_size_rule.py +35 -0
  183. fuwen_riskmanager/rules/order_validity_rule.py +42 -0
  184. fuwen_riskmanager/template.py +103 -0
  185. fuwen_riskmanager/ui/__init__.py +4 -0
  186. fuwen_riskmanager/ui/widget.py +287 -0
  187. fuwen_signal/1.py +2 -0
  188. fuwen_signal/__init__.py +1 -0
  189. fuwen_signal/fw_signal/__init__.py +0 -0
  190. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202/__init__.py +0 -0
  191. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217/1.py +4 -0
  192. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217/__init__.py +1 -0
  193. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//344/270/203/347/246/217/345/205/245/345/217/243.py +238 -0
  194. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/205/254/345/205/261/__init__.py +0 -0
  195. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/205/254/345/205/261//345/205/254/345/205/261/345/270/270/351/207/217.py +1 -0
  196. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/205/254/345/205/261//345/205/254/347/224/250/345/207/275/346/225/260.py +276 -0
  197. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/205/254/345/205/261//350/256/241/347/256/227/351/253/230/344/275/216/347/202/271.py +293 -0
  198. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231/__init__.py +0 -0
  199. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231//345/271/263/344/273/223/344/277/241/345/217/267/346/243/200/346/265/213.py +67 -0
  200. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231//345/271/263/344/273/223/350/247/204/345/210/2311.py +97 -0
  201. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231//345/271/263/344/273/223/350/247/204/345/210/2312.py +166 -0
  202. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231//345/271/263/344/273/223/350/247/204/345/210/2313.py +188 -0
  203. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231//345/271/263/344/273/223/350/247/204/345/210/2314.py +252 -0
  204. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/271/263/344/273/223/350/247/204/345/210/231//345/271/263/344/273/223/350/247/204/345/210/2315.py +977 -0
  205. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/274/200/344/273/223/350/247/204/345/210/231/__init__.py +6 -0
  206. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//345/274/200/344/273/223/350/247/204/345/210/231//345/274/200/344/273/223/344/277/241/345/217/267/345/210/244/346/226/255.py +289 -0
  207. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//351/205/215/347/275/256/__init__.py +0 -0
  208. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//344/270/203/347/246/217//351/205/215/347/275/256//351/273/230/350/256/244.py +73 -0
  209. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//345/217/214/345/235/207/347/272/277/__init__.py +0 -0
  210. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//345/217/214/345/235/207/347/272/277/main.py +47 -0
  211. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//345/217/214/345/235/207/347/272/277//345/217/214/345/235/207/347/272/277_/346/226/260.py +56 -0
  212. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//346/250/241/346/235/277/__init__.py +0 -0
  213. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//346/250/241/346/235/277/main.py +15 -0
  214. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//351/232/217/346/234/272/1.py +56 -0
  215. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//351/232/217/346/234/272/__init__.py +0 -0
  216. fuwen_signal/fw_signal//344/277/241/345/217/267/345/267/245/345/216/202//351/232/217/346/234/272/main.py +21 -0
  217. fuwen_signal/fw_signal//345/205/254/345/205/261/345/272/223/__init__.py +4 -0
  218. fuwen_signal/fw_signal//345/205/254/345/205/261/345/272/223//346/211/223/345/215/260/346/227/245/345/277/227.py +73 -0
  219. fuwen_signal/fw_signal//345/205/254/345/205/261/345/272/223//347/246/217/347/272/271/344/277/241/345/217/267/351/200/202/351/205/215/345/231/250.py +127 -0
  220. fuwen_signal//347/244/272/344/276/213_/344/270/203/347/246/217.py +13 -0
  221. fuwen_sqlite/__init__.py +30 -0
  222. fuwen_sqlite/sqlite_database.py +484 -0
  223. fuwen_websocket/__init__.py +29 -0
  224. fuwen_websocket/websocket_client.py +188 -0
  225. fw_strategies/__init__.py +0 -0
  226. fw_strategies//345/257/274/345/205/245/347/255/226/347/225/245.py +10 -0
  227. fwquant-1.0.1.dist-info/METADATA +44 -0
  228. fwquant-1.0.1.dist-info/RECORD +231 -0
  229. fwquant-1.0.1.dist-info/WHEEL +5 -0
  230. fwquant-1.0.1.dist-info/licenses/LICENSE +21 -0
  231. fwquant-1.0.1.dist-info/top_level.txt +14 -0
config/__init__.py ADDED
File without changes
@@ -0,0 +1,12 @@
1
+ # 项目根目录(跨平台兼容)
2
+ import os
3
+
4
+ 项目根目录 = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
5
+
6
+ # 缓存目录路径
7
+ 缓存目录 = os.path.join(项目根目录, "缓存目录")
8
+ os.makedirs(缓存目录, exist_ok=True)
9
+
10
+ # 日志目录路径
11
+ 日志目录 = os.path.join(项目根目录, "日志目录")
12
+ os.makedirs(日志目录, exist_ok=True)
@@ -0,0 +1,24 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2015-present, Xiaoyou Chen
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ __version__ = "4.3.0"
@@ -0,0 +1,17 @@
1
+ from .logger import logger
2
+ from .dataset import AlphaDataset, Segment, to_datetime
3
+ from .model import AlphaModel
4
+ from .strategy import AlphaStrategy, BacktestingEngine
5
+ from .lab import AlphaLab
6
+
7
+
8
+ __all__ = [
9
+ "logger",
10
+ "AlphaDataset",
11
+ "Segment",
12
+ "to_datetime",
13
+ "AlphaModel",
14
+ "AlphaStrategy",
15
+ "BacktestingEngine",
16
+ "AlphaLab"
17
+ ]
@@ -0,0 +1,21 @@
1
+ from .template import AlphaDataset
2
+ from .utility import Segment, to_datetime
3
+ from .processor import (
4
+ process_drop_na,
5
+ process_fill_na,
6
+ process_cs_norm,
7
+ process_robust_zscore_norm,
8
+ process_cs_rank_norm
9
+ )
10
+
11
+
12
+ __all__ = [
13
+ "AlphaDataset",
14
+ "Segment",
15
+ "to_datetime",
16
+ "process_drop_na",
17
+ "process_fill_na",
18
+ "process_cs_norm",
19
+ "process_robust_zscore_norm",
20
+ "process_cs_rank_norm"
21
+ ]
@@ -0,0 +1,64 @@
1
+ """
2
+ Cross Section Operators
3
+ """
4
+
5
+ import polars as pl
6
+
7
+ from .utility import DataProxy
8
+
9
+
10
+ def cs_rank(feature: DataProxy) -> DataProxy:
11
+ """Perform cross-sectional ranking"""
12
+ df: pl.DataFrame = feature.df.select(
13
+ pl.col("datetime"),
14
+ pl.col("vt_symbol"),
15
+ pl.col("data").rank().over("datetime")
16
+ )
17
+ return DataProxy(df)
18
+
19
+
20
+ def cs_mean(feature: DataProxy) -> DataProxy:
21
+ """Calculate cross-sectional mean"""
22
+ df: pl.DataFrame = feature.df.select(
23
+ pl.col("datetime"),
24
+ pl.col("vt_symbol"),
25
+ pl.col("data").mean().over("datetime")
26
+ )
27
+ return DataProxy(df)
28
+
29
+
30
+ def cs_std(feature: DataProxy) -> DataProxy:
31
+ """Calculate cross-sectional standard deviation"""
32
+ df: pl.DataFrame = feature.df.select(
33
+ pl.col("datetime"),
34
+ pl.col("vt_symbol"),
35
+ pl.col("data").std().over("datetime")
36
+ )
37
+ return DataProxy(df)
38
+
39
+
40
+ def cs_sum(feature: DataProxy) -> DataProxy:
41
+ """Calculate cross-sectional sum"""
42
+ df: pl.DataFrame = feature.df.select(
43
+ pl.col("datetime"),
44
+ pl.col("vt_symbol"),
45
+ pl.col("data").sum().over("datetime")
46
+ )
47
+ return DataProxy(df)
48
+
49
+
50
+ def cs_scale(feature: DataProxy) -> DataProxy:
51
+ """Scale the feature by the sum of absolute values in the cross section"""
52
+ abs_feature = abs(feature)
53
+ sum_abs = cs_sum(abs_feature)
54
+
55
+ df_merged: pl.DataFrame = feature.df.join(sum_abs.df, on=["datetime", "vt_symbol"], suffix="_sum")
56
+
57
+ df: pl.DataFrame = df_merged.with_columns(
58
+ pl.when(pl.col("data_sum") != 0)
59
+ .then(pl.col("data") / pl.col("data_sum"))
60
+ .otherwise(0)
61
+ .alias("data")
62
+ ).select(["datetime", "vt_symbol", "data"])
63
+
64
+ return DataProxy(df)
File without changes
@@ -0,0 +1,330 @@
1
+ import polars as pl
2
+
3
+ from fuwen_adaptor.alpha import AlphaDataset
4
+
5
+
6
+ class Alpha101(AlphaDataset):
7
+ """101 basic factors from WorldQuant"""
8
+
9
+ def __init__(
10
+ self,
11
+ df: pl.DataFrame,
12
+ train_period: tuple[str, str],
13
+ valid_period: tuple[str, str],
14
+ test_period: tuple[str, str]
15
+ ) -> None:
16
+ """Constructor"""
17
+ super().__init__(
18
+ df=df,
19
+ train_period=train_period,
20
+ valid_period=valid_period,
21
+ test_period=test_period,
22
+ )
23
+
24
+ returns_expr: str = "(close / ts_delay(close, 1) - 1)"
25
+
26
+ # Alpha1
27
+ self.add_feature("alpha1", f"(cs_rank(ts_argmax(pow1(quesval(0, {returns_expr}, close, ts_std({returns_expr}, 20)), 2.0), 5)) - 0.5)")
28
+
29
+ # Alpha2
30
+ self.add_feature("alpha2", "(-1) * ts_corr(cs_rank(ts_delta(log(volume), 2)), cs_rank((close - open) / open), 6)")
31
+
32
+ # Alpha3
33
+ self.add_feature("alpha3", "ts_corr(cs_rank(open), cs_rank(volume), 10) * -1")
34
+
35
+ # Alpha4
36
+ self.add_feature("alpha4", "-1 * ts_rank(cs_rank(low), 9)")
37
+
38
+ # Alpha5
39
+ self.add_feature("alpha5", "cs_rank((open - (ts_sum(vwap, 10) / 10))) * (-1 * abs(cs_rank((close - vwap))))")
40
+
41
+ # Alpha6
42
+ self.add_feature("alpha6", "(-1) * ts_corr(open, volume, 10)")
43
+
44
+ # Alpha7
45
+ self.add_feature("alpha7", "quesval2(ts_mean(volume, 20), volume, (-1 * ts_rank(abs(close - ts_delay(close, 7)), 60)) * sign(ts_delta(close, 7)), -1)")
46
+
47
+ # Alpha8
48
+ self.add_feature("alpha8", f"-1 * cs_rank(((ts_sum(open, 5) * ts_sum({returns_expr}, 5)) - ts_delay((ts_sum(open, 5) * ts_sum({returns_expr}, 5)), 10)))")
49
+
50
+ # Alpha9
51
+ self.add_feature("alpha9", "quesval(0, ts_min(ts_delta(close, 1), 5), ts_delta(close, 1), quesval(0, ts_max(ts_delta(close, 1), 5), (-1 * ts_delta(close, 1)), ts_delta(close, 1)))")
52
+
53
+ # Alpha10
54
+ self.add_feature("alpha10", "cs_rank(quesval(0, ts_min(ts_delta(close, 1), 4), ts_delta(close, 1), quesval(0, ts_max(ts_delta(close, 1), 4), (-1 * ts_delta(close, 1)), ts_delta(close, 1))))")
55
+
56
+ # Alpha11
57
+ self.add_feature("alpha11", "(cs_rank(ts_max(vwap - close, 3)) + cs_rank(ts_min(vwap - close, 3))) * cs_rank(ts_delta(volume, 3))")
58
+
59
+ # Alpha12
60
+ self.add_feature("alpha12", "sign(ts_delta(volume, 1)) * (-1 * ts_delta(close, 1))")
61
+
62
+ # Alpha13
63
+ self.add_feature("alpha13", "-1 * cs_rank(ts_cov(cs_rank(close), cs_rank(volume), 5))")
64
+
65
+ # Alpha14
66
+ self.add_feature("alpha14", f"(-1 * cs_rank(({returns_expr}) - ts_delay({returns_expr}, 3))) * ts_corr(open, volume, 10)")
67
+
68
+ # Alpha15
69
+ self.add_feature("alpha15", "-1 * ts_sum(cs_rank(ts_corr(cs_rank(high), cs_rank(volume), 3)), 3)")
70
+
71
+ # Alpha16
72
+ self.add_feature("alpha16", "-1 * cs_rank(ts_cov(cs_rank(high), cs_rank(volume), 5))")
73
+
74
+ # Alpha17
75
+ self.add_feature("alpha17", "(-1 * cs_rank(ts_rank(close, 10))) * cs_rank(close - 2 * ts_delay(close, 1) + ts_delay(close, 2)) * cs_rank(ts_rank(volume / ts_mean(volume, 20), 5))")
76
+
77
+ # Alpha18
78
+ self.add_feature("alpha18", "-1 * cs_rank((ts_std(abs(close - open), 5) + (close - open)) + ts_corr(close, open, 10))")
79
+
80
+ # Alpha19
81
+ self.add_feature("alpha19", f"(-1 * sign(ts_delta(close, 7) + (close - ts_delay(close, 7)))) * (cs_rank(ts_sum({returns_expr}, 250) + 1) + 1)")
82
+
83
+ # Alpha20
84
+ self.add_feature("alpha20", "(-1 * cs_rank(open - ts_delay(high, 1))) * cs_rank(open - ts_delay(close, 1)) * cs_rank(open - ts_delay(low, 1))")
85
+
86
+ # Alpha21 (the innermost original was >=1, implemented as >1)
87
+ self.add_feature("alpha21", "quesval2((ts_mean(close, 8) + ts_std(close, 8)), ts_mean(close, 2), -1, quesval2(ts_mean(close, 2), (ts_mean(close, 8) - ts_std(close, 8)), 1, quesval(1, (volume / ts_mean(volume, 20)), 1, -1)))")
88
+
89
+ # Alpha22
90
+ self.add_feature("alpha22", "-1 * ts_delta(ts_corr(high, volume, 5), 5) * cs_rank(ts_std(close, 20))")
91
+
92
+ # Alpha23
93
+ self.add_feature("alpha23", "quesval2(ts_mean(high, 20), high, -1 * ts_delta(high, 2), 0)")
94
+
95
+ # Alpha24 (the original condition was <=0.05, implemented as <0.05)
96
+ self.add_feature("alpha24", "quesval(0.05, ts_delta(ts_sum(close, 100) / 100, 100) / ts_delay(close, 100), (-1 * ts_delta(close, 3)), (-1 * (close - ts_min(close, 100))))")
97
+
98
+ # Alpha25
99
+ self.add_feature("alpha25", f"cs_rank( (-1 * {returns_expr}) * ts_mean(volume, 20) * vwap * (high - close) )")
100
+
101
+ # Alpha26
102
+ self.add_feature("alpha26", "-1 * ts_max(ts_corr(ts_rank(volume, 5), ts_rank(high, 5), 5), 3)")
103
+
104
+ # Alpha27
105
+ self.add_feature("alpha27", "quesval(0.5, cs_rank(ts_mean(ts_corr(cs_rank(volume), cs_rank(vwap), 6), 2)), -1, 1)")
106
+
107
+ # Alpha28
108
+ self.add_feature("alpha28", "cs_scale(ts_corr(ts_mean(volume, 20), low, 5) + (high + low) / 2 - close)")
109
+
110
+ # Alpha29
111
+ self.add_feature("alpha29", f"ts_min(ts_product(cs_rank(cs_rank(cs_scale(log(ts_sum(ts_min(cs_rank(cs_rank((-1 * cs_rank(ts_delta((close - 1), 5))))), 2), 1))))), 1), 5) + ts_rank(ts_delay((-1 * {returns_expr}), 6), 5)")
112
+
113
+ # Alpha30
114
+ self.add_feature("alpha30", "((cs_rank(sign(close - ts_delay(close, 1)) + sign(ts_delay(close, 1) - ts_delay(close, 2)) + sign(ts_delay(close, 2) - ts_delay(close, 3))) * -1 + 1) * ts_sum(volume, 5)) / ts_sum(volume, 20)")
115
+
116
+ # Alpha31
117
+ self.add_feature("alpha31", "(cs_rank(cs_rank(cs_rank(ts_decay_linear((-1) * cs_rank(cs_rank(ts_delta(close, 10))), 10)))) + cs_rank((-1) * ts_delta(close, 3))) + sign(cs_scale(ts_corr(ts_mean(volume, 20), low, 12)))")
118
+
119
+ # Alpha32
120
+ self.add_feature("alpha32", "cs_scale((ts_sum(close, 7) / 7 - close)) + (20 * cs_scale(ts_corr(vwap, ts_delay(close, 5), 230)))")
121
+
122
+ # Alpha33
123
+ self.add_feature("alpha33", "cs_rank((-1) * (open / close * -1 + 1))")
124
+
125
+ # Alpha34
126
+ self.add_feature("alpha34", f"cs_rank((cs_rank(ts_std({returns_expr}, 2) / ts_std({returns_expr}, 5)) * -1 + 1) + (cs_rank(ts_delta(close, 1)) * -1 + 1))")
127
+
128
+ # Alpha35
129
+ self.add_feature("alpha35", f"(ts_rank(volume, 32) * (ts_rank((close + high - low), 16) * -1 + 1)) * (ts_rank({returns_expr}, 32) * -1 + 1)")
130
+
131
+ # Alpha36
132
+ self.add_feature("alpha36", f"((((2.21 * cs_rank(ts_corr((close - open), ts_delay(volume, 1), 15))) + (0.7 * cs_rank((open - close)))) + (0.73 * cs_rank(ts_rank(ts_delay((-1) * {returns_expr}, 6), 5)))) + cs_rank(abs(ts_corr(vwap, ts_mean(volume, 20), 6)))) + (0.6 * cs_rank(((ts_sum(close, 200) / 200 - open) * (close - open))))")
133
+
134
+ # Alpha37
135
+ self.add_feature("alpha37", "cs_rank(ts_corr(ts_delay((open - close), 1), close, 200)) + cs_rank((open - close))")
136
+
137
+ # Alpha38
138
+ self.add_feature("alpha38", "((-1) * cs_rank(ts_rank(close, 10))) * cs_rank((close / open))")
139
+
140
+ # Alpha39
141
+ self.add_feature("alpha39", f"((-1) * cs_rank((ts_delta(close, 7) * (cs_rank(ts_decay_linear((volume / ts_mean(volume, 20)), 9)) * -1 + 1)))) * (cs_rank(ts_sum({returns_expr}, 250)) + 1)")
142
+
143
+ # Alpha40
144
+ self.add_feature("alpha40", "((-1) * cs_rank(ts_std(high, 10))) * ts_corr(high, volume, 10)")
145
+
146
+ # Alpha41
147
+ self.add_feature("alpha41", "pow1((high * low), 0.5) - vwap")
148
+
149
+ # Alpha42
150
+ self.add_feature("alpha42", "cs_rank((vwap - close)) / cs_rank((vwap + close))")
151
+
152
+ # Alpha43
153
+ self.add_feature("alpha43", "ts_rank((volume / ts_mean(volume, 20)), 20) * ts_rank((-1) * ts_delta(close, 7), 8)")
154
+
155
+ # Alpha44
156
+ self.add_feature("alpha44", "(-1) * ts_corr(high, cs_rank(volume), 5)")
157
+
158
+ # Alpha45
159
+ self.add_feature("alpha45", "(-1) * cs_rank(ts_sum(ts_delay(close, 5), 20) / 20) * ts_corr(close, volume, 2) * cs_rank(ts_corr(ts_sum(close, 5), ts_sum(close, 20), 2))")
160
+
161
+ # Alpha46
162
+ self.add_feature("alpha46", "quesval(0.25, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), -1, quesval(0, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), (-1) * (close - ts_delay(close, 1)), 1))")
163
+
164
+ # Alpha47
165
+ self.add_feature("alpha47", "((cs_rank(pow1(close, -1)) * volume / ts_mean(volume, 20)) * (high * cs_rank(high - close)) / (ts_sum(high, 5) / 5)) - cs_rank(vwap - ts_delay(vwap, 5))")
166
+
167
+ # Alpha48 (contains `IndNeutralize`, currently not implemented)
168
+ # self.add_feature("alpha48", "(ts_corr(ts_delta(close, 1), ts_delta(ts_delay(close, 1), 1), 250) * ts_delta(close, 1)) / close / ts_sum(pow1((ts_delta(close, 1) / ts_delay(close, 1)), 2), 250)")
169
+
170
+ # Alpha49
171
+ self.add_feature("alpha49", "quesval(-0.1, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), (-1) * (close - ts_delay(close, 1)), 1)")
172
+
173
+ # Alpha50
174
+ self.add_feature("alpha50", "(-1) * ts_max(cs_rank(ts_corr(cs_rank(volume), cs_rank(vwap), 5)), 5)")
175
+
176
+ # Alpha51
177
+ self.add_feature("alpha51", "quesval(-0.05, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), (-1) * (close - ts_delay(close, 1)), 1)")
178
+
179
+ # Alpha52
180
+ self.add_feature("alpha52", f"(((-1) * ts_min(low, 5)) + ts_delay(ts_min(low, 5), 5)) * cs_rank((ts_sum({returns_expr}, 240) - ts_sum({returns_expr}, 20)) / 220) * ts_rank(volume, 5)")
181
+
182
+ # Alpha53
183
+ self.add_feature("alpha53", "(-1) * ts_delta(((close - low) - (high - close)) / (close - low), 9)")
184
+
185
+ # Alpha54
186
+ self.add_feature("alpha54", "((-1) * ((low - close) * pow1(open, 5))) / ((low - high) * pow1(close, 5))")
187
+
188
+ # Alpha55
189
+ self.add_feature("alpha55", "(-1) * ts_corr(cs_rank((close - ts_min(low, 12)) / (ts_max(high, 12) - ts_min(low, 12))), cs_rank(volume), 6)")
190
+
191
+ # Alpha56 (missing `cap` field, cannot be implemented)
192
+ # original formula: (0 - (1 * (rank((sum(returns, 10) / sum(sum(returns, 2), 3))) * rank((returns * cap)))))
193
+
194
+ # Alpha57
195
+ self.add_feature("alpha57", "-1 * ((close - vwap) / ts_decay_linear(cs_rank(ts_argmax(close, 30)), 2))")
196
+
197
+ # Alpha58 (contains `IndNeutralize`, currently not implemented)
198
+ # self.add_feature("alpha58", "(-1) * ts_rank(ts_decay_linear(ts_corr(vwap, volume, 4), 8), 6)")
199
+
200
+ # Alpha59 (contains `IndNeutralize`, currently not implemented)
201
+ # self.add_feature("alpha59", "(-1) * ts_rank(ts_decay_linear(ts_corr(((vwap * 0.728317) + (vwap * (1 - 0.728317))), volume, 4), 16), 8)")
202
+
203
+ # Alpha60
204
+ self.add_feature("alpha60", "- 1 * ((2 * cs_scale(cs_rank((((close - low) - (high - close)) / (high - low)) * volume))) - cs_scale(cs_rank(ts_argmax(close, 10))))")
205
+
206
+ # Alpha61
207
+ self.add_feature("alpha61", "quesval2(cs_rank(vwap - ts_min(vwap, 16)), cs_rank(ts_corr(vwap, ts_mean(volume, 180), 18)), 1, 0)")
208
+
209
+ # Alpha62
210
+ self.add_feature("alpha62", "(cs_rank(ts_corr(vwap, ts_sum(ts_mean(volume, 20), 22), 10)) < cs_rank((cs_rank(open) + cs_rank(open)) < (cs_rank((high + low) / 2) + cs_rank(high)))) * -1")
211
+
212
+ # Alpha63 (contains `IndNeutralize`, currently not implemented)
213
+ # self.add_feature("alpha63", "(cs_rank(ts_decay_linear(ts_delta(close, 2), 8)) - cs_rank(ts_decay_linear(ts_corr(vwap * 0.318108 + open * 0.681892, ts_sum(ts_mean(volume, 180), 37), 14), 12))) * -1")
214
+
215
+ # Alpha64
216
+ self.add_feature("alpha64", "(cs_rank(ts_corr(ts_sum(((open * 0.178404) + (low * (1 - 0.178404))), 13), ts_sum(ts_mean(volume, 120), 13), 17)) < cs_rank(ts_delta((((high + low) / 2 * 0.178404) + (vwap * (1 - 0.178404))), 4))) * -1")
217
+
218
+ # Alpha65
219
+ self.add_feature("alpha65", "(cs_rank(ts_corr(((open * 0.00817205) + (vwap * (1 - 0.00817205))), ts_sum(ts_mean(volume, 60), 9), 6)) < cs_rank(open - ts_min(open, 14))) * -1")
220
+
221
+ # Alpha66
222
+ self.add_feature("alpha66", "(cs_rank(ts_decay_linear(ts_delta(vwap, 4), 7)) + ts_rank(ts_decay_linear((((low * 0.96633) + (low * (1 - 0.96633))) - vwap) / (open - ((high + low) / 2)), 11), 7)) * -1")
223
+
224
+ # Alpha67 (contains `IndNeutralize`, currently not implemented)
225
+ # self.add_feature("alpha67", "pow2(cs_rank(high - ts_min(high, 2)), cs_rank(ts_corr(vwap, ts_mean(volume, 20), 6))) * -1")
226
+
227
+ # Alpha68
228
+ self.add_feature("alpha68", "(ts_rank(ts_corr(cs_rank(high), cs_rank(ts_mean(volume, 15)), 9), 14) < cs_rank(ts_delta((close * 0.518371 + low * (1 - 0.518371)), 1))) * -1")
229
+
230
+ # Alpha69 (contains `IndNeutralize`, currently not implemented)
231
+ # self.add_feature("alpha69", "pow2(cs_rank(ts_max(ts_delta(vwap, 3), 5)), ts_rank(ts_corr(close * 0.490655 + vwap * 0.509345, ts_mean(volume, 20), 5), 9)) * -1")
232
+
233
+ # Alpha70 (contains `IndNeutralize`, currently not implemented)
234
+ # self.add_feature("alpha70", "pow2(cs_rank(ts_delta(vwap, 1)), ts_rank(ts_corr(close, ts_mean(volume, 50), 18), 18)) * -1")
235
+
236
+ # Alpha71
237
+ self.add_feature("alpha71", "ts_greater(ts_rank(ts_decay_linear(ts_corr(ts_rank(close, 3), ts_rank(ts_mean(volume, 180), 12), 18), 4), 16), ts_rank(ts_decay_linear(pow1(cs_rank((low + open) - (vwap + vwap)), 2), 16), 4))")
238
+
239
+ # Alpha72
240
+ self.add_feature("alpha72", "cs_rank(ts_decay_linear(ts_corr((high + low) / 2, ts_mean(volume, 40), 9), 10)) / cs_rank(ts_decay_linear(ts_corr(ts_rank(vwap, 4), ts_rank(volume, 19), 7), 3))")
241
+
242
+ # Alpha73
243
+ self.add_feature("alpha73", "ts_greater(cs_rank(ts_decay_linear(ts_delta(vwap, 5), 3)), ts_rank(ts_decay_linear((ts_delta(open * 0.147155 + low * 0.852845, 2) / (open * 0.147155 + low * 0.852845)) * -1, 3), 17)) * -1")
244
+
245
+ # Alpha74
246
+ self.add_feature("alpha74", "quesval2(cs_rank(ts_corr(close, ts_sum(ts_mean(volume, 30), 37), 15)), cs_rank(ts_corr(cs_rank(high * 0.0261661 + vwap * 0.9738339), cs_rank(volume), 11)), 1, 0) * -1")
247
+
248
+ # Alpha75
249
+ self.add_feature("alpha75", "quesval2(cs_rank(ts_corr(vwap, volume, 4)), cs_rank(ts_corr(cs_rank(low), cs_rank(ts_mean(volume, 50)), 12)), 1, 0)")
250
+
251
+ # Alpha76 (contains `IndNeutralize`, currently not implemented)
252
+ # self.add_feature("alpha76", "ts_greater(cs_rank(ts_decay_linear(ts_delta(vwap, 1), 12)), ts_rank(ts_decay_linear(ts_rank(ts_corr(low, ts_mean(volume, 81), 8), 20), 17), 19)) * -1")
253
+
254
+ # Alpha77
255
+ self.add_feature("alpha77", "ts_less(cs_rank(ts_decay_linear((((high + low) / 2 + high) - (vwap + high)), 20)), cs_rank(ts_decay_linear(ts_corr((high + low) / 2, ts_mean(volume, 40), 3), 6)))")
256
+
257
+ # Alpha78
258
+ self.add_feature("alpha78", "pow2(cs_rank(ts_corr(ts_sum((low * 0.352233) + (vwap * (1 - 0.352233)), 20), ts_sum(ts_mean(volume, 40), 20), 7)), cs_rank(ts_corr(cs_rank(vwap), cs_rank(volume), 6)))")
259
+
260
+ # Alpha79 (contains `IndNeutralize`, currently not implemented)
261
+ # self.add_feature("alpha79", "quesval2(cs_rank(ts_delta(close * 0.60733 + open * 0.39267, 1)), cs_rank(ts_corr(ts_rank(vwap, 4), ts_rank(ts_mean(volume, 150), 9), 15)), 1, 0)")
262
+
263
+ # Alpha80 (contains `IndNeutralize`, currently not implemented)
264
+ # self.add_feature("alpha80", "pow2(cs_rank(sign(ts_delta(open * 0.868128 + high * 0.131872, 4))), ts_rank(ts_corr(high, ts_mean(volume, 10), 5), 6)) * -1")
265
+
266
+ # Alpha81
267
+ self.add_feature("alpha81", "quesval2(cs_rank(log(ts_product(cs_rank(pow1(cs_rank(ts_corr(vwap, ts_sum(ts_mean(volume, 10), 50), 8)), 4)), 15))), cs_rank(ts_corr(cs_rank(vwap), cs_rank(volume), 5)), 1, 0) * -1")
268
+
269
+ # Alpha82 (contains `IndNeutralize`, currently not implemented)
270
+ # self.add_feature("alpha82", "ts_less(cs_rank(ts_decay_linear(ts_delta(open, 1), 15)), ts_rank(ts_decay_linear(ts_corr(volume, open, 17), 7), 13)) * -1")
271
+
272
+ # Alpha83
273
+ self.add_feature("alpha83", "(cs_rank(ts_delay((high - low) / (ts_sum(close, 5) / 5), 2)) * cs_rank(cs_rank(volume))) / (((high - low) / (ts_sum(close, 5) / 5)) / (vwap - close))")
274
+
275
+ # Alpha84
276
+ self.add_feature("alpha84", "pow2(ts_rank(vwap - ts_max(vwap, 15), 21), ts_delta(close, 5))")
277
+
278
+ # Alpha85
279
+ self.add_feature("alpha85", "pow2(cs_rank(ts_corr(high * 0.876703 + close * 0.123297, ts_mean(volume, 30), 10)), cs_rank(ts_corr(ts_rank((high + low) / 2, 4), ts_rank(volume, 10), 7)))")
280
+
281
+ # Alpha86
282
+ self.add_feature("alpha86", "quesval2(ts_rank(ts_corr(close, ts_sum(ts_mean(volume, 20), 15), 6), 20), cs_rank((open + close) - (vwap + open)), 1, 0) * -1")
283
+
284
+ # Alpha87 (contains `IndNeutralize`, currently not implemented)
285
+ # self.add_feature("alpha87", "ts_greater(cs_rank(ts_decay_linear(ts_delta(close * 0.369701 + vwap * 0.630299, 2), 3)), ts_rank(ts_decay_linear(abs(ts_corr(ts_mean(volume, 81), close, 13)), 5), 14)) * -1")
286
+
287
+ # Alpha88
288
+ self.add_feature("alpha88", "ts_less(cs_rank(ts_decay_linear((cs_rank(open) + cs_rank(low)) - (cs_rank(high) + cs_rank(close)), 8)), ts_rank(ts_decay_linear(ts_corr(ts_rank(close, 8), ts_rank(ts_mean(volume, 60), 21), 8), 7), 3))")
289
+
290
+ # Alpha89 (contains `IndNeutralize`, currently not implemented)
291
+ # self.add_feature("alpha89", "(ts_rank(ts_decay_linear(ts_corr(low, ts_mean(volume, 10), 7), 6), 4) - ts_rank(ts_decay_linear(ts_delta(vwap, 3), 10), 15))")
292
+
293
+ # Alpha90 (contains `IndNeutralize`, currently not implemented)
294
+ # self.add_feature("alpha90", "pow2(cs_rank(close - ts_max(close, 5)), ts_rank(ts_corr(ts_mean(volume, 40), low, 5), 3)) * -1")
295
+
296
+ # Alpha91 (contains `IndNeutralize`, currently not implemented)
297
+ # self.add_feature("alpha91", "(ts_rank(ts_decay_linear(ts_decay_linear(ts_corr(close, volume, 10), 16), 4), 5) - cs_rank(ts_decay_linear(ts_corr(vwap, ts_mean(volume, 30), 4), 3))) * -1")
298
+
299
+ # Alpha92
300
+ self.add_feature("alpha92", "ts_less(ts_rank(ts_decay_linear(quesval2(((high + low) / 2 + close), (low + open), 1, 0), 15), 19), ts_rank(ts_decay_linear(ts_corr(cs_rank(low), cs_rank(ts_mean(volume, 30)), 8), 7), 7))")
301
+
302
+ # Alpha93 (contains `IndNeutralize`, currently not implemented)
303
+ # self.add_feature("alpha93", "ts_rank(ts_decay_linear(ts_corr(vwap, ts_mean(volume, 81), 17), 20), 8) / cs_rank(ts_decay_linear(ts_delta(close * 0.524434 + vwap * 0.475566, 3), 16))")
304
+
305
+ # Alpha94
306
+ self.add_feature("alpha94", "pow2(cs_rank(vwap - ts_min(vwap, 12)), ts_rank(ts_corr(ts_rank(vwap, 20), ts_rank(ts_mean(volume, 60), 4), 18), 3)) * -1")
307
+
308
+ # Alpha95
309
+ self.add_feature("alpha95", "quesval2(cs_rank(open - ts_min(open, 12)), ts_rank(pow1(cs_rank(ts_corr(ts_sum((high + low) / 2, 19), ts_sum(ts_mean(volume, 40), 19), 13)), 5), 12), 1, 0)")
310
+
311
+ # Alpha96
312
+ self.add_feature("alpha96", "ts_greater(ts_rank(ts_decay_linear(ts_corr(cs_rank(vwap), cs_rank(volume), 4), 4), 8), ts_rank(ts_decay_linear(ts_argmax(ts_corr(ts_rank(close, 7), ts_rank(ts_mean(volume, 60), 4), 4), 13), 14), 13)) * -1")
313
+
314
+ # Alpha97 (contains `IndNeutralize`, currently not implemented)
315
+ # self.add_feature("alpha97", "(cs_rank(ts_decay_linear(ts_delta(low * 0.721001 + vwap * 0.278999, 3), 20)) - ts_rank(ts_decay_linear(ts_rank(ts_corr(ts_rank(low, 8), ts_rank(ts_mean(volume, 60), 17), 5), 19), 16), 7)) * -1")
316
+
317
+ # Alpha98
318
+ self.add_feature("alpha98", "cs_rank(ts_decay_linear(ts_corr(vwap, ts_sum(ts_mean(volume, 5), 26), 5), 7)) - cs_rank(ts_decay_linear(ts_rank(ts_argmin(ts_corr(cs_rank(open), cs_rank(ts_mean(volume, 15)), 21), 9), 7), 8))")
319
+
320
+ # Alpha99
321
+ self.add_feature("alpha99", "quesval2(cs_rank(ts_corr(ts_sum((high + low) / 2, 20), ts_sum(ts_mean(volume, 60), 20), 9)), cs_rank(ts_corr(low, volume, 6)), 1, 0) * -1")
322
+
323
+ # Alpha100 (contains `IndNeutralize`, currently not implemented)
324
+ # self.add_feature("alpha100", "-1 * ((1.5 * cs_scale(cs_rank(((close - low) - (high - close)) / (high - low) * volume))) - cs_scale(ts_corr(close, cs_rank(ts_mean(volume, 20)), 5) - cs_rank(ts_argmin(close, 30)))) * (volume / ts_mean(volume, 20))")
325
+
326
+ # Alpha101
327
+ self.add_feature("alpha101", "((close - open) / ((high - low) + 0.001))")
328
+
329
+ # Set label
330
+ self.set_label("ts_delay(close, -3) / ts_delay(close, -1) - 1")
@@ -0,0 +1,130 @@
1
+ import polars as pl
2
+
3
+ from fuwen_adaptor.alpha import AlphaDataset
4
+
5
+
6
+ class Alpha158(AlphaDataset):
7
+ """158 basic factors from Qlib"""
8
+
9
+ def __init__(
10
+ self,
11
+ df: pl.DataFrame,
12
+ train_period: tuple[str, str],
13
+ valid_period: tuple[str, str],
14
+ test_period: tuple[str, str]
15
+ ) -> None:
16
+ """Constructor"""
17
+ super().__init__(
18
+ df=df,
19
+ train_period=train_period,
20
+ valid_period=valid_period,
21
+ test_period=test_period,
22
+ )
23
+
24
+ # Candlestick pattern features
25
+ self.add_feature("kmid", "(close - open) / open")
26
+ self.add_feature("klen", "(high - low) / open")
27
+ self.add_feature("kmid_2", "(close - open) / (high - low + 1e-12)")
28
+ self.add_feature("kup", "(high - ts_greater(open, close)) / open")
29
+ self.add_feature("kup_2", "(high - ts_greater(open, close)) / (high - low + 1e-12)")
30
+ self.add_feature("klow", "(ts_less(open, close) - low) / open")
31
+ self.add_feature("klow_2", "((ts_less(open, close) - low) / (high - low + 1e-12))")
32
+ self.add_feature("ksft", "(close * 2 - high - low) / open")
33
+ self.add_feature("ksft_2", "(close * 2 - high - low) / (high - low + 1e-12)")
34
+
35
+ # Price change features
36
+ for field in ["open", "high", "low", "vwap"]:
37
+ self.add_feature(f"{field}_0", f"{field} / close")
38
+
39
+ # Time series features
40
+ windows: list[int] = [5, 10, 20, 30, 60]
41
+
42
+ for w in windows:
43
+ self.add_feature(f"roc_{w}", f"ts_delay(close, {w}) / close")
44
+
45
+ for w in windows:
46
+ self.add_feature(f"ma_{w}", f"ts_mean(close, {w}) / close")
47
+
48
+ for w in windows:
49
+ self.add_feature(f"std_{w}", f"ts_std(close, {w}) / close")
50
+
51
+ for w in windows:
52
+ self.add_feature(f"beta_{w}", f"ts_slope(close, {w}) / close")
53
+
54
+ for w in windows:
55
+ self.add_feature(f"rsqr_{w}", f"ts_rsquare(close, {w})")
56
+
57
+ for w in windows:
58
+ self.add_feature(f"resi_{w}", f"ts_resi(close, {w}) / close")
59
+
60
+ for w in windows:
61
+ self.add_feature(f"max_{w}", f"ts_max(high, {w}) / close")
62
+
63
+ for w in windows:
64
+ self.add_feature(f"min_{w}", f"ts_min(low, {w}) / close")
65
+
66
+ for w in windows:
67
+ self.add_feature(f"qtlu_{w}", f"ts_quantile(close, {w}, 0.8) / close")
68
+
69
+ for w in windows:
70
+ self.add_feature(f"qtld_{w}", f"ts_quantile(close, {w}, 0.2) / close")
71
+
72
+ for w in windows:
73
+ self.add_feature(f"rank_{w}", f"ts_rank(close, {w})")
74
+
75
+ for w in windows:
76
+ self.add_feature(f"rsv_{w}", f"(close - ts_min(low, {w})) / (ts_max(high, {w}) - ts_min(low, {w}) + 1e-12)")
77
+
78
+ for w in windows:
79
+ self.add_feature(f"imax_{w}", f"ts_argmax(high, {w}) / {w}")
80
+
81
+ for w in windows:
82
+ self.add_feature(f"imin_{w}", f"ts_argmin(low, {w}) / {w}")
83
+
84
+ for w in windows:
85
+ self.add_feature(f"imxd_{w}", f"(ts_argmax(high, {w}) - ts_argmin(low, {w})) / {w}")
86
+
87
+ for w in windows:
88
+ self.add_feature(f"corr_{w}", f"ts_corr(close, ts_log(volume + 1), {w})")
89
+
90
+ for w in windows:
91
+ self.add_feature(f"cord_{w}", f"ts_corr(close / ts_delay(close, 1), ts_log(volume / ts_delay(volume, 1) + 1), {w})")
92
+
93
+ for w in windows:
94
+ self.add_feature(f"cntp_{w}", f"ts_mean(close > ts_delay(close, 1), {w})")
95
+
96
+ for w in windows:
97
+ self.add_feature(f"cntn_{w}", f"ts_mean(close < ts_delay(close, 1), {w})")
98
+
99
+ for w in windows:
100
+ self.add_feature(f"cntd_{w}", f"ts_mean(close > ts_delay(close, 1), {w}) - ts_mean(close < ts_delay(close, 1), {w})")
101
+
102
+ for w in windows:
103
+ self.add_feature(f"sump_{w}", f"ts_sum(ts_greater(close - ts_delay(close, 1), 0), {w}) / (ts_sum(ts_abs(close - ts_delay(close, 1)), {w}) + 1e-12)")
104
+
105
+ for w in windows:
106
+ self.add_feature(f"sumn_{w}", f"ts_sum(ts_greater(ts_delay(close, 1) - close, 0), {w}) / (ts_sum(ts_abs(close - ts_delay(close, 1)), {w}) + 1e-12)")
107
+
108
+ for w in windows:
109
+ self.add_feature(f"sumd_{w}", f"(ts_sum(ts_greater(close - ts_delay(close, 1), 0), {w}) - ts_sum(ts_greater(ts_delay(close, 1) - close, 0), {w})) / (ts_sum(ts_abs(close - ts_delay(close, 1)), {w}) + 1e-12)")
110
+
111
+ for w in windows:
112
+ self.add_feature(f"vma_{w}", f"ts_mean(volume, {w}) / (volume + 1e-12)")
113
+
114
+ for w in windows:
115
+ self.add_feature(f"vstd_{w}", f"ts_std(volume, {w}) / (volume + 1e-12)")
116
+
117
+ for w in windows:
118
+ self.add_feature(f"wvma_{w}", f"ts_std(ts_abs(close / ts_delay(close, 1) - 1) * volume, {w}) / (ts_mean(ts_abs(close / ts_delay(close, 1) - 1) * volume, {w}) + 1e-12)")
119
+
120
+ for w in windows:
121
+ self.add_feature(f"vsump_{w}", f"ts_sum(ts_greater(volume - ts_delay(volume, 1), 0), {w}) / (ts_sum(ts_abs(volume - ts_delay(volume, 1)), {w}) + 1e-12)")
122
+
123
+ for w in windows:
124
+ self.add_feature(f"vsumn_{w}", f"ts_sum(ts_greater(ts_delay(volume, 1) - volume, 0), {w}) / (ts_sum(ts_abs(volume - ts_delay(volume, 1)), {w}) + 1e-12)")
125
+
126
+ for w in windows:
127
+ self.add_feature(f"vsumd_{w}", f"(ts_sum(ts_greater(volume - ts_delay(volume, 1), 0), {w}) - ts_sum(ts_greater(ts_delay(volume, 1) - volume, 0), {w})) / (ts_sum(ts_abs(volume - ts_delay(volume, 1)), {w}) + 1e-12)")
128
+
129
+ # Set label
130
+ self.set_label("ts_delay(close, -3) / ts_delay(close, -1) - 1")