cnhkmcp 2.1.2__py3-none-any.whl → 2.1.3__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 (113) hide show
  1. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/METADATA +1 -1
  2. cnhkmcp-2.1.3.dist-info/RECORD +6 -0
  3. cnhkmcp-2.1.3.dist-info/top_level.txt +1 -0
  4. cnhkmcp/__init__.py +0 -125
  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/README.md +0 -38
  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/ace.log +0 -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/config.json +0 -6
  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/ace_lib.py +0 -1510
  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/fetch_all_datasets.py +0 -157
  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/get_knowledgeBase_tool/fetch_all_documentation.py +0 -132
  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/get_knowledgeBase_tool/fetch_all_operators.py +0 -99
  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/get_knowledgeBase_tool/helpful_functions.py +0 -180
  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/icon.ico +0 -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/icon.png +0 -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/test.txt +0 -1
  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/main.py +0 -576
  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/process_knowledge_base.py +0 -281
  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/rag_engine.py +0 -408
  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/requirements.txt +0 -7
  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/run.bat +0 -3
  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//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 +0 -265
  22. cnhkmcp/untracked/APP/.gitignore +0 -32
  23. cnhkmcp/untracked/APP/MODULAR_STRUCTURE.md +0 -112
  24. cnhkmcp/untracked/APP/README.md +0 -309
  25. cnhkmcp/untracked/APP/Tranformer/Transformer.py +0 -4985
  26. cnhkmcp/untracked/APP/Tranformer/ace.log +0 -0
  27. cnhkmcp/untracked/APP/Tranformer/ace_lib.py +0 -1510
  28. cnhkmcp/untracked/APP/Tranformer/helpful_functions.py +0 -180
  29. cnhkmcp/untracked/APP/Tranformer/output/Alpha_candidates.json +0 -2421
  30. cnhkmcp/untracked/APP/Tranformer/output/Alpha_candidates_/321/207/320/264/342/225/221/321/204/342/225/233/320/233.json +0 -654
  31. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_error.json +0 -1034
  32. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_success.json +0 -444
  33. 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 +0 -22
  34. cnhkmcp/untracked/APP/Tranformer/parsetab.py +0 -60
  35. cnhkmcp/untracked/APP/Tranformer/template_summary.txt +0 -3182
  36. cnhkmcp/untracked/APP/Tranformer/transformer_config.json +0 -7
  37. cnhkmcp/untracked/APP/Tranformer/validator.py +0 -889
  38. cnhkmcp/untracked/APP/ace.log +0 -69
  39. cnhkmcp/untracked/APP/ace_lib.py +0 -1510
  40. cnhkmcp/untracked/APP/blueprints/__init__.py +0 -6
  41. cnhkmcp/untracked/APP/blueprints/feature_engineering.py +0 -347
  42. cnhkmcp/untracked/APP/blueprints/idea_house.py +0 -221
  43. cnhkmcp/untracked/APP/blueprints/inspiration_house.py +0 -432
  44. cnhkmcp/untracked/APP/blueprints/paper_analysis.py +0 -570
  45. cnhkmcp/untracked/APP/custom_templates/templates.json +0 -1257
  46. cnhkmcp/untracked/APP/give_me_idea/BRAIN_Alpha_Template_Expert_SystemPrompt.md +0 -400
  47. cnhkmcp/untracked/APP/give_me_idea/ace_lib.py +0 -1510
  48. cnhkmcp/untracked/APP/give_me_idea/alpha_data_specific_template_master.py +0 -252
  49. cnhkmcp/untracked/APP/give_me_idea/fetch_all_datasets.py +0 -157
  50. cnhkmcp/untracked/APP/give_me_idea/fetch_all_operators.py +0 -99
  51. cnhkmcp/untracked/APP/give_me_idea/helpful_functions.py +0 -180
  52. cnhkmcp/untracked/APP/give_me_idea/what_is_Alpha_template.md +0 -11
  53. cnhkmcp/untracked/APP/helpful_functions.py +0 -180
  54. cnhkmcp/untracked/APP/hkSimulator/ace_lib.py +0 -1497
  55. cnhkmcp/untracked/APP/hkSimulator/autosimulator.py +0 -447
  56. cnhkmcp/untracked/APP/hkSimulator/helpful_functions.py +0 -180
  57. cnhkmcp/untracked/APP/mirror_config.txt +0 -20
  58. cnhkmcp/untracked/APP/operaters.csv +0 -129
  59. cnhkmcp/untracked/APP/requirements.txt +0 -53
  60. cnhkmcp/untracked/APP/run_app.bat +0 -28
  61. cnhkmcp/untracked/APP/run_app.sh +0 -34
  62. cnhkmcp/untracked/APP/setup_tsinghua.bat +0 -39
  63. cnhkmcp/untracked/APP/setup_tsinghua.sh +0 -43
  64. cnhkmcp/untracked/APP/simulator/alpha_submitter.py +0 -404
  65. cnhkmcp/untracked/APP/simulator/simulator_wqb.py +0 -618
  66. cnhkmcp/untracked/APP/ssrn-3332513.pdf +6 -109201
  67. cnhkmcp/untracked/APP/static/brain.js +0 -589
  68. cnhkmcp/untracked/APP/static/decoder.js +0 -1540
  69. cnhkmcp/untracked/APP/static/feature_engineering.js +0 -1729
  70. cnhkmcp/untracked/APP/static/idea_house.js +0 -937
  71. cnhkmcp/untracked/APP/static/inspiration.js +0 -465
  72. cnhkmcp/untracked/APP/static/inspiration_house.js +0 -868
  73. cnhkmcp/untracked/APP/static/paper_analysis.js +0 -390
  74. cnhkmcp/untracked/APP/static/script.js +0 -3082
  75. cnhkmcp/untracked/APP/static/simulator.js +0 -597
  76. cnhkmcp/untracked/APP/static/styles.css +0 -3127
  77. cnhkmcp/untracked/APP/static/usage_widget.js +0 -508
  78. cnhkmcp/untracked/APP/templates/alpha_inspector.html +0 -511
  79. cnhkmcp/untracked/APP/templates/feature_engineering.html +0 -960
  80. cnhkmcp/untracked/APP/templates/idea_house.html +0 -564
  81. cnhkmcp/untracked/APP/templates/index.html +0 -932
  82. cnhkmcp/untracked/APP/templates/inspiration_house.html +0 -861
  83. cnhkmcp/untracked/APP/templates/paper_analysis.html +0 -91
  84. cnhkmcp/untracked/APP/templates/simulator.html +0 -343
  85. cnhkmcp/untracked/APP/templates/transformer_web.html +0 -580
  86. cnhkmcp/untracked/APP/usage.md +0 -351
  87. 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 +0 -1510
  88. 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 +0 -712
  89. 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 +0 -180
  90. 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 +0 -2456
  91. cnhkmcp/untracked/arXiv_API_Tool_Manual.md +0 -490
  92. cnhkmcp/untracked/arxiv_api.py +0 -229
  93. cnhkmcp/untracked/forum_functions.py +0 -998
  94. 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 +0 -407
  95. 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 +0 -2415
  96. 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 +0 -31
  97. 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 +0 -101
  98. 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 +0 -190
  99. cnhkmcp/untracked/platform_functions.py +0 -2886
  100. cnhkmcp/untracked/sample_mcp_config.json +0 -11
  101. cnhkmcp/untracked/user_config.json +0 -31
  102. 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 +0 -202
  103. 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 +0 -56
  104. 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 +0 -194
  105. 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 +0 -101
  106. 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 +0 -436
  107. 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 +0 -128
  108. 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 +0 -190
  109. cnhkmcp-2.1.2.dist-info/RECORD +0 -111
  110. cnhkmcp-2.1.2.dist-info/top_level.txt +0 -1
  111. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/WHEEL +0 -0
  112. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/entry_points.txt +0 -0
  113. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,309 +0,0 @@
