Files
gostock/internal/logic/strategy/rule/ai.go
yanweidong 827ec7bf5a fix bug
2026-02-02 19:04:32 +08:00

43 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package rule
import (
"fmt"
"git.apinb.com/bsm-sdk/core/utils"
"git.apinb.com/quant/gostock/internal/config"
"git.apinb.com/quant/gostock/internal/logic/deepseek"
)
var (
MarkdataPath = "./markdata/"
)
func (r *RuleFactory) RunAi(code string) {
mdPath := MarkdataPath + code + ".md"
if !utils.PathExists(mdPath) {
r.Model.AiScrore = -1
r.Model.AddDesc(fmt.Sprintf("%s markdown 文件未找友", mdPath))
return
}
c := deepseek.Config{
APIKey: config.Spec.DeepSeekApiKey, // 替换为你的API Key
BaseURL: "https://api.deepseek.com",
Model: "deepseek-chat", // 或 "deepseek-coder"
MaxTokens: 2000,
Temperature: 0.7,
}
prompt := "你是一名资深量化投研分析师。请根据markdown格式的附件内容给出详细总结与买入评分0-10输出JSON字段summary(500字内中文总结)、score(0-10数字)、action(买入/谨慎/观望)、risk(一句风险提示)。"
result, err := deepseek.ProcessMarkdownQA(c, mdPath, prompt)
if err != nil {
r.Model.AiScrore = -1
r.Model.AddDesc(fmt.Sprintf("处理失败: %v", err))
return
}
// 输出JSON格式的结果
fmt.Println(string(result))
}