cnhkmcp 2.1.3__py3-none-any.whl → 2.1.5__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 (194) hide show
  1. cnhkmcp/__init__.py +126 -0
  2. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/README.md +38 -0
  3. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/ace.log +0 -0
  4. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/config.json +6 -0
  5. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/ace_lib.py +1514 -0
  6. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/fetch_all_datasets.py +157 -0
  7. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/fetch_all_documentation.py +132 -0
  8. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/fetch_all_operators.py +99 -0
  9. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/helpful_functions.py +180 -0
  10. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/icon.ico +0 -0
  11. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/icon.png +0 -0
  12. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001_10_Steps_to_Start_on_BRAIN_documentation.json +14 -0
  13. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001_Intermediate_Pack_-_Improve_your_Alpha_2_2_documentation.json +174 -0
  14. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001_Intermediate_Pack_-_Understand_Results_1_2_documentation.json +167 -0
  15. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001_Introduction_to_Alphas_documentation.json +145 -0
  16. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001_Introduction_to_BRAIN_Expression_Language_documentation.json +107 -0
  17. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001_WorldQuant_Challenge_documentation.json +56 -0
  18. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/001__Read_this_First_-_Starter_Pack_documentation.json +404 -0
  19. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/002_How_to_choose_the_Simulation_Settings_documentation.json +268 -0
  20. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/002_Simulate_your_first_Alpha_documentation.json +88 -0
  21. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/002__Alpha_Examples_for_Beginners_documentation.json +254 -0
  22. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/002__Alpha_Examples_for_Bronze_Users_documentation.json +114 -0
  23. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/002__Alpha_Examples_for_Silver_Users_documentation.json +79 -0
  24. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/002__How_BRAIN_works_documentation.json +184 -0
  25. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/003_Clear_these_tests_before_submitting_an_Alpha_documentation.json +388 -0
  26. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/003_Parameters_in_the_Simulation_results_documentation.json +243 -0
  27. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/004_Group_Data_Fields_documentation.json +69 -0
  28. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/004_How_to_use_the_Data_Explorer_documentation.json +142 -0
  29. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/004_Model77_dataset_documentation.json +14 -0
  30. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/004_Sentiment1_dataset_documentation.json +14 -0
  31. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/004_Understanding_Data_in_BRAIN_Key_Concepts_and_Tips_documentation.json +182 -0
  32. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/004_Vector_Data_Fields_documentation.json +30 -0
  33. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Crowding_Risk-Neutralized_Alphas_documentation.json +64 -0
  34. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_D0_documentation.json +66 -0
  35. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Double_Neutralization_documentation.json +53 -0
  36. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Fast_D1_Documentation_documentation.json +304 -0
  37. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Investability_Constrained_Metrics_documentation.json +129 -0
  38. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Must-read_posts_How_to_improve_your_Alphas_documentation.json +14 -0
  39. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Neutralization_documentation.json +29 -0
  40. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_RAM_Risk-Neutralized_Alphas_documentation.json +64 -0
  41. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Risk_Neutralization_Default_setting_documentation.json +75 -0
  42. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Risk_Neutralized_Alphas_documentation.json +171 -0
  43. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/005_Statistical_Risk-Neutralized_Alphas_documentation.json +51 -0
  44. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_EUR_TOP2500_Universe_documentation.json +35 -0
  45. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_GLB_TOPDIV3000_Universe_documentation.json +48 -0
  46. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_Getting_Started_China_Research_for_Consultants_Gold_documentation.json +142 -0
  47. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_Getting_started_on_Illiquid_Universes_Gold_documentation.json +46 -0
  48. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_Getting_started_with_USA_TOPSP500_universe_Gold_documentation.json +62 -0
  49. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_Global_Alphas_Gold_documentation.json +66 -0
  50. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/006_India_Alphas_documentation.json +35 -0
  51. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Consultant_Dos_and_Don_ts_documentation.json +35 -0
  52. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Consultant_Features_documentation.json +239 -0
  53. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Consultant_Simulation_Features_documentation.json +149 -0
  54. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Consultant_Submission_Tests_documentation.json +363 -0
  55. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Finding_Consultant_Alphas_documentation.json +333 -0
  56. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Power_Pool_Alphas_documentation.json +14 -0
  57. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Research_Advisory_Program_documentation.json +35 -0
  58. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Starting_Guide_for_Research_Consultants_documentation.json +14 -0
  59. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Visualization_Tool_documentation.json +99 -0
  60. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007_Your_Advisor_-_Kunqi_Jiang_documentation.json +53 -0
  61. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007__Brain_Genius_documentation.json +288 -0
  62. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/007__Single_Dataset_Alphas_documentation.json +41 -0
  63. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/008_Advisory_Theme_Calendar_documentation.json +14 -0
  64. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/008_Multiplier_Rules_documentation.json +14 -0
  65. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/008_Overview_of_Themes_documentation.json +14 -0
  66. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/008_Theme_Calendar_documentation.json +14 -0
  67. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_Combo_Expression_documentation.json +272 -0
  68. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_Global_SuperAlphas_documentation.json +14 -0
  69. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_Helpful_Tips_documentation.json +58 -0
  70. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_Selection_Expression_documentation.json +1546 -0
  71. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_SuperAlpha_Operators_documentation.json +890 -0
  72. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_SuperAlpha_Results_documentation.json +83 -0
  73. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/009_What_is_a_SuperAlpha_documentation.json +261 -0
  74. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/010_BRAIN_API_documentation.json +515 -0
  75. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/010_Documentation_for_ACE_API_Library_Gold_documentation.json +27 -0
  76. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/010__Understanding_simulation_limits_documentation.json +210 -0
  77. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/arithmetic_operators.json +209 -0
  78. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/cross_sectional_operators.json +98 -0
  79. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/group_operators.json +121 -0
  80. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/logical_operators.json +145 -0
  81. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/reduce_operators.json +156 -0
  82. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/special_operators.json +35 -0
  83. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/test.txt +1 -0
  84. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/time_series_operators.json +386 -0
  85. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/transformational_operators.json +61 -0
  86. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/vector_operators.json +38 -0
  87. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/main.py +576 -0
  88. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/process_knowledge_base.py +281 -0
  89. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/rag_engine.py +408 -0
  90. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/requirements.txt +7 -0
  91. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/run.bat +3 -0
  92. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/vector_db/_manifest.json +302 -0
  93. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/vector_db/_meta.json +1 -0
  94. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/vector_db/chroma.sqlite3 +0 -0
  95. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242//321/211/320/266/320/246/321/206/320/274/320/261/321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/231/320/243/321/205/342/225/235/320/220/321/206/320/230/320/241.py +265 -0
  96. cnhkmcp/untracked/APP/.gitignore +32 -0
  97. cnhkmcp/untracked/APP/MODULAR_STRUCTURE.md +112 -0
  98. cnhkmcp/untracked/APP/README.md +309 -0
  99. cnhkmcp/untracked/APP/Tranformer/Transformer.py +4989 -0
  100. cnhkmcp/untracked/APP/Tranformer/ace.log +0 -0
  101. cnhkmcp/untracked/APP/Tranformer/ace_lib.py +1514 -0
  102. cnhkmcp/untracked/APP/Tranformer/helpful_functions.py +180 -0
  103. cnhkmcp/untracked/APP/Tranformer/output/Alpha_candidates.json +7187 -0
  104. cnhkmcp/untracked/APP/Tranformer/output/Alpha_candidates_/321/207/320/264/342/225/221/321/204/342/225/233/320/233.json +654 -0
  105. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_error.json +1 -0
  106. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_success.json +47312 -0
  107. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_/321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/320/237/320/277/321/207/320/253/342/224/244/321/206/320/236/320/265/321/210/342/225/234/342/225/234/321/205/320/225/320/265Machine_lib.json +22 -0
  108. cnhkmcp/untracked/APP/Tranformer/parsetab.py +60 -0
  109. cnhkmcp/untracked/APP/Tranformer/template_summary.txt +3182 -0
  110. cnhkmcp/untracked/APP/Tranformer/transformer_config.json +7 -0
  111. cnhkmcp/untracked/APP/Tranformer/validator.py +889 -0
  112. cnhkmcp/untracked/APP/ace.log +69 -0
  113. cnhkmcp/untracked/APP/ace_lib.py +1514 -0
  114. cnhkmcp/untracked/APP/blueprints/__init__.py +6 -0
  115. cnhkmcp/untracked/APP/blueprints/feature_engineering.py +347 -0
  116. cnhkmcp/untracked/APP/blueprints/idea_house.py +221 -0
  117. cnhkmcp/untracked/APP/blueprints/inspiration_house.py +432 -0
  118. cnhkmcp/untracked/APP/blueprints/paper_analysis.py +570 -0
  119. cnhkmcp/untracked/APP/custom_templates/templates.json +1257 -0
  120. cnhkmcp/untracked/APP/give_me_idea/BRAIN_Alpha_Template_Expert_SystemPrompt.md +400 -0
  121. cnhkmcp/untracked/APP/give_me_idea/ace_lib.py +1514 -0
  122. cnhkmcp/untracked/APP/give_me_idea/alpha_data_specific_template_master.py +252 -0
  123. cnhkmcp/untracked/APP/give_me_idea/fetch_all_datasets.py +157 -0
  124. cnhkmcp/untracked/APP/give_me_idea/fetch_all_operators.py +99 -0
  125. cnhkmcp/untracked/APP/give_me_idea/helpful_functions.py +180 -0
  126. cnhkmcp/untracked/APP/give_me_idea/what_is_Alpha_template.md +11 -0
  127. cnhkmcp/untracked/APP/helpful_functions.py +180 -0
  128. cnhkmcp/untracked/APP/hkSimulator/ace_lib.py +1501 -0
  129. cnhkmcp/untracked/APP/hkSimulator/autosimulator.py +447 -0
  130. cnhkmcp/untracked/APP/hkSimulator/helpful_functions.py +180 -0
  131. cnhkmcp/untracked/APP/mirror_config.txt +20 -0
  132. cnhkmcp/untracked/APP/operaters.csv +129 -0
  133. cnhkmcp/untracked/APP/requirements.txt +53 -0
  134. cnhkmcp/untracked/APP/run_app.bat +28 -0
  135. cnhkmcp/untracked/APP/run_app.sh +34 -0
  136. cnhkmcp/untracked/APP/setup_tsinghua.bat +39 -0
  137. cnhkmcp/untracked/APP/setup_tsinghua.sh +43 -0
  138. cnhkmcp/untracked/APP/simulator/alpha_submitter.py +404 -0
  139. cnhkmcp/untracked/APP/simulator/simulator_wqb.py +618 -0
  140. cnhkmcp/untracked/APP/ssrn-3332513.pdf +109188 -19
  141. cnhkmcp/untracked/APP/static/brain.js +589 -0
  142. cnhkmcp/untracked/APP/static/decoder.js +1540 -0
  143. cnhkmcp/untracked/APP/static/feature_engineering.js +1729 -0
  144. cnhkmcp/untracked/APP/static/idea_house.js +937 -0
  145. cnhkmcp/untracked/APP/static/inspiration.js +465 -0
  146. cnhkmcp/untracked/APP/static/inspiration_house.js +868 -0
  147. cnhkmcp/untracked/APP/static/paper_analysis.js +390 -0
  148. cnhkmcp/untracked/APP/static/script.js +3082 -0
  149. cnhkmcp/untracked/APP/static/simulator.js +597 -0
  150. cnhkmcp/untracked/APP/static/styles.css +3127 -0
  151. cnhkmcp/untracked/APP/static/usage_widget.js +508 -0
  152. cnhkmcp/untracked/APP/templates/alpha_inspector.html +511 -0
  153. cnhkmcp/untracked/APP/templates/feature_engineering.html +960 -0
  154. cnhkmcp/untracked/APP/templates/idea_house.html +564 -0
  155. cnhkmcp/untracked/APP/templates/index.html +932 -0
  156. cnhkmcp/untracked/APP/templates/inspiration_house.html +861 -0
  157. cnhkmcp/untracked/APP/templates/paper_analysis.html +91 -0
  158. cnhkmcp/untracked/APP/templates/simulator.html +343 -0
  159. cnhkmcp/untracked/APP/templates/transformer_web.html +580 -0
  160. cnhkmcp/untracked/APP/usage.md +351 -0
  161. cnhkmcp/untracked/APP//321/207/342/225/235/320/250/321/205/320/230/320/226/321/204/342/225/225/320/220/321/211/320/221/320/243/321/206/320/261/320/265/ace_lib.py +1514 -0
  162. cnhkmcp/untracked/APP//321/207/342/225/235/320/250/321/205/320/230/320/226/321/204/342/225/225/320/220/321/211/320/221/320/243/321/206/320/261/320/265/brain_alpha_inspector.py +712 -0
  163. cnhkmcp/untracked/APP//321/207/342/225/235/320/250/321/205/320/230/320/226/321/204/342/225/225/320/220/321/211/320/221/320/243/321/206/320/261/320/265/helpful_functions.py +180 -0
  164. cnhkmcp/untracked/APP//321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/231/320/243/321/205/342/225/235/320/220/321/206/320/230/320/241.py +2460 -0
  165. cnhkmcp/untracked/__init__.py +0 -0
  166. cnhkmcp/untracked/arXiv_API_Tool_Manual.md +490 -0
  167. cnhkmcp/untracked/arxiv_api.py +229 -0
  168. cnhkmcp/untracked/back_up/forum_functions.py +998 -0
  169. cnhkmcp/untracked/back_up/platform_functions.py +2886 -0
  170. cnhkmcp/untracked/brain-consultant.md +31 -0
  171. cnhkmcp/untracked/forum_functions.py +407 -0
  172. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272/forum_functions.py +407 -0
  173. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272/platform_functions.py +2601 -0
  174. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272/user_config.json +31 -0
  175. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272//321/210/320/276/320/271AI/321/210/320/277/342/225/227/321/210/342/224/220/320/251/321/204/342/225/225/320/272/321/206/320/246/320/227/321/206/320/261/320/263/321/206/320/255/320/265/321/205/320/275/320/266/321/204/342/225/235/320/252/321/204/342/225/225/320/233/321/210/342/225/234/342/225/234/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270.md +101 -0
  176. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272//321/211/320/225/320/235/321/207/342/225/234/320/276/321/205/320/231/320/235/321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/230/320/241_/321/205/320/276/320/231/321/210/320/263/320/225/321/205/342/224/220/320/225/321/210/320/266/320/221/321/204/342/225/233/320/255/321/210/342/225/241/320/246/321/205/320/234/320/225.py +190 -0
  177. cnhkmcp/untracked/platform_functions.py +2601 -0
  178. cnhkmcp/untracked/sample_mcp_config.json +11 -0
  179. cnhkmcp/untracked/user_config.json +31 -0
  180. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/320/237/320/222/321/210/320/220/320/223/321/206/320/246/320/227/321/206/320/261/320/263_BRAIN_Alpha_Test_Requirements_and_Tips.md +202 -0
  181. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_Alpha_explaination_workflow.md +56 -0
  182. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_BRAIN_6_Tips_Datafield_Exploration_Guide.md +194 -0
  183. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_BRAIN_Alpha_Improvement_Workflow.md +101 -0
  184. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_Dataset_Exploration_Expert_Manual.md +436 -0
  185. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_daily_report_workflow.md +128 -0
  186. cnhkmcp/untracked//321/211/320/225/320/235/321/207/342/225/234/320/276/321/205/320/231/320/235/321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/230/320/241_/321/205/320/276/320/231/321/210/320/263/320/225/321/205/342/224/220/320/225/321/210/320/266/320/221/321/204/342/225/233/320/255/321/210/342/225/241/320/246/321/205/320/234/320/225.py +192 -0
  187. {cnhkmcp-2.1.3.dist-info → cnhkmcp-2.1.5.dist-info}/METADATA +1 -1
  188. cnhkmcp-2.1.5.dist-info/RECORD +192 -0
  189. cnhkmcp-2.1.5.dist-info/top_level.txt +1 -0
  190. cnhkmcp-2.1.3.dist-info/RECORD +0 -6
  191. cnhkmcp-2.1.3.dist-info/top_level.txt +0 -1
  192. {cnhkmcp-2.1.3.dist-info → cnhkmcp-2.1.5.dist-info}/WHEEL +0 -0
  193. {cnhkmcp-2.1.3.dist-info → cnhkmcp-2.1.5.dist-info}/entry_points.txt +0 -0
  194. {cnhkmcp-2.1.3.dist-info → cnhkmcp-2.1.5.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,157 @@
1
+ import getpass
2
+ import json
3
+ import os
4
+ import sys
5
+ from typing import List
6
+
7
+ import pandas as pd
8
+
9
+ # Ensure we can import ace_lib from the project root
10
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
11
+ ROOT_DIR = os.path.dirname(SCRIPT_DIR)
12
+ if ROOT_DIR not in sys.path:
13
+ sys.path.append(ROOT_DIR)
14
+
15
+ import ace_lib # noqa: E402
16
+
17
+
18
+ def prompt_credentials() -> tuple[str, str]:
19
+ """Prompt user for platform credentials."""
20
+ email = input("Enter BRAIN Email: ").strip()
21
+ while not email:
22
+ email = input("Email is required. Enter BRAIN Email: ").strip()
23
+
24
+ password = getpass.getpass("Enter BRAIN Password: ").strip()
25
+ while not password:
26
+ password = getpass.getpass("Password is required. Enter BRAIN Password: ").strip()
27
+
28
+ return email, password
29
+
30
+
31
+ def fetch_all_combinations(session: ace_lib.SingleSession) -> pd.DataFrame:
32
+ """Return all valid instrument/region/delay/universe combos from platform settings."""
33
+ options_df = ace_lib.get_instrument_type_region_delay(session)
34
+ if options_df is None or options_df.empty:
35
+ raise RuntimeError("No simulation options fetched; cannot enumerate datasets.")
36
+ return options_df
37
+
38
+
39
+ def fetch_datasets_for_combo(
40
+ session: ace_lib.SingleSession,
41
+ instrument_type: str,
42
+ region: str,
43
+ delay: int,
44
+ universe: str,
45
+ ) -> pd.DataFrame:
46
+ """Fetch datasets for one combination (theme ALL to include both theme true/false)."""
47
+ df = ace_lib.get_datasets(
48
+ session,
49
+ instrument_type=instrument_type,
50
+ region=region,
51
+ delay=delay,
52
+ universe=universe,
53
+ theme="ALL",
54
+ )
55
+ if df is None:
56
+ return pd.DataFrame()
57
+
58
+ df = df.copy()
59
+ df["param_instrument_type"] = instrument_type
60
+ df["param_region"] = region
61
+ df["param_delay"] = delay
62
+ df["param_universe"] = universe
63
+ df["combo_key"] = df.apply(
64
+ lambda row: f"{instrument_type}-{region}-D{delay}-{universe}",
65
+ axis=1,
66
+ )
67
+ return df
68
+
69
+
70
+ def merge_and_deduplicate(datasets: List[pd.DataFrame]) -> pd.DataFrame:
71
+ """Merge fetched datasets and deduplicate by dataset id, keeping all combo metadata."""
72
+ combined = pd.concat([df for df in datasets if not df.empty], ignore_index=True)
73
+ if combined.empty:
74
+ return combined
75
+
76
+ # Aggregate availability combos per dataset id
77
+ availability = (
78
+ combined.groupby("id")["combo_key"]
79
+ .agg(lambda x: " | ".join(sorted(set(x))))
80
+ .rename("available_in")
81
+ .reset_index()
82
+ )
83
+
84
+ # Drop duplicate rows by dataset id, keep first occurrence of other columns
85
+ unique_df = combined.drop_duplicates(subset=["id"]).copy()
86
+ unique_df = unique_df.merge(availability, on="id", how="left")
87
+
88
+ # Sort for readability
89
+ sort_cols = [col for col in ["category", "subcategory", "id"] if col in unique_df.columns]
90
+ if sort_cols:
91
+ # Ensure sort keys are hashable/strings to avoid unhashable dict errors
92
+ for col in sort_cols:
93
+ unique_df[col] = unique_df[col].apply(
94
+ lambda v: v
95
+ if pd.isna(v) or isinstance(v, (int, float, str, bool))
96
+ else json.dumps(v, ensure_ascii=False, sort_keys=True)
97
+ )
98
+ unique_df = unique_df.sort_values(sort_cols).reset_index(drop=True)
99
+
100
+ return unique_df
101
+
102
+
103
+ def main():
104
+ print("=== Fetch All BRAIN Datasets (all regions/universes/delays) ===")
105
+
106
+ email, password = prompt_credentials()
107
+
108
+ # Monkey-patch ace_lib credential retrieval so start_session uses provided credentials
109
+ ace_lib.get_credentials = lambda: (email, password)
110
+
111
+ print("Logging in...")
112
+ try:
113
+ session = ace_lib.start_session()
114
+ print("Login successful.")
115
+ except Exception as exc:
116
+ print(f"Login failed: {exc}")
117
+ return
118
+
119
+ print("Fetching valid instrument/region/delay/universe combinations from platform settings...")
120
+ try:
121
+ options_df = fetch_all_combinations(session)
122
+ except Exception as exc:
123
+ print(f"Failed to fetch simulation options: {exc}")
124
+ return
125
+
126
+ all_datasets: List[pd.DataFrame] = []
127
+ total_combos = 0
128
+
129
+ for _, row in options_df.iterrows():
130
+ instrument_type = row.get("InstrumentType")
131
+ region = row.get("Region")
132
+ delay = row.get("Delay")
133
+ universes = row.get("Universe") or []
134
+
135
+ for universe in universes:
136
+ total_combos += 1
137
+ print(f"[{total_combos}] Fetching datasets for {instrument_type} / {region} / D{delay} / {universe}...")
138
+ try:
139
+ df = fetch_datasets_for_combo(session, instrument_type, region, delay, universe)
140
+ print(f" -> Retrieved {len(df)} rows")
141
+ all_datasets.append(df)
142
+ except Exception as exc:
143
+ print(f" -> Failed for {instrument_type}-{region}-D{delay}-{universe}: {exc}")
144
+
145
+ result_df = merge_and_deduplicate(all_datasets)
146
+
147
+ if result_df.empty:
148
+ print("No datasets fetched; nothing to save.")
149
+ return
150
+
151
+ output_path = os.path.join(SCRIPT_DIR, "all_datasets_full.csv")
152
+ result_df.to_csv(output_path, index=False)
153
+ print(f"Saved {len(result_df)} unique datasets to {output_path}")
154
+
155
+
156
+ if __name__ == "__main__":
157
+ main()
@@ -0,0 +1,132 @@
1
+ """Minimal helper script to log in, list tutorials, and dump each tutorial page.
2
+
3
+ - Prompts for email/password at runtime (keeps credentials out of source).
4
+ - Uses only the requests standard stack; no project-internal imports.
5
+ - Saves each page JSON to tutorial_dump/<index>_<page_id>.json for inspection.
6
+
7
+ Run with: python doc_fetch_sample.py
8
+ """
9
+ import base64
10
+ import getpass
11
+ import json
12
+ import os
13
+ from typing import Any, Dict, Iterable, List, Optional
14
+
15
+ import requests
16
+
17
+ BASE_URL = "https://api.worldquantbrain.com"
18
+
19
+
20
+ def _basic_auth_header(email: str, password: str) -> Dict[str, str]:
21
+ token = base64.b64encode(f"{email}:{password}".encode()).decode()
22
+ return {"Authorization": f"Basic {token}"}
23
+
24
+
25
+ def authenticate(email: str, password: str) -> requests.Session:
26
+ """Authenticate and return a session carrying the JWT cookie."""
27
+ session = requests.Session()
28
+ resp = session.post(f"{BASE_URL}/authentication", headers=_basic_auth_header(email, password), timeout=30)
29
+ if resp.status_code != 201:
30
+ raise RuntimeError(f"Authentication failed (status {resp.status_code}): {resp.text}")
31
+ return session
32
+
33
+
34
+ def fetch_tutorials(session: requests.Session) -> List[Dict[str, Any]]:
35
+ """Fetch tutorials list; handle a few common response shapes."""
36
+ resp = session.get(f"{BASE_URL}/tutorials", timeout=30)
37
+ resp.raise_for_status()
38
+ data = resp.json()
39
+ if isinstance(data, list):
40
+ return data
41
+ if isinstance(data, dict):
42
+ for key in ("items", "results", "data", "tutorials"):
43
+ maybe = data.get(key)
44
+ if isinstance(maybe, list):
45
+ return maybe
46
+ return []
47
+
48
+
49
+ def fetch_tutorial_pages(session: requests.Session, tutorial_id: str) -> List[Dict[str, Any]]:
50
+ """Fetch pages for a tutorial when the list entry only gives a tutorial id/slug."""
51
+ resp = session.get(f"{BASE_URL}/tutorials/{tutorial_id}/pages", timeout=30)
52
+ if resp.status_code == 404:
53
+ return [] # graceful fallback
54
+ resp.raise_for_status()
55
+ data = resp.json()
56
+ if isinstance(data, list):
57
+ return data
58
+ if isinstance(data, dict):
59
+ for key in ("items", "results", "pages", "data"):
60
+ maybe = data.get(key)
61
+ if isinstance(maybe, list):
62
+ return maybe
63
+ return []
64
+
65
+
66
+ def _extract_page_id(entry: Dict[str, Any]) -> Optional[str]:
67
+ for key in ("page_id", "pageId", "id", "pageID", "slug", "code"):
68
+ if key in entry and entry[key] is not None:
69
+ return str(entry[key])
70
+ return None
71
+
72
+
73
+ def fetch_page(session: requests.Session, page_id: str) -> Dict[str, Any]:
74
+ resp = session.get(f"{BASE_URL}/tutorial-pages/{page_id}", timeout=30)
75
+ resp.raise_for_status()
76
+ return resp.json()
77
+
78
+
79
+ def dump_pages(session: requests.Session, tutorials: List[Dict[str, Any]], out_dir: str = "tutorial_dump") -> None:
80
+ os.makedirs(out_dir, exist_ok=True)
81
+
82
+ # Save raw tutorials list for inspection
83
+ with open(os.path.join(out_dir, "tutorials_raw.json"), "w", encoding="utf-8") as f:
84
+ json.dump(tutorials, f, ensure_ascii=False, indent=2)
85
+
86
+ def _iter_page_candidates(item: Dict[str, Any]) -> Iterable[Dict[str, Any]]:
87
+ # If the tutorial entry already has pages array, yield them
88
+ if isinstance(item.get("pages"), list):
89
+ for p in item["pages"]:
90
+ yield p
91
+ # Else, try fetching pages via tutorial id/slug
92
+ tutorial_id = _extract_page_id(item)
93
+ if tutorial_id:
94
+ pages = fetch_tutorial_pages(session, tutorial_id)
95
+ for p in pages:
96
+ yield p
97
+ # Lastly, treat the tutorial itself as a single page if it has an id/slug
98
+ if tutorial_id:
99
+ yield {"id": tutorial_id, "title": item.get("title")}
100
+
101
+ seen = 0
102
+ for idx, item in enumerate(tutorials, start=1):
103
+ for page_entry in _iter_page_candidates(item):
104
+ page_id = _extract_page_id(page_entry)
105
+ if not page_id:
106
+ print(f"[{idx:03d}] skipped page (no id): {page_entry}")
107
+ continue
108
+ try:
109
+ page = fetch_page(session, page_id)
110
+ except requests.HTTPError as e:
111
+ print(f"[{idx:03d}] page {page_id} -> HTTP {e.response.status_code} ({page_entry})")
112
+ continue
113
+ seen += 1
114
+ title = page.get("title") or page_entry.get("title") or item.get("title") or f"page_{page_id}"
115
+ out_path = os.path.join(out_dir, f"{idx:03d}_{seen:02d}_{page_id}.json")
116
+ with open(out_path, "w", encoding="utf-8") as f:
117
+ json.dump(page, f, ensure_ascii=False, indent=2)
118
+ snippet = page.get("code") or page.get("content") or str(page)[:120]
119
+ print(f"[{idx:03d}] saved {title} -> {out_path}; sample: {str(snippet)[:80]}")
120
+
121
+
122
+ def main() -> None:
123
+ email = input("BRAIN email: ").strip()
124
+ password = getpass.getpass("BRAIN password: ")
125
+ session = authenticate(email, password)
126
+ tutorials = fetch_tutorials(session)
127
+ print(f"Fetched {len(tutorials)} tutorials")
128
+ dump_pages(session, tutorials)
129
+
130
+
131
+ if __name__ == "__main__":
132
+ main()
@@ -0,0 +1,99 @@
1
+ import getpass
2
+ import os
3
+ import sys
4
+ from typing import List
5
+
6
+ import pandas as pd
7
+
8
+ # Make ace_lib importable
9
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
10
+ ROOT_DIR = os.path.dirname(SCRIPT_DIR)
11
+ if ROOT_DIR not in sys.path:
12
+ sys.path.append(ROOT_DIR)
13
+
14
+ import ace_lib # noqa: E402
15
+
16
+
17
+ def prompt_credentials() -> tuple[str, str]:
18
+ email = input("Enter BRAIN Email: ").strip()
19
+ while not email:
20
+ email = input("Email is required. Enter BRAIN Email: ").strip()
21
+
22
+ password = getpass.getpass("Enter BRAIN Password: ").strip()
23
+ while not password:
24
+ password = getpass.getpass("Password is required. Enter BRAIN Password: ").strip()
25
+
26
+ return email, password
27
+
28
+
29
+ def fetch_operators(session: ace_lib.SingleSession) -> pd.DataFrame:
30
+ df = ace_lib.get_operators(session)
31
+ if df is None or df.empty:
32
+ return pd.DataFrame()
33
+
34
+ df = df.copy()
35
+
36
+ # Choose an identifier column robustly
37
+ id_col = "id" if "id" in df.columns else None
38
+ if id_col is None:
39
+ if "name" in df.columns:
40
+ id_col = "name"
41
+ else:
42
+ id_col = "_row_id"
43
+ df[id_col] = df.index
44
+
45
+ # Re-aggregate scopes so each operator id is unique
46
+ if "scope" in df.columns:
47
+ scope_map = (
48
+ df.groupby(id_col)["scope"]
49
+ .agg(lambda x: sorted(set([item for item in x if pd.notna(item)])))
50
+ .rename("scopes")
51
+ .reset_index()
52
+ )
53
+ else:
54
+ scope_map = pd.DataFrame({id_col: df[id_col].unique(), "scopes": [[] for _ in range(df[id_col].nunique())]})
55
+
56
+ unique_df = df.drop(columns=["scope"], errors="ignore").drop_duplicates(subset=[id_col]).merge(
57
+ scope_map, on=id_col, how="left"
58
+ )
59
+
60
+ # Sort for readability
61
+ sort_cols: List[str] = [col for col in ["category", "subcategory", "name", id_col] if col in unique_df.columns]
62
+ if sort_cols:
63
+ unique_df = unique_df.sort_values(sort_cols).reset_index(drop=True)
64
+
65
+ return unique_df
66
+
67
+
68
+ def main():
69
+ print("=== Fetch All BRAIN Operators ===")
70
+
71
+ email, password = prompt_credentials()
72
+ ace_lib.get_credentials = lambda: (email, password)
73
+
74
+ print("Logging in...")
75
+ try:
76
+ session = ace_lib.start_session()
77
+ print("Login successful.")
78
+ except Exception as exc:
79
+ print(f"Login failed: {exc}")
80
+ return
81
+
82
+ print("Fetching operators...")
83
+ try:
84
+ operators_df = fetch_operators(session)
85
+ except Exception as exc:
86
+ print(f"Failed to fetch operators: {exc}")
87
+ return
88
+
89
+ if operators_df.empty:
90
+ print("No operators returned; nothing to save.")
91
+ return
92
+
93
+ output_path = os.path.join(SCRIPT_DIR, "all_operators.csv")
94
+ operators_df.to_csv(output_path, index=False)
95
+ print(f"Saved {len(operators_df)} operators to {output_path}")
96
+
97
+
98
+ if __name__ == "__main__":
99
+ main()
@@ -0,0 +1,180 @@
1
+ import json
2
+ import os
3
+ from typing import Union
4
+
5
+ import pandas as pd
6
+ from pandas.io.formats.style import Styler
7
+
8
+ brain_api_url = os.environ.get("BRAIN_API_URL", "https://api.worldquantbrain.com")
9
+ brain_url = os.environ.get("BRAIN_URL", "https://platform.worldquantbrain.com")
10
+
11
+
12
+ def make_clickable_alpha_id(alpha_id: str) -> str:
13
+ """
14
+ Create a clickable HTML link for an alpha ID.
15
+
16
+ Args:
17
+ alpha_id (str): The ID of the alpha.
18
+
19
+ Returns:
20
+ str: An HTML string containing a clickable link to the alpha's page on the platform.
21
+ """
22
+
23
+ url = brain_url + "/alpha/"
24
+ return f'<a href="{url}{alpha_id}">{alpha_id}</a>'
25
+
26
+
27
+ def prettify_result(
28
+ result: list, detailed_tests_view: bool = False, clickable_alpha_id: bool = False
29
+ ) -> Union[pd.DataFrame, Styler]:
30
+ """
31
+ Combine and format simulation results into a single DataFrame for analysis.
32
+
33
+ Args:
34
+ result (list): A list of dictionaries containing simulation results.
35
+ detailed_tests_view (bool, optional): If True, include detailed test results. Defaults to False.
36
+ clickable_alpha_id (bool, optional): If True, make alpha IDs clickable. Defaults to False.
37
+
38
+ Returns:
39
+ pandas.DataFrame or pandas.io.formats.style.Styler: A DataFrame containing formatted results,
40
+ optionally with clickable alpha IDs.
41
+ """
42
+ list_of_is_stats = [result[x]["is_stats"] for x in range(len(result)) if result[x]["is_stats"] is not None]
43
+ is_stats_df = pd.concat(list_of_is_stats).reset_index(drop=True)
44
+ is_stats_df = is_stats_df.sort_values("fitness", ascending=False)
45
+
46
+ expressions = {
47
+ result[x]["alpha_id"]: (
48
+ {
49
+ "selection": result[x]["simulate_data"]["selection"],
50
+ "combo": result[x]["simulate_data"]["combo"],
51
+ }
52
+ if result[x]["simulate_data"]["type"] == "SUPER"
53
+ else result[x]["simulate_data"]["regular"]
54
+ )
55
+ for x in range(len(result))
56
+ if result[x]["is_stats"] is not None
57
+ }
58
+ expression_df = pd.DataFrame(list(expressions.items()), columns=["alpha_id", "expression"])
59
+
60
+ list_of_is_tests = [result[x]["is_tests"] for x in range(len(result)) if result[x]["is_tests"] is not None]
61
+ is_tests_df = pd.concat(list_of_is_tests, sort=True).reset_index(drop=True)
62
+ is_tests_df = is_tests_df[is_tests_df["result"] != "WARNING"]
63
+ if detailed_tests_view:
64
+ cols = ["limit", "result", "value"]
65
+ is_tests_df["details"] = is_tests_df[cols].to_dict(orient="records")
66
+ is_tests_df = is_tests_df.pivot(index="alpha_id", columns="name", values="details").reset_index()
67
+ else:
68
+ is_tests_df = is_tests_df.pivot(index="alpha_id", columns="name", values="result").reset_index()
69
+
70
+ alpha_stats = pd.merge(is_stats_df, expression_df, on="alpha_id")
71
+ alpha_stats = pd.merge(alpha_stats, is_tests_df, on="alpha_id")
72
+ alpha_stats = alpha_stats.drop(columns=alpha_stats.columns[(alpha_stats == "PENDING").any()])
73
+ alpha_stats.columns = alpha_stats.columns.str.replace("(?<=[a-z])(?=[A-Z])", "_", regex=True).str.lower()
74
+ if clickable_alpha_id:
75
+ return alpha_stats.style.format({"alpha_id": lambda x: make_clickable_alpha_id(str(x))})
76
+ return alpha_stats
77
+
78
+
79
+ def concat_pnl(result: list) -> pd.DataFrame:
80
+ """
81
+ Combine PnL results from multiple alphas into a single DataFrame.
82
+
83
+ Args:
84
+ result (list): A list of dictionaries containing simulation results with PnL data.
85
+
86
+ Returns:
87
+ pandas.DataFrame: A DataFrame containing combined PnL data for all alphas.
88
+ """
89
+ list_of_pnls = [result[x]["pnl"] for x in range(len(result)) if result[x]["pnl"] is not None]
90
+ pnls_df = pd.concat(list_of_pnls).reset_index()
91
+
92
+ return pnls_df
93
+
94
+
95
+ def concat_is_tests(result: list) -> pd.DataFrame:
96
+ """
97
+ Combine in-sample test results from multiple alphas into a single DataFrame.
98
+
99
+ Args:
100
+ result (list): A list of dictionaries containing simulation results with in-sample test data.
101
+
102
+ Returns:
103
+ pandas.DataFrame: A DataFrame containing combined in-sample test results for all alphas.
104
+ """
105
+ is_tests_list = [result[x]["is_tests"] for x in range(len(result)) if result[x]["is_tests"] is not None]
106
+ is_tests_df = pd.concat(is_tests_list, sort=True).reset_index(drop=True)
107
+ return is_tests_df
108
+
109
+
110
+ def save_simulation_result(result: dict) -> None:
111
+ """
112
+ Save the simulation result to a JSON file in the 'simulation_results' folder.
113
+
114
+ Args:
115
+ result (dict): A dictionary containing the simulation result for an alpha.
116
+ """
117
+
118
+ alpha_id = result["id"]
119
+ region = result["settings"]["region"]
120
+ folder_path = "simulation_results/"
121
+ file_path = os.path.join(folder_path, f"{alpha_id}_{region}")
122
+
123
+ os.makedirs(folder_path, exist_ok=True)
124
+
125
+ with open(file_path, "w", encoding="utf-8") as file:
126
+ json.dump(result, file)
127
+
128
+
129
+ def save_pnl(pnl_df: pd.DataFrame, alpha_id: str, region: str) -> None:
130
+ """
131
+ Save the PnL data for an alpha to a CSV file in the 'alphas_pnl' folder.
132
+
133
+ Args:
134
+ pnl_df (pandas.DataFrame): The DataFrame containing PnL data.
135
+ alpha_id (str): The ID of the alpha.
136
+ region (str): The region for which the PnL data was generated.
137
+ """
138
+
139
+ folder_path = "alphas_pnl/"
140
+ file_path = os.path.join(folder_path, f"{alpha_id}_{region}.csv")
141
+ os.makedirs(folder_path, exist_ok=True)
142
+
143
+ pnl_df.to_csv(file_path)
144
+
145
+
146
+ def save_yearly_stats(yearly_stats: pd.DataFrame, alpha_id: str, region: str):
147
+ """
148
+ Save the yearly statistics for an alpha to a CSV file in the 'yearly_stats' folder.
149
+
150
+ Args:
151
+ yearly_stats (pandas.DataFrame): The DataFrame containing yearly statistics.
152
+ alpha_id (str): The ID of the alpha.
153
+ region (str): The region for which the statistics were generated.
154
+ """
155
+
156
+ folder_path = "yearly_stats/"
157
+ file_path = os.path.join(folder_path, f"{alpha_id}_{region}.csv")
158
+ os.makedirs(folder_path, exist_ok=True)
159
+
160
+ yearly_stats.to_csv(file_path, index=False)
161
+
162
+
163
+ def expand_dict_columns(data: pd.DataFrame) -> pd.DataFrame:
164
+ """
165
+ Expand dictionary columns in a DataFrame into separate columns.
166
+
167
+ Args:
168
+ data (pandas.DataFrame): The input DataFrame with dictionary columns.
169
+
170
+ Returns:
171
+ pandas.DataFrame: A new DataFrame with expanded columns.
172
+ """
173
+ dict_columns = list(filter(lambda x: isinstance(data[x].iloc[0], dict), data.columns))
174
+ new_columns = pd.concat(
175
+ [data[col].apply(pd.Series).rename(columns=lambda x: f"{col}_{x}") for col in dict_columns],
176
+ axis=1,
177
+ )
178
+
179
+ data = pd.concat([data, new_columns], axis=1)
180
+ return data
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "10-steps-start-brain-platform",
3
+ "title": "10 Steps to Start on BRAIN",
4
+ "lastModified": "2025-03-12T05:07:54.001684-04:00",
5
+ "content": [
6
+ {
7
+ "type": "TEXT",
8
+ "value": "<p><b>10 Steps to Start on BRAIN</b></p><ol><li>Watch the <a href=\"https://platform.worldquantbrain.com/learn/courses/introduction-alphas\">“Introduction to Alphas”</a> training series</li><li>Read the <a href=\"https://platform.worldquantbrain.com/learn/documentation#:~:text=Documentation-,Discover%20BRAIN,-4%20Articles\">starter pack series</a> under “Discover BRAIN” section</li><li>Simulate three simple formulas using the data field: close and the operator: rank</li><li>Understand the simulation settings, starting with <a href=\"https://platform.worldquantbrain.com/learn/documentation/create-alphas/simulation-settings\">delay and neutralization</a> .</li><li>Click the Example button on the bottom left of the <a href=\"https://platform.worldquantbrain.com/simulate\">Simulate</a> page for examples. Try to improve these expressions using the Hint and then submit</li><li>Understand the <a href=\"https://platform.worldquantbrain.com/learn/documentation/interpret-results/parameters-simulation-results\">Simulation Results</a> and submission tests.</li><li>Simulate Alphas discussed in the \"Create Alphas\" sections <a href=\"https://platform.worldquantbrain.com/learn/documentation/create-alphas/running-your-first-alpha\">Run your First Alpha</a> and <a href=\"https://platform.worldquantbrain.com/learn/documentation/create-alphas/another-sample-alpha\">Another Sample Alpha</a>. Pay attention to the settings.</li><li>Check the <a href=\"https://platform.worldquantbrain.com/events\">Events</a> page to attend training webinars.</li><li>Read the <a href=\"https://support.worldquantbrain.com/hc/en-us/search?filter_by=community&amp;query=%5Bbrain+tips&amp;utf8=%E2%9C%93\">BRAIN TIPS series</a> and the <a href=\"https://support.worldquantbrain.com/hc/en-us/search?content_tags=01GVTJQR8518KQMHP1JMCZ4Y99&amp;utf8=%E2%9C%93\">Beginner</a> posts in FAQs/ Forums</li><li>Try to create Alphas using available <a href=\"https://platform.worldquantbrain.com/data/data-sets/pv1\">Price volume</a> data fields or and, <a href=\"https://platform.worldquantbrain.com/learn/data-and-operators/operators\">Operators</a></li></ol><p></p><p></p>",
9
+ "id": "9a93f80b-cd7e-4c54-8c1f-ce8365c6eb20"
10
+ }
11
+ ],
12
+ "sequence": 29,
13
+ "category": "Getting Started"
14
+ }