1
- # BRAIN Expression Template Decoder - Flask Web Application
2
-
3
- A comprehensive Flask web application for decoding string templates with grammar checking, syntax highlighting, and seamless integration with WorldQuant BRAIN platform for real operator data.
4
-
5
- ## 🚀 Features
6
-
7
- ### Core Functionality
8
- - **Template Detection**: Automatically detects `<template_name/>` patterns in expressions
9
- - **Grammar Checking**: Real-time validation for semicolons, comments, and syntax
10
- - **Syntax Highlighting**: Color-coded display with line numbers and autocomplete
11
- - **Template Decoding**: Two modes for generating expressions
12
- - **Full Iteration**: Generate all possible combinations of template variables
13
- - **Random Iteration**: Generate a random sample of specified size
14
- - **Export Options**: Copy results or download as text file
15
-
16
- ### Template Types
17
- - **Op (Operators)** - Blue button, integrates with BRAIN operators
18
- - **Data (Data Fields)** - Green button, for data field configuration
19
- - **Normal (Parameters)** - Gray button, for general parameters
20
-
21
- ### BRAIN Integration
22
- - **Built-in API Integration**: Direct connection to WorldQuant BRAIN API with CORS handling
23
- - **186+ Operators**: Access to all operator categories (Arithmetic, Ranking, Reduce, Time Series, etc.)
24
- - **800+ Data Fields**: From fundamental datasets with search and filtering
25
- - **Advanced Search**: Filter operators by category and search by name
26
- - **Multi-select Interface**: Professional operator selection with visual feedback
27
-
28
- ## 🛠️ Setup and Installation
29
-
30
- ### Prerequisites
31
- - Python 3.7 or higher
32
- - pip (Python package installer)
33
- - WorldQuant BRAIN account (for BRAIN integration features)
34
-
35
- ### Quick Start
36
-
37
- 1. **Clone or download** this repository to your local machine
38
-
39
- 2. **Run the application** (dependencies will be installed automatically!):
40
-
41
- **On Windows:**
42
- ```bash
43
- # Double-click run_app.bat or run in terminal:
44
- run_app.bat
45
- ```
46
-
47
- **On macOS/Linux:**
48
- ```bash
49
- # Make the script executable (first time only):
50
- chmod +x run_app.sh
51
-
52
- # Run the application:
53
- ./run_app.sh
54
- ```
55
-
56
- **Or run directly with Python:**
57
- ```bash
58
- python app.py
59
- ```
60
-
61
- 3. **Automatic dependency installation**:
62
- - The application will automatically check for missing dependencies
63
- - If any packages are missing, they will be installed from requirements.txt
64
- - **For users in China**: Dependencies are automatically downloaded from Tsinghua University mirror for faster installation
65
- - No manual installation needed!
66
-
67
- 4. **Open the application**:
68
- - The Flask server starts on `http://localhost:5000`
69
- - Open your web browser and navigate to `http://localhost:5000`
70
- - Everything is integrated - no separate proxy server needed!
71
-
72
- ### For Users in China (中国用户)
73
-
74
- The application automatically uses Tsinghua University's PyPI mirror (清华大学镜像) for faster downloads. If you prefer to install dependencies manually:
75
-
76
- **Windows:**
77
- ```bash
78
- # Use the setup script with Tsinghua mirror
79
- setup_tsinghua.bat
80
- ```
81
-
82
- **macOS/Linux:**
83
- ```bash
84
- # Make executable and run
85
- chmod +x setup_tsinghua.sh
86
- ./setup_tsinghua.sh
87
- ```
88
-
89
- **Manual installation with Tsinghua mirror:**
90
- ```bash
91
- pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
92
- ```
93
-
94
- **Configuring Alternative Mirrors:**
95
- You can change the mirror source by editing `mirror_config.txt`. The file includes several popular Chinese mirrors:
96
- - Tsinghua (清华大学) - Default
97
- - Aliyun (阿里云)
98
- - Douban (豆瓣)
99
- - USTC (中国科学技术大学)
100
-
101
- ### Manual Installation
102
-
103
- If the automatic installation doesn't work, you can install manually:
104
-
105
- ```bash
106
- # Install dependencies from requirements.txt
107
- pip install -r requirements.txt
108
-
109
- # Or install individual packages
110
- pip install flask==2.3.3 flask-cors==4.0.0 requests==2.31.0 pandas==2.0.3
111
-
112
- # Start the application
113
- python app.py
114
- ```
115
-
116
- **Note**: The application includes automatic dependency checking and will attempt to install missing packages when you run it.
117
-
118
- ## 🔗 BRAIN Integration
119
-
120
- ### Setup
121
- 1. **No separate setup required** - BRAIN API integration is built into the Flask application
122
- 2. **Connect to BRAIN**: Click "Connect to BRAIN" button in the web interface
123
- 3. **Enter credentials**: Use your WorldQuant BRAIN username and password
124
- 4. **Automatic operator loading**: The system fetches all available operators (186+)
125
-
126
- ### Using BRAIN Operators
127
- 1. **Configure templates**: Set template type to "Op"
128
- 2. **Choose from BRAIN**: Click the "Choose from BRAIN" button in template configuration
129
- 3. **Search and filter**: Use the search box and category filter to find operators
130
- 4. **Multi-select**: Check multiple operators and apply them to your template
131
- 5. **Generate combinations**: Decode templates to get all possible operator combinations
132
-
133
- ## 📝 Usage Guide
134
-
135
- ### 1. Expression Editor
136
- - Type or paste your expression in the main editor
137
- - Grammar is checked automatically with visual feedback
138
- - Templates are detected and highlighted in real-time
139
- - Use autocomplete by typing `<` for template suggestions
140
-
141
- ### 2. Template Management
142
- - Templates appear in the right panel as they're detected
143
- - Click template type buttons (Op/Data/Normal) to configure
144
- - Visual indicators show configured (✓) vs unconfigured (•) templates
145
- - Click template names to view current configuration
146
-
147
- ### 3. Template Configuration
148
- - **Normal templates**: Enter comma-separated values manually
149
- - **Op templates**: Choose from BRAIN operators or enter manually
150
- - **Data templates**: Enter data field specifications
151
-
152
- ### 4. Template Decoding
153
- Two options for generating expressions:
154
- - **full_iteration**: Generate all possible combinations
155
- - Creates every possible combination using Cartesian product
156
- - Shows first 999 results with search functionality for large datasets
157
- - **random_iteration**: Generate random sample
158
- - Specify number of random expressions (default: 10)
159
- - Generates all combinations first, then randomly selects the specified number
160
- - Useful for testing or when you only need a subset of possibilities
161
- - Each template must have at least one configured value
162
- - Results are displayed with copy and download options
163
-
164
- ## 💡 Example Expression
165
-
166
- ```
167
- positive_sentiment = rank(<backfill_op/>(<positive_sentiment/>,<days/>));
168
- negative_sentiment = rank(<backfill_op/>(<negative_sentiment/>, <days/>));
169
- sentiment_difference = <compare_op/>(positive_sentiment, negative_sentiment);
170
- <time_series_operator/>(sentiment_difference, <days/>)
171
- ```
172
-
173
- ### Example Configuration
174
- - `<days/>` → `7, 14, 30`
175
- - `<compare_op/>` → `ts_max, ts_min` (selected from BRAIN)
176
- - `<time_series_operator/>` → `ts_delta, ts_mean` (selected from BRAIN)
177
-
178
- ### Generated Output
179
- The decoder will generate all combinations:
180
- ```
181
- ts_delta(ts_max(7), 7)
182
- ts_delta(ts_max(14), 14)
183
- ts_delta(ts_max(30), 30)
184
- ts_delta(ts_min(7), 7)
185
- ts_delta(ts_min(14), 14)
186
- ts_delta(ts_min(30), 30)
187
- ts_mean(ts_max(7), 7)
188
- ...and so on
189
- ```
190
-
191
- ## 🎯 Grammar Rules
192
-
193
- - Use `/* */` for multi-line comments
194
- - End statements with `;` (except the last line)
195
- - No classes, objects, pointers, or functions allowed
196
- - The last line is the Alpha expression for BRAIN simulator
197
-
198
- ## 🏗️ Technical Architecture
199
-
200
- ### Flask Application Structure
201
- ```
202
- BRAINProject/
203
- ├── app.py # Flask application with auto-dependency installation
204
- ├── templates/
205
- │ └── index.html # Main web interface template
206
- ├── static/
207
- │ ├── styles.css # Application styling
208
- │ ├── script.js # Core application logic
209
- │ ├── decoder.js # Template decoding algorithms
210
- │ └── brain.js # BRAIN API integration module
211
- ├── requirements.txt # Python dependencies
212
- ├── mirror_config.txt # PyPI mirror configuration
213
- ├── run_app.bat # Windows startup script
214
- ├── run_app.sh # Unix/macOS startup script
215
- ├── setup_tsinghua.bat # Windows setup with Tsinghua mirror (for China)
216
- ├── setup_tsinghua.sh # Unix setup with Tsinghua mirror (for China)
217
- ├── brain_function_tester.ipynb # Jupyter notebook for testing
218
- └── README.md # This file
219
- ```
220
-
221
- ### Key Components
222
- - **Flask Backend**: Handles BRAIN API authentication and data fetching
223
- - **Template Engine**: Jinja2 templates for dynamic content
224
- - **Static Assets**: CSS and JavaScript served efficiently
225
- - **CORS Handling**: Built-in cross-origin request support
226
- - **Session Management**: Secure session handling for BRAIN authentication
227
-
228
- ### API Endpoints
229
- - `GET /` - Main application page
230
- - `POST /api/authenticate` - BRAIN authentication
231
- - `GET /api/operators` - Fetch BRAIN operators with pagination
232
- - `GET /api/datafields` - Fetch BRAIN data fields
233
- - `GET /api/status` - Check authentication status
234
- - `POST /api/logout` - Logout from BRAIN
235
-
236
- ## 🔧 Advanced Features
237
-
238
- ### Operator Fetching
239
- - **Robust Pagination**: Handles BRAIN API pagination automatically
240
- - **Category Support**: Fetches operators from all categories
241
- - **Error Handling**: Multiple fallback strategies for reliable data loading
242
- - **Debugging**: Built-in endpoints for API response analysis
243
-
244
- ### Template Processing
245
- - **Real-time Detection**: Templates detected as you type
246
- - **Visual Feedback**: Color-coded syntax highlighting
247
- - **Status Indicators**: Clear visual cues for template configuration state
248
- - **Validation**: Ensures all templates are configured before decoding
249
-
250
- ### User Experience
251
- - **Professional UI**: Clean, modern interface design
252
- - **Responsive Design**: Works on desktop and tablet devices
253
- - **Keyboard Shortcuts**: Efficient template autocomplete
254
- - **Export Options**: Copy individual results or download all
255
-
256
- ## 🐛 Troubleshooting
257
-
258
- ### Common Issues
259
-
260
- 1. **Flask server won't start**:
261
- - Check Python version (3.7+ required)
262
- - Install missing dependencies: `pip install -r requirements.txt`
263
-
264
- 2. **BRAIN connection fails**:
265
- - Verify your BRAIN credentials
266
- - Check internet connectivity
267
- - Ensure no firewall blocking outbound HTTPS requests
268
-
269
- 3. **Templates not detecting**:
270
- - Check template syntax: `<template_name/>`
271
- - Refresh templates manually using the button
272
-
273
- 4. **No operators loading**:
274
- - Verify BRAIN authentication is successful
275
- - Check browser console for error messages
276
- - Try logout and re-authentication
277
-
278
- ### Debug Mode
279
- Run the application in debug mode for detailed error information:
280
- ```bash
281
- python app.py
282
- # Debug mode is enabled by default in the application
283
- ```
284
-
285
- ## 📈 Performance
286
-
287
- - **Efficient Loading**: Operators loaded once during authentication
288
- - **Pagination Handling**: Automatically fetches all data regardless of API pagination
289
- - **Session Management**: Persistent sessions for better user experience
290
- - **Optimized Frontend**: Minimal JavaScript dependencies for fast loading
291
-
292
- ## 🔐 Security
293
-
294
- - **Session Security**: Flask secure sessions with configurable secret key
295
- - **Credential Handling**: Credentials never stored, only used for API authentication
296
- - **CORS Protection**: Properly configured cross-origin request handling
297
- - **Input Validation**: Template syntax validation and grammar checking
298
-
299
- ## 🚧 Future Enhancements
300
-
301
- - **Template Library**: Save and share template configurations
302
- - **Advanced Filtering**: More sophisticated operator and data field filtering
303
- - **Batch Operations**: Process multiple expressions simultaneously
304
- - **API Integration**: Connect to additional financial data providers
305
- - **Export Formats**: Support for JSON, CSV, and other output formats
306
-
307
- ---
308
-
309
- **Note**: This Flask application replaces the previous HTML+proxy architecture, providing a more robust and integrated solution for BRAIN template decoding.