fix: prevent DeepSeek token overflow with product-level limits (#1431)

* feat: enforce strategy limits to prevent token overflow

* fix: tune token limits after real-world testing

- Relax kline max 20→30, timeframes 3→4 (tested ~41K tokens, safe under 131K)
- Restore ranking limits to original [5,10,15,20] options (only ~1.5K token impact)
- Add static coins limit (max 3) with toast notification
- Add timeframe limit toast when exceeding 4
- Log SSE token usage (prompt/completion/total) from API response
- Fix nil logger crash in claw402 data client (engine.go)

* feat: add token estimation functionality for strategy configurations

* feat: add discard changes button in Strategy Studio for unsaved modifications

* feat: retain selected strategy after saving in Strategy Studio

* feat: enhance strategy display in Strategy Studio with improved layout and sorting of token limits

* refactor: improve layout and styling of stats display in CompetitionPage

* refactor: replace select elements with NofxSelect component for improved consistency in strategy configuration forms

* style: update NofxSelect component to use smaller text size for improved readability

* feat: implement token overflow handling in strategy updates and UI

---------

Co-authored-by: Dean <afei.wuhao@gmail.com>
This commit is contained in:
deanokk
2026-03-27 00:26:40 +08:00
committed by shinchan-zhai
parent b705810ec2
commit 79a3be1874
20 changed files with 1124 additions and 338 deletions

View File

@@ -1080,11 +1080,16 @@ export const translations = {
public: 'Public',
addDescription: 'Add strategy description...',
unsaved: 'Unsaved',
discardChanges: 'Discard',
selectOrCreate: 'Select or create a strategy',
customPromptDesc: 'Extra prompt appended to System Prompt for personalized trading style',
customPromptPlaceholder: 'Enter custom prompt...',
generatePromptPreview: 'Click to generate prompt preview',
runAiTestHint: 'Click to run AI test',
tokenEstimate: 'Token Estimate',
tokenExceedWarning: 'Exceeds context limit. Reduce coins or timeframes.',
tokenEstimating: 'Estimating...',
tokenTooltip: 'Based on strictest model',
},
// Metric Tooltip
@@ -2371,11 +2376,16 @@ export const translations = {
public: '公开',
addDescription: '添加策略简介...',
unsaved: '未保存',
discardChanges: '撤销',
selectOrCreate: '选择或创建策略',
customPromptDesc: '附加在 System Prompt 末尾的额外提示,用于补充个性化交易风格',
customPromptPlaceholder: '输入自定义提示词...',
generatePromptPreview: '点击生成 Prompt 预览',
runAiTestHint: '点击运行 AI 测试',
tokenEstimate: 'Token 预估',
tokenExceedWarning: '超出上下文限制,建议减少币种或时间框架',
tokenEstimating: '预估中...',
tokenTooltip: '基于最严格模型计算',
},
// Metric Tooltip
@@ -3464,11 +3474,16 @@ export const translations = {
public: 'Publik',
addDescription: 'Tambah deskripsi strategi...',
unsaved: 'Belum Disimpan',
discardChanges: 'Buang',
selectOrCreate: 'Pilih atau buat strategi',
customPromptDesc: 'Prompt tambahan di akhir System Prompt untuk gaya trading personal',
customPromptPlaceholder: 'Masukkan prompt kustom...',
generatePromptPreview: 'Klik untuk generate pratinjau prompt',
runAiTestHint: 'Klik untuk menjalankan uji AI',
tokenEstimate: 'Estimasi Token',
tokenExceedWarning: 'Melebihi batas konteks. Kurangi koin atau timeframe.',
tokenEstimating: 'Mengestimasi...',
tokenTooltip: 'Berdasarkan model paling ketat',
},
// Metric Tooltip