You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Eric0801
1c16cb4321
[UX] Remove accordion, restore detailed prompt, keep popover options
...
- Removed accordion functionality as content became too sparse
- Restored detailed prompt structure from llm_service.py
- Enhanced fallback analysis with comprehensive metrics (VaR, R2, etc)
- Kept popover options for different analysis modes
- Updated max_tokens to 3000 for more detailed responses
3 months ago
data_init
Infra and data updates: fix Redis volume, expose DB, stabilize yfinance ingestion\n\n- docker-compose: use named volume for redis-data; keep common_network; Flask reachable on 8007\n- data_clear&update_us_v0.py: host=localhost; safe price_col; float cast; threads=False\n- data_clear&update_tw_v0.py: same fixes as US; robust insert values\n- update_data_daily.py: consistency fixes for yf.download and price column\n- requirements: align versions for stability\n- Re-initialized US/TW data to latest (2025-09-24)
4 months ago
prompts
feat: improve LLM output styling and prompt structure
3 months ago
sql_script
set db postgresql version as 15
1 year ago
static
change only backtesting>=1
2 years ago
templates
[UX] Remove accordion, restore detailed prompt, keep popover options
3 months ago
.gitignore
add new assets list and add competitions
2 years ago
Dockerfile
add new assets list and add competitions
2 years ago
LLM_DEMO.py
Fix unhashable type error in prompt templates\n\n- Fixed syntax error in prompts/investment_advice.py: {{}} -> {}\n- Cleaned up duplicate imports in llm_service.py\n- Removed unused lru_cache import\n- All prompt templates now work correctly\n- Demo script runs successfully
4 months ago
LLM_SETUP.md
Add LLM investment advice feature with OpenAI integration\n\n- Created llm_service.py with comprehensive LLM advisor\n- Added config_openai.py for API configuration\n- Created prompts/investment_advice.py with prompt templates\n- Updated requirements.txt with OpenAI dependency\n- Modified main.py with /api/llm_advice endpoint\n- Enhanced result_view.html with LLM advice section\n- Added CSS styling for better UI\n- Created LLM_SETUP.md setup guide\n- Added test_llm_service.py for testing\n- Implemented caching, retry logic, and error handling\n- Features: strategy analysis, risk assessment, market insights
4 months ago
Procfile
init
3 years ago
README.md
docs: add README with setup, workflow, and guardrails; no code changes
3 months ago
assets_tw.json
20230721 Finished auto deploy
3 years ago
assets_us.json
update new password setting
1 year ago
config.py
update new password setting
1 year ago
config_openai.py
Add LLM investment advice feature with OpenAI integration\n\n- Created llm_service.py with comprehensive LLM advisor\n- Added config_openai.py for API configuration\n- Created prompts/investment_advice.py with prompt templates\n- Updated requirements.txt with OpenAI dependency\n- Modified main.py with /api/llm_advice endpoint\n- Enhanced result_view.html with LLM advice section\n- Added CSS styling for better UI\n- Created LLM_SETUP.md setup guide\n- Added test_llm_service.py for testing\n- Implemented caching, retry logic, and error handling\n- Features: strategy analysis, risk assessment, market insights
4 months ago
cursor.md
docs: add cursor.md guardrails to prevent tech debt; no code changes
3 months ago
docker-compose.yml
[UX] Remove accordion, restore detailed prompt, keep popover options
3 months ago
llm_service.py
[UX] Remove accordion, restore detailed prompt, keep popover options
3 months ago
main.py
Add LLM investment advice feature with OpenAI integration\n\n- Created llm_service.py with comprehensive LLM advisor\n- Added config_openai.py for API configuration\n- Created prompts/investment_advice.py with prompt templates\n- Updated requirements.txt with OpenAI dependency\n- Modified main.py with /api/llm_advice endpoint\n- Enhanced result_view.html with LLM advice section\n- Added CSS styling for better UI\n- Created LLM_SETUP.md setup guide\n- Added test_llm_service.py for testing\n- Implemented caching, retry logic, and error handling\n- Features: strategy analysis, risk assessment, market insights
4 months ago
portfolio_builder.py
change only backtesting>=1
2 years ago
requirements.txt
Add LLM investment advice feature with OpenAI integration\n\n- Created llm_service.py with comprehensive LLM advisor\n- Added config_openai.py for API configuration\n- Created prompts/investment_advice.py with prompt templates\n- Updated requirements.txt with OpenAI dependency\n- Modified main.py with /api/llm_advice endpoint\n- Enhanced result_view.html with LLM advice section\n- Added CSS styling for better UI\n- Created LLM_SETUP.md setup guide\n- Added test_llm_service.py for testing\n- Implemented caching, retry logic, and error handling\n- Features: strategy analysis, risk assessment, market insights
4 months ago
sql_command.py
init
3 years ago
test_llm_service.py
Fix syntax error in test script\n\n- Corrected missing parenthesis in test_llm_service.py\n- All tests now pass successfully
4 months ago
update_assets_us.py
add new assets list and add competitions
2 years ago
TPM – 投資組合大擂台
1) 內容概要
Flask + PostgreSQL + Redis 的投資策略平台,內含回測、圖表與 LLM 投資建議。
前端採 Jinja SSR + Bootstrap;LLM 透過 llm_service.py 封裝,可切換 OpenAI/OpenRouter/Mock。
2) 技術棧(現況,請勿任意更換)
Backend: Flask 2.2, psycopg2, Flask-Caching, Plotly
DB/Cache: PostgreSQL, Redis
Frontend: Jinja, Bootstrap 5, Bootstrap Icons(避免新增其他 CSS 框架)
LLM: OpenAI SDK(可接 OpenRouter),支援 Mock
Container: Docker, docker-compose
3) 目錄重點
main.py: 路由與頁面組裝;禁止塞商業邏輯
llm_service.py: LLM 供應商、Prompt、重試、快取
portfolio_builder.py: 投組演算法
templates/: Jinja 模板(僅結構與少量初始化)
static/js/{components,pages}/: 前端 JS 組件與頁面邏輯
sql_script/: DB 初始化
data_init/: 資料初始化與更新腳本
4) 快速開始
準備 .env(置於專案根目錄)
LLM_PROVIDER=openrouter
OPENROUTER_API_KEY=your_key
OPENROUTER_MODEL=google/gemini-2.0-flash-exp:free
LLM_TIMEOUT=60
LLM_MAX_TOKENS=1500
LLM_TEMPERATURE=0.6
MOCK_LLM=false
啟動容器
docker compose up -d --build --force-recreate
服務連線
5) 開發規範(避免技術債)
不動既有架構、Docker 設定與不相關功能。
僅在確定「已使用」時才把套件寫入 requirements.txt;未用到的要移除。
完成一個環節、測試通過才 commit;不要在同一個 commit 混雜多項變更。
前端:避免大型 inline JS;新邏輯放 static/js/pages/*.js 或 static/js/components/*.js。
後端:商業邏輯放在服務檔案(如 llm_service.py),main.py 保持輕薄。
LLM:僅經 get_llm_advisor().generate_advice(strategy_id, strategy_dict);參數由 .env 控制。
6) 測試
後端:可使用離線腳本(MOCK_LLM=true)進行測試。
任何變更建議附最小可重現測試或腳本(避免手動點擊測試)。
7) 常見問題
500 + LLM 失敗:確認 .env 已注入容器;離線測試可先設 MOCK_LLM=true
DB 連線錯誤:程式內部連線 host 應為 db
KeyError(TSLA/AAPL):確認 data_init 成功寫入對應市場資料
8) Git / PR 規範
分支命名:feature/<area>-<short>、fix/<area>-<short>
PR 標題:[TPM] <Title>;內容包含「動機 / 變更 / 風險 / 測試方式」
小步提交、保持向後相容;前端改動請將 JS 抽出至 static/js/
9) 設計原則
關注點分離:路由薄、服務厚;模板薄、JS 組件化
僅在既有層擴展功能;避免跨層耦合
可回退:大改以 feature flag 包裝,保持 simple 模式可用
更詳細的協作規範請見 cursor.md。