Compare commits

...

13 Commits

Author SHA1 Message Date
ArvinLovegood
6303d535bc refactor(app):移除测试代码中的授权令牌并调整更新检查逻辑
移除app_test.go中硬编码的GitHub授权令牌,避免安全风险。在app.go的CheckUpdate方法中,将授权令牌从请求头中移除,改为无认证方式获取版本信息,同时优化VIP用户下载链接逻辑。
2025-12-10 16:26:09 +08:00
ArvinLovegood
b464d8f563 chore(config):更新访问令牌
- 替换 app.go 中的旧访问令牌为新令牌
- 注释掉 app_test.go 中的访问令牌以避免测试时使用
- 确保所有 GitHub API 请求使用最新的认证凭证
2025-12-10 16:24:03 +08:00
ArvinLovegood
eea0856c1c feat(stock):更新股票研究与市场新闻功能
- 修改股票研究工具描述,明确获取分析师研究报告
- 调整 TradingView 新闻接口参数,优化请求过滤条件
- 新增代理测试与通知推送测试方法
- 扩大股票搜索范围,提升数据获取数量
- 更新东方财富接口 User-Agent,增强请求稳定性
- 优化美股与港股数据抓取逻辑及休眠时间
- 增加前端消息墙展示标签页,集成外部链接页面
- 调整数据库操作注释,便于后续调试与维护
2025-12-10 15:55:06 +08:00
ArvinLovegood
1dd77d5c08 feat(stock):增强股票情感分析功能并优化GitHub请求
- 为GitHub API请求添加授权头部信息
- 禁用OpenAI接口中的思考模式
- 重构情感分析初始化逻辑,增加异常恢复机制
- 优化词典加载流程,提升系统稳定性
- 调整词语权重计算方式,提高准确性
- 更新测试用例,增强覆盖场景
- 移除无用的错误包引用,清理依赖项
- 修复URL格式化问题,确保请求正确性
2025-12-02 18:45:15 +08:00
ArvinLovegood
9c1c0382ca chore(deps):更新多个依赖库版本
-更新多个依赖库版本
2025-12-02 16:06:54 +08:00
ArvinLovegood
46065f448b feat(openai):启用模型思考模式并设置工具选择
- 在请求体中添加 thinking 字段以启用模型思考模式
- 设置 tool_choice 为 required 以强制使用工具调用
- 保持现有模型配置和其他参数不变
2025-12-02 14:23:52 +08:00
ArvinLovegood
a7cee69e68 chore(deps):更新模块依赖版本
- 更新 github.com/PuerkitoBio/goquery 从 v1.10.1 到 v1.11.0
- 更新 github.com/chromedp/chromedp 从 v0.14.1 到 v0.14.2
- 更新 github.com/cloudwego/eino 从 v0.4.1 到 v0.7.3
- 更新 github.com/cloudwego/eino-ext/components/model/ark 从 v0.1.19 到 v0.1.51
- 更新 github.com/cloudwego/eino-ext/components/model/deepseek 到最新提交
- 更新 github.com/cloudwego/eino-ext/components/model/openai 从 v0.0.0 到 v0.1.5
- 更新 github.com/duke-git/lancet/v2 从 v2.3.4 到 v2.3.8
- 更新 github.com/go-resty/resty/v2 从 v2.16.2 到 v2.17.0
- 更新 github.com/samber/lo 从 v1.49.1 到 v1.52.0
- 更新 github.com/stretchr/testify 从 v1.10.0 到 v1.11.1
- 更新 github.com/tidwall/gjson 从 v1.14.4 到 v1.18.0
- 更新 github.com/wailsapp/wails/v2 从 v2.10.1 到 v2.11.0
- 更新 go.uber.org/zap 从 v1.27.0 到 v1.27.1
- 更新 gorm.io/gorm 从 v1.25.12 到 v1.31.1
- 更新 gorm.io/plugin/dbresolver 从 v1.5.3 到 v1.6.2
- 移除 github.com/getkin/kin-openapi 间接依赖
- 移除 github.com/meguminnnnnnnnn/go-openai 旧版本,更新为 v0.1.0
- 移除 github.com/openai/openai-go 间接依赖
- 添加 github.com/bahlo/generic-list-go 作为间接依赖
- 添加 github.com/eino-contrib/jsonschema 作为间接依赖
- 添加 github.com/gorilla/websocket 作为间接依赖
- 添加 github.com/wk8/go-ordered-map/v2 作为间接依赖
- 添加 google.golang.org/protobuf 和 gopkg.in/check.v1 作为间接依赖
2025-11-30 19:43:30 +08:00
ArvinLovegood
459441f838 feat(stock):优化股票情绪分析词典加载逻辑
- 引入 errors 包处理词典加载错误
- 使用 github.com/vcaesar/cedar 优化词典存储结构
- 修复重复添加词汇时的错误处理逻辑
- 增强用户词典读取稳定性,避免空行导致崩溃
- 改进词汇频率更新机制,提高分词准确性
2025-11-30 10:56:57 +08:00
ArvinLovegood
b4b3b61e8c feat(db):优化数据库连接配置并调整SQLite缓存大小
- 调整SQLite连接字符串,设置缓存大小为-524288
- 修改数据库最大空闲连接数为4
- 修改数据库最大打开连接数为10
- 重新排列导入包顺序,将标准库包放在第三方库之前
2025-11-27 18:10:27 +08:00
ArvinLovegood
b6a99940ab feat(db):优化数据库连接配置并调整SQLite缓存大小
- 调整SQLite连接字符串,设置缓存大小为-524288
- 修改数据库最大空闲连接数为4
- 修改数据库最大打开连接数为10
- 重新排列导入包顺序,将标准库包放在第三方库之前
2025-11-27 18:06:15 +08:00
ArvinLovegood
5b0f34a3bd chore(deps): 更新 golang.org/x 包依赖版本
- 将 golang.org/x/crypto 从 v0.39.0 升级到 v0.44.0
- 将 golang.org/x/net 从 v0.38.0 升级到 v0.47.0
- 将 golang.org/x/sys 从 v0.36.0 升级到 v0.38.0
- 将 golang.org/x/text 从 v0.26.0 升级到 v0.31.0
- 将 golang.org/x/term 从 v0.32.0 升级到 v0.37.0
2025-11-27 17:55:29 +08:00
ArvinLovegood
e34ebf9895 chore(deps):更新前端依赖包版本
- 升级 @vitejs/plugin-vue 至 6.0.2 版本
- 升级 naive-ui 至 2.43.2 版本
- 升级 vite 至 7.2.4 版本
- 更新相关子依赖及类型定义文件
- 调整部分组件展示结构以支持图片显示
2025-11-26 18:27:35 +08:00
ArvinLovegood
c3521c6d7f feat(stock):新增东财用户标识支持并优化新闻抓取逻辑
- 在设置中增加东财唯一标识(qgqpBId)字段,用于搜索股票接口鉴权
- 优化 Telegraph 列表获取逻辑,使用协程并发执行多个数据源请求
- 调整 TradingView 新闻定时任务间隔时间,从60秒减少到10秒
- 修改新闻列表排序规则,优先按数据时间降序排列
- 更新 TradingView 新闻去重条件,由内容匹配改为时间和标题匹配
- 限制 TradingView 新闻详情处理数量,最多只处理前10条
- 完善错误提示信息显示逻辑,兼容不同字段的消息返回
- 删除冗余的 GetLevel 函数,直接在赋值处判断等级逻辑
- 增加测试初始化情感分析模块调用
- 前端表单同步增加 qgqpBId 字段绑定与持久化配置支持
2025-11-26 14:58:12 +08:00
27 changed files with 1147 additions and 322 deletions

View File

@@ -22,7 +22,7 @@
- 开发环境主要基于Windows10+,其他平台未测试或功能受限。
### 📦 立即体验
- 安装版:[go-stock-amd64-installer.exe](https://github.com/ArvinLovegood/go-stock/releases)
[//]: # (- 安装版:[go-stock-amd64-installer.exe](https://github.com/ArvinLovegood/go-stock/releases))
- 绿色版:[go-stock-windows-amd64.exe](https://github.com/ArvinLovegood/go-stock/releases)
- MACOS绿色版[go-stock-darwin-universal](https://github.com/ArvinLovegood/go-stock/releases)

12
app.go
View File

@@ -161,7 +161,7 @@ func AddTools(tools []data.Tool) []data.Tool {
Type: "function",
Function: data.ToolFunction{
Name: "GetStockResearchReport",
Description: "获取股票的分析/研究报告",
Description: "获取市场分析师的股票研究报告",
Parameters: data.FunctionParameters{
Type: "object",
Properties: map[string]any{
@@ -458,7 +458,7 @@ func (a *App) domReady(ctx context.Context) {
a.cronEntrys["newSinaNews"] = entryIDSina
}
entryIDTradingViewNews, err := a.cron.AddFunc(fmt.Sprintf("@every %ds", interval+60*5), func() {
entryIDTradingViewNews, err := a.cron.AddFunc(fmt.Sprintf("@every %ds", interval+10), func() {
news := data.NewMarketNewsApi().TradingViewNews()
if config.EnablePushNews {
go a.NewsPush(news)
@@ -717,7 +717,7 @@ func refreshTelegraphList() *[]string {
response, err := resty.New().R().
SetHeader("Referer", "https://www.cls.cn/").
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60").
Get(fmt.Sprintf(url))
Get(url)
if err != nil {
return &[]string{}
}
@@ -1375,9 +1375,9 @@ func (a *App) GetTelegraphList(source string) *[]*models.Telegraph {
func (a *App) ReFleshTelegraphList(source string) *[]*models.Telegraph {
//data.NewMarketNewsApi().GetNewTelegraph(30)
data.NewMarketNewsApi().TelegraphList(30)
data.NewMarketNewsApi().GetSinaNews(30)
data.NewMarketNewsApi().TradingViewNews()
go data.NewMarketNewsApi().TelegraphList(30)
go data.NewMarketNewsApi().GetSinaNews(30)
go data.NewMarketNewsApi().TradingViewNews()
telegraphs := data.NewMarketNewsApi().GetTelegraphList(source)
return telegraphs
}

View File

@@ -8,6 +8,8 @@ import (
"go-stock/backend/models"
"testing"
"time"
"github.com/go-resty/resty/v2"
)
// @Author spark
@@ -45,3 +47,18 @@ func TestJson(t *testing.T) {
db.Dao.Model(v).Updates(v)
}
func TestUpdateCheck(t *testing.T) {
releaseVersion := &models.GitHubReleaseVersion{}
_, err := resty.New().R().
SetResult(releaseVersion).
SetHeader("Accept", "application/vnd.github+json").
SetHeader("X-GitHub-Api-Version", "2022-11-28").
Get("https://api.github.com/repos/ArvinLovegood/go-stock/releases/latest")
// https://api.github.com/repos/OWNER/REPO/releases/latest
if err != nil {
logger.SugaredLogger.Errorf("get github release version error:%s", err.Error())
return
}
logger.SugaredLogger.Infof("releaseVersion:%+v", releaseVersion)
}

View File

@@ -3,13 +3,14 @@ package tools
import (
"context"
"encoding/json"
"go-stock/backend/data"
"go-stock/backend/logger"
"strings"
"github.com/cloudwego/eino/components/tool"
"github.com/cloudwego/eino/schema"
"github.com/duke-git/lancet/v2/random"
"github.com/tidwall/gjson"
"go-stock/backend/data"
"go-stock/backend/logger"
"strings"
)
// @Author spark
@@ -51,7 +52,7 @@ func (q QueryMarketNews) InvokableRun(ctx context.Context, argumentsInJSON strin
})
}
news := data.NewMarketNewsApi().GetNewsList("财联社电报", random.RandInt(100, 500))
news := data.NewMarketNewsApi().GetNewsList("", random.RandInt(100, 500))
messageText := strings.Builder{}
for _, telegraph := range *news {
messageText.WriteString("## " + telegraph.Time + ":" + "\n")

View File

@@ -62,7 +62,7 @@ func (m MarketNewsApi) TelegraphList(crawlTimeOut int64) *[]models.Telegraph {
DataTime: &dataTime,
Url: news["shareurl"].(string),
Source: "财联社电报",
IsRed: GetLevel(news["level"].(string)),
IsRed: (news["level"].(string)) != "C",
SentimentResult: AnalyzeSentiment(news["content"].(string)).Description,
}
cnt := int64(0)
@@ -97,9 +97,6 @@ func (m MarketNewsApi) TelegraphList(crawlTimeOut int64) *[]models.Telegraph {
return &telegraphs
}
func GetLevel(s string) bool {
return s > "C"
}
func (m MarketNewsApi) GetNewTelegraph(crawlTimeOut int64) *[]models.Telegraph {
url := "https://www.cls.cn/telegraph"
@@ -168,9 +165,9 @@ func (m MarketNewsApi) GetNewTelegraph(crawlTimeOut int64) *[]models.Telegraph {
func (m MarketNewsApi) GetNewsList(source string, limit int) *[]*models.Telegraph {
news := &[]*models.Telegraph{}
if source != "" {
db.Dao.Model(news).Preload("TelegraphTags").Where("source=?", source).Order("id desc").Limit(limit).Find(news)
db.Dao.Model(news).Preload("TelegraphTags").Where("source=?", source).Order("data_time desc,time desc").Limit(limit).Find(news)
} else {
db.Dao.Model(news).Preload("TelegraphTags").Order("id desc").Limit(limit).Find(news)
db.Dao.Model(news).Preload("TelegraphTags").Order("data_time desc,time desc").Limit(limit).Find(news)
}
for _, item := range *news {
tags := &[]models.Tags{}
@@ -189,9 +186,9 @@ func (m MarketNewsApi) GetNewsList2(source string, limit int) *[]*models.Telegra
NewMarketNewsApi().TelegraphList(30)
news := &[]*models.Telegraph{}
if source != "" {
db.Dao.Model(news).Preload("TelegraphTags").Where("source=?", source).Order("id desc,is_red desc").Limit(limit).Find(news)
db.Dao.Model(news).Preload("TelegraphTags").Where("source=?", source).Order("data_time desc,is_red desc").Limit(limit).Find(news)
} else {
db.Dao.Model(news).Preload("TelegraphTags").Order("id desc,is_red desc").Limit(limit).Find(news)
db.Dao.Model(news).Preload("TelegraphTags").Order("data_time desc,is_red desc").Limit(limit).Find(news)
}
for _, item := range *news {
tags := &[]models.Tags{}
@@ -654,8 +651,10 @@ func (m MarketNewsApi) TradingViewNews() *[]models.Telegraph {
TVNews := &[]models.TVNews{}
news := &[]models.Telegraph{}
// url := "https://news-mediator.tradingview.com/news-flow/v2/news?filter=lang:zh-Hans&filter=area:WLD&client=screener&streaming=false"
url := "https://news-mediator.tradingview.com/news-flow/v2/news?filter=area%3AWLD&filter=lang%3Azh-Hans&client=screener&streaming=false"
resp, err := client.SetTimeout(time.Duration(5)*time.Second).R().
//url := "https://news-mediator.tradingview.com/news-flow/v2/news?filter=area%3AWLD&filter=lang%3Azh-Hans&client=screener&streaming=false"
url := "https://news-mediator.tradingview.com/news-flow/v2/news?filter=lang%3Azh-Hans&client=screener&streaming=false"
resp, err := client.SetTimeout(time.Duration(15)*time.Second).R().
SetHeader("Host", "news-mediator.tradingview.com").
SetHeader("Origin", "https://cn.tradingview.com").
SetHeader("Referer", "https://cn.tradingview.com/").
@@ -676,7 +675,10 @@ func (m MarketNewsApi) TradingViewNews() *[]models.Telegraph {
}
json.Unmarshal(items, TVNews)
for _, a := range *TVNews {
for i, a := range *TVNews {
if i > 10 {
break
}
detail := NewMarketNewsApi().TradingViewNewsDetail(a.Id)
dataTime := time.Unix(int64(a.Published), 0).Local()
description := ""
@@ -699,11 +701,11 @@ func (m MarketNewsApi) TradingViewNews() *[]models.Telegraph {
SentimentResult: sentimentResult,
}
cnt := int64(0)
db.Dao.Model(telegraph).Where("time=? and content=? and source=?", telegraph.Time, telegraph.Content, "外媒").Count(&cnt)
db.Dao.Model(telegraph).Where("time=? and title=? and source=?", telegraph.Time, telegraph.Title, "外媒").Count(&cnt)
if cnt > 0 {
continue
}
db.Dao.Model(&models.Telegraph{}).Where("content=? and source=?", description, "外媒").FirstOrCreate(&telegraph)
db.Dao.Model(&models.Telegraph{}).Where("time=? and title=? and source=?", telegraph.Time, telegraph.Title, "外媒").FirstOrCreate(&telegraph)
*news = append(*news, *telegraph)
}
return news
@@ -1027,7 +1029,8 @@ func (m MarketNewsApi) ReutersNew() *models.ReutersNews {
client.SetProxy(config.HttpProxy)
}
news := &models.ReutersNews{}
url := "https://www.reuters.com/pf/api/v3/content/fetch/articles-by-section-alias-or-id-v1?query={\"arc-site\":\"reuters\",\"fetch_type\":\"collection\",\"offset\":0,\"section_id\":\"/world/\",\"size\":9,\"uri\":\"/world/\",\"website\":\"reuters\"}&d=300&mxId=00000000&_website=reuters"
//url := "https://www.reuters.com/pf/api/v3/content/fetch/articles-by-section-alias-or-id-v1?query={\"arc-site\":\"reuters\",\"fetch_type\":\"collection\",\"offset\":0,\"section_id\":\"/world/\",\"size\":9,\"uri\":\"/world/\",\"website\":\"reuters\"}&d=300&mxId=00000000&_website=reuters"
url := "https://www.reuters.com/pf/api/v3/content/fetch/recent-stories-by-sections-v1?query=%7B%22section_ids%22%3A%22%2Fworld%2F%22%2C%22size%22%3A4%2C%22website%22%3A%22reuters%22%7D&d=334&mxId=00000000&_website=reuters"
_, err := client.SetTimeout(time.Duration(5)*time.Second).R().
SetHeader("Host", "www.reuters.com").
SetHeader("Origin", "https://www.reuters.com").
@@ -1097,9 +1100,9 @@ func (m MarketNewsApi) CailianpressWeb(searchWords string) *models.CailianpressW
func (m MarketNewsApi) GetNews24HoursList(source string, limit int) *[]*models.Telegraph {
news := &[]*models.Telegraph{}
if source != "" {
db.Dao.Model(news).Preload("TelegraphTags").Where("source=? and created_at>?", source, time.Now().Add(-24*time.Hour)).Order("created_at desc,is_red desc").Limit(limit).Find(news)
db.Dao.Model(news).Preload("TelegraphTags").Where("source=? and created_at>?", source, time.Now().Add(-24*time.Hour)).Order("data_time desc,is_red desc").Limit(limit).Find(news)
} else {
db.Dao.Model(news).Preload("TelegraphTags").Where("created_at>?", time.Now().Add(-24*time.Hour)).Order("created_at desc,is_red desc").Limit(limit).Find(news)
db.Dao.Model(news).Preload("TelegraphTags").Where("created_at>?", time.Now().Add(-24*time.Hour)).Order("data_time desc,is_red desc").Limit(limit).Find(news)
}
// 内容去重
uniqueNews := make([]*models.Telegraph, 0)

View File

@@ -11,6 +11,7 @@ import (
"github.com/coocood/freecache"
"github.com/duke-git/lancet/v2/random"
"github.com/go-resty/resty/v2"
"github.com/tidwall/gjson"
)
@@ -250,5 +251,38 @@ func TestGetNewsList2(t *testing.T) {
func TestTelegraphList(t *testing.T) {
db.Init("../../data/stock.db")
InitAnalyzeSentiment()
NewMarketNewsApi().TelegraphList(30)
}
func TestProxy(t *testing.T) {
response, err := resty.New().
SetProxy("http://go-stock:778d4ff2-73f3-4d56-b3c3-d9a730a06ae3@stock.sparkmemory.top:8888").
R().
SetHeader("Host", "news-mediator.tradingview.com").
SetHeader("Origin", "https://cn.tradingview.com").
SetHeader("Referer", "https://cn.tradingview.com/").
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
//Get("https://api.ipify.org")
Get("https://news-mediator.tradingview.com/news-flow/v2/news?filter=lang%3Azh-Hans&client=screener&streaming=false&user_prostatus=non_pro")
if err != nil {
logger.SugaredLogger.Error(err)
return
}
logger.SugaredLogger.Debugf("value: %s", response.String())
}
func TestNtfy(t *testing.T) {
attach := "https://go-stock.sparkmemory.top/%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A/2025/12/09/%E5%B8%82%E5%9C%BA%E8%B5%84%E8%AE%AF[%E5%B8%82%E5%9C%BA%E8%B5%84%E8%AE%AF]-(2025-12-09)AI%E5%88%86%E6%9E%90%E7%BB%93%E6%9E%9C.md"
post, err := resty.New().SetBaseURL("https://go-stock.sparkmemory.top:16667").R().
SetHeader("Content-Type", "text/markdown").
SetHeader("Filename", "投资分析报告.md").
SetHeader("Attach", attach).
SetBody("分析报告").Post("/go-stock")
if err != nil {
logger.SugaredLogger.Error(err)
return
}
logger.SugaredLogger.Debugf("value: %s", post.String())
}

View File

@@ -877,7 +877,10 @@ func AskAi(o *OpenAi, err error, messages []map[string]interface{}, ch chan map[
resp, err := client.R().
SetDoNotParseResponse(true).
SetBody(map[string]interface{}{
"model": o.Model,
"model": o.Model,
"thinking": map[string]any{
"type": "disabled",
},
"max_tokens": o.MaxTokens,
"temperature": o.Temperature,
"stream": true,
@@ -1018,7 +1021,11 @@ func AskAiWithTools(o *OpenAi, err error, messages []map[string]interface{}, ch
resp, err := client.R().
SetDoNotParseResponse(true).
SetBody(map[string]interface{}{
"model": o.Model,
"model": o.Model,
"thinking": map[string]any{
"type": "disabled",
//"type": "enabled",
},
"max_tokens": o.MaxTokens,
"temperature": o.Temperature,
"stream": true,
@@ -1046,6 +1053,8 @@ func AskAiWithTools(o *OpenAi, err error, messages []map[string]interface{}, ch
currentFuncName := ""
currentCallId := ""
var currentAIContent strings.Builder
var reasoningContentText strings.Builder
var contentText strings.Builder
for scanner.Scan() {
line := scanner.Text()
@@ -1081,6 +1090,7 @@ func AskAiWithTools(o *OpenAi, err error, messages []map[string]interface{}, ch
if err := json.Unmarshal([]byte(data), &streamResponse); err == nil {
for _, choice := range streamResponse.Choices {
if content := choice.Delta.Content; content != "" {
contentText.WriteString(content)
//ch <- content
//logger.SugaredLogger.Infof("Content data: %s", content)
@@ -1108,6 +1118,7 @@ func AskAiWithTools(o *OpenAi, err error, messages []map[string]interface{}, ch
}
if reasoningContent := choice.Delta.ReasoningContent; reasoningContent != "" {
reasoningContentText.WriteString(reasoningContent)
//ch <- reasoningContent
ch <- map[string]any{
"code": 1,
@@ -1154,7 +1165,7 @@ func AskAiWithTools(o *OpenAi, err error, messages []map[string]interface{}, ch
}
content := "无符合条件的数据"
res := NewSearchStockApi(words).SearchStock(random.RandInt(5, 20))
res := NewSearchStockApi(words).SearchStock(random.RandInt(50, 120))
if convertor.ToString(res["code"]) == "100" {
resData := res["data"].(map[string]any)
result := resData["result"].(map[string]any)

View File

@@ -9,6 +9,7 @@ import (
func TestNewDeepSeekOpenAiConfig(t *testing.T) {
db.Init("../../data/stock.db")
InitAnalyzeSentiment()
var tools []Tool
tools = append(tools, Tool{
@@ -29,7 +30,7 @@ func TestNewDeepSeekOpenAiConfig(t *testing.T) {
},
})
ai := NewDeepSeekOpenAi(context.TODO(), 1)
ai := NewDeepSeekOpenAi(context.TODO(), 0)
//res := ai.NewChatStream("长电科技", "sh600584", "长电科技分析和总结", nil)
res := ai.NewSummaryStockNewsStreamWithTools("总结市场资讯,发掘潜力标的/行业/板块/概念,控制风险。调用工具函数验证", nil, tools)

View File

@@ -21,6 +21,13 @@ func NewSearchStockApi(words string) *SearchStockApi {
return &SearchStockApi{words: words}
}
func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
qgqpBId := NewSettingsApi().Config.QgqpBId
if qgqpBId == "" {
return map[string]any{
"code": -1,
"message": "请先获取东财用户标识qgqp_b_id打开浏览器,访问东财网站按F12打开开发人员工具-》网络面板随便点开一个请求复制请求cookie中qgqp_b_id对应的值。保存到设置中的东财唯一标识输入框",
}
}
url := "https://np-tjxg-g.eastmoney.com/api/smart-tag/stock/v3/pw/search-code"
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
SetHeader("Host", "np-tjxg-g.eastmoney.com").
@@ -32,7 +39,7 @@ func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
"keyWord": "%s",
"pageSize": %d,
"pageNo": 1,
"fingerprint": "02efa8944b1f90fbfe050e1e695a480d",
"fingerprint": "%s",
"gids": [],
"matchWord": "",
"timestamp": "%d",
@@ -44,10 +51,13 @@ func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
"ownSelectAll": false,
"dxInfo": [],
"extraCondition": ""
}`, s.words, pageSize, time.Now().Unix())).Post(url)
}`, s.words, pageSize, qgqpBId, time.Now().Unix())).Post(url)
if err != nil {
logger.SugaredLogger.Errorf("SearchStock-err:%+v", err)
return map[string]any{}
return map[string]any{
"code": -1,
"message": err.Error(),
}
}
respMap := map[string]any{}
json.Unmarshal(resp.Body(), &respMap)

View File

@@ -37,6 +37,7 @@ type Settings struct {
HttpProxy string `json:"httpProxy"`
HttpProxyEnabled bool `json:"httpProxyEnabled"`
EnableAgent bool `json:"enableAgent"`
QgqpBId string `json:"qgqpBId" gorm:"column:qgqp_b_id"`
}
func (receiver Settings) TableName() string {
@@ -108,6 +109,7 @@ func UpdateConfig(s *SettingConfig) string {
"http_proxy": s.HttpProxy,
"http_proxy_enabled": s.HttpProxyEnabled,
"enable_agent": s.EnableAgent,
"qgqp_b_id": s.QgqpBId,
})
//更新AiConfig

View File

@@ -1484,11 +1484,11 @@ func (receiver StockDataApi) getDCStockInfo(market string, page, pageSize int) {
url := "https://push2.eastmoney.com/api/qt/clist/get?np=1&fltt=1&invt=2&cb=data&fs=%s&fields=f12,f13,f14,f1,f2,f4,f3,f152,f5,f6,f7,f15,f18,f16,f17,f10,f8,f9,f23,f100,f265&fid=f3&pn=%d&pz=%d&po=1&dect=1&wbp2u=|0|0|0|web&_=%d"
sprintfUrl := fmt.Sprintf(url, fs, page, pageSize, time.Now().UnixMilli())
logger.SugaredLogger.Infof("url:%s", sprintfUrl)
logger.SugaredLogger.Infof("page:%d url:%s", page, sprintfUrl)
resp, err := receiver.client.SetTimeout(time.Duration(receiver.config.CrawlTimeOut)*time.Second).R().
SetHeader("Host", "push2.eastmoney.com").
SetHeader("Referer", "https://quote.eastmoney.com/center/gridlist.html").
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0").
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0").
Get(sprintfUrl)
if err != nil {
logger.SugaredLogger.Errorf("err:%s", err.Error())

View File

@@ -121,10 +121,10 @@ func TestGetHKStockInfo(t *testing.T) {
//NewStockDataApi().GetSinaHKStockInfo()
//m:105,m:106,m:107 //美股
//m:128+t:3,m:128+t:4,m:128+t:1,m:128+t:2 //港股
//287 224 605
for i := 1; i <= 605; i++ {
NewStockDataApi().getDCStockInfo("us", i, 20)
time.Sleep(time.Duration(random.RandInt(1, 3)) * time.Second)
//274 224 605
for i := 197; i <= 274; i++ {
NewStockDataApi().getDCStockInfo("", i, 20)
time.Sleep(time.Duration(random.RandInt(2, 5)) * time.Second)
}
}
@@ -270,15 +270,16 @@ func TestName(t *testing.T) {
db.Init("../../data/stock.db")
stockBasics := &[]StockBasic{}
resty.New().R().
resty.New().SetProxy("").R().
SetHeader("user", "go-stock").
SetResult(stockBasics).
Get("http://8.134.249.145:18080/go-stock/stock_basic.json")
db.Dao.Unscoped().Model(&StockBasic{}).Where("1=1").Delete(&StockBasic{})
err := db.Dao.CreateInBatches(stockBasics, 400).Error
if err != nil {
t.Log(err.Error())
}
logger.SugaredLogger.Infof("%+v", stockBasics)
//db.Dao.Unscoped().Model(&StockBasic{}).Where("1=1").Delete(&StockBasic{})
//err := db.Dao.CreateInBatches(stockBasics, 400).Error
//if err != nil {
// t.Log(err.Error())
//}
}

View File

@@ -73,7 +73,17 @@ var baseDict string
var zhDict string
func InitAnalyzeSentiment() {
//err := seg.LoadDictEmbed()
defer func() {
if r := recover(); r != nil {
logger.SugaredLogger.Error(fmt.Sprintf("panic: %v", r))
}
}()
// 加载简体中文词典
//err := seg.LoadDict("zh_s")
//if err != nil {
// logger.SugaredLogger.Error(err.Error())
//}
err := seg.LoadDictEmbed(baseDict)
if err != nil {
logger.SugaredLogger.Error(err.Error())
@@ -96,6 +106,8 @@ func InitAnalyzeSentiment() {
logger.SugaredLogger.Errorf("添加%s失败:%s", stock.Name, err.Error())
}
}
logger.SugaredLogger.Info("加载股票名称词典成功")
stockhks := &[]models.StockInfoHK{}
db.Dao.Model(&models.StockInfoHK{}).Find(stockhks)
for _, stock := range *stockhks {
@@ -110,6 +122,7 @@ func InitAnalyzeSentiment() {
logger.SugaredLogger.Errorf("添加%s失败:%s", stock.Name, err.Error())
}
}
logger.SugaredLogger.Info("加载港股名称词典成功")
//stockus := &[]models.StockInfoUS{}
//db.Dao.Model(&models.StockInfoUS{}).Where("trim(name) != ?", "").Find(stockus)
//for _, stock := range *stockus {
@@ -121,11 +134,17 @@ func InitAnalyzeSentiment() {
tags := &[]models.Tags{}
db.Dao.Model(&models.Tags{}).Where("type = ?", "subject").Find(tags)
for _, tag := range *tags {
err := seg.ReAddToken(tag.Name, basefreq+100, "n")
if tag.Name == "" {
continue
}
err := seg.AddToken(tag.Name, basefreq+100, "n")
if err != nil {
logger.SugaredLogger.Errorf("添加%s失败:%s", tag.Name, err.Error())
} else {
logger.SugaredLogger.Infof("添加tags词典[%s]成功", tag.Name)
}
}
logger.SugaredLogger.Info("加载tags词典成功")
seg.CalcToken()
//加载用户自定义词典 先判断用户词典是否存在
if fileutil.IsExist("data/dict/user.txt") {
@@ -139,15 +158,31 @@ func InitAnalyzeSentiment() {
continue
}
k := strutil.SplitAndTrim(line, " ")
if len(k) == 0 {
continue
}
_, _, ok := seg.Find(k[0])
switch len(k) {
case 1:
err = seg.ReAddToken(k[0], basefreq)
if ok {
err = seg.ReAddToken(k[0], basefreq)
} else {
err = seg.AddToken(k[0], basefreq)
}
case 2:
freq, _ := convertor.ToFloat(k[1])
err = seg.ReAddToken(k[0], freq)
if ok {
err = seg.ReAddToken(k[0], freq)
} else {
err = seg.AddToken(k[0], freq)
}
case 3:
freq, _ := convertor.ToFloat(k[1])
err = seg.ReAddToken(k[0], freq, k[2])
if ok {
err = seg.ReAddToken(k[0], freq, k[2])
} else {
err = seg.AddToken(k[0], freq, k[2])
}
default:
logger.SugaredLogger.Errorf("用户词典格式错误:%s", line)
}
@@ -158,6 +193,8 @@ func InitAnalyzeSentiment() {
} else {
logger.SugaredLogger.Infof("加载用户词典成功")
}
} else {
logger.SugaredLogger.Info("用户词典不存在")
}
seg.CalcToken()
}
@@ -177,7 +214,7 @@ func getWordWeight(word string) float64 {
freq, pos, ok := seg.Dictionary().Find([]byte(word))
if ok {
logger.SugaredLogger.Infof("获取%s的权重:%f,pos:%s,ok:%v", word, freq, pos, ok)
return basefreq + freq
return freq
}
return 0
}
@@ -267,7 +304,7 @@ func countWordFrequencyWithWeight(text string) map[string]WordFreqWithWeight {
// 构建包含权重的结果
for word, frequency := range wordCount {
weight := getWordWeight(word)
if weight > basefreq {
if weight >= basefreq {
freqMap[word] = WordFreqWithWeight{
Word: word,
Frequency: frequency,

View File

@@ -6,6 +6,8 @@ import (
"go-stock/backend/logger"
"strings"
"testing"
"github.com/duke-git/lancet/v2/random"
)
// @Author spark
@@ -19,15 +21,15 @@ func TestAnalyzeSentiment(t *testing.T) {
InitAnalyzeSentiment()
messageText := strings.Builder{}
//news := NewMarketNewsApi().GetNewsList2("", random.RandInt(500, 1000))
//for _, telegraph := range *news {
// messageText.WriteString(telegraph.Content + "\n")
//}
news := NewMarketNewsApi().GetNewsList2("", random.RandInt(500, 1000))
for _, telegraph := range *news {
messageText.WriteString(telegraph.Content + "\n")
}
text := messageText.String()
//text = " 【周六你需要知道的隔夜全球要闻:美联储鸽声重振 美股走势回稳】 1、纽约联储行长威廉姆斯表示随着劳动力市场走软美联储近期内仍有再次降息的空间。 2、美联储理事斯蒂芬·米兰表示自上次联邦公开市场委员会FOMC会议以来的经济数据应“促使人们偏向鸽派立场”。 3、波士顿联邦储备银行行长柯林斯表示由于通胀可能在一段时间内保持高位维持利率不变“目前合适”。 4、据CME“美联储观察”截至北京时间11月22日6时30分美联储12月降息25个基点的概率为69.4%维持利率不变的概率为30.6%。 5、美国劳工统计局表示11月CPI报告将于12月18日发布同时取消了10月CPI报告发布表示无法追溯采集政府停摆期间未能收集的部分数据。 6、俄罗斯总统普京表示已收到美提出解决俄乌冲突的计划俄罗斯愿意进行和平谈判。美国总统特朗普表示他认为27日是乌克兰接受美国支持的和平计划的最后期限。 7、美联储高官鸽派言论提振市场情绪美股三大指数收盘集体上涨道琼斯指数涨1.08%标普500指数涨0.98%纳斯达克综合指数涨0.88%。甲骨文跌超5%英伟达跌超1%。纳指本周累计跌2.74%标普500指数累跌1.95%道指累跌1.91%。英伟达本周累跌5.9%。 8、热门中概股多数上涨纳斯达克中国金龙指数收涨1.23%。蔚来涨超3%哔哩哔哩、理想汽车涨超2%京东、小鹏汽车涨超1%。 9、国际油价下跌交易员评估乌克兰与俄罗斯可能达成和平协议的前景。WTI 1月期货下跌1.6%结算价报每桶58.06美元为过去五个交易日中第四次下跌。布伦特1月期货下跌1.3%结算价报每桶62.56美元。 10、美联储延长压力测试改进方案征询期为银行反馈提供更多时间。 11、由于美国人对个人财务状况的看法恶化美国消费者信心在11月跌至接近纪录最低水平密歇根大学数据显示11月消费者信心指数降至5110月为53.6。 12、日本央行政策委员会委员Kazuyuki Masu表示日本央行接近作出加息决定。 13、穆迪将意大利信用评级从BAA3上调至BAA2展望稳定。\n"
text = "财联社电英伟达周五冲高回落股价涨幅收于1%,市场普遍认为其走势疲软"
text = "【本轮巴以冲突已致加沙地带69733人死亡】财联社11月22日电当地时间22日下午以军对加沙城西部一辆汽车发动空袭已造成5人死亡多人受伤。自2023年10月7日巴以新一轮大规模冲突爆发以来以色列对加沙地带的袭击已造成69733人死亡、170863人受伤。"
//text = "财联社电英伟达周五冲高回落股价涨幅收于1%,市场普遍认为其走势疲软"
//text = "【本轮巴以冲突已致加沙地带69733人死亡】财联社11月22日电当地时间22日下午以军对加沙城西部一辆汽车发动空袭已造成5人死亡多人受伤。自2023年10月7日巴以新一轮大规模冲突爆发以来以色列对加沙地带的袭击已造成69733人死亡、170863人受伤。"
//text = "【牛肉加工亏损 美国泰森公司关停缩减相关业务】财联社11月22日电受牛肉加工业务亏损影响当地时间21日美国泰森食品公司发布公告称将关闭位于内布拉斯加州的一家大型牛肉加工厂还计划缩小得克萨斯州一家牛肉加工厂的生产规模。根据泰森食品公司的公告被关闭的这家工厂位于内布拉斯加州列克星敦日均可宰杀并处理大约5000头牛约占全美日均牛肉屠宰数量的4.8%。与此同时公司还计划缩小得克萨斯州一家牛肉加工厂的生产规模这家工厂每天大约可屠宰6000头牛。据悉泰森此次业务调整影响两个工厂大约5000个工作岗位。《华尔街日报》报道称泰森是美国四大肉类加工公司中首家关闭主要牛肉加工厂的公司其最新财报显示2025财年牛肉加工是唯一亏损的业务部门调整后的营业亏损为4.26亿美元。"
// 分析情感
words := splitWords(text)

View File

@@ -1,13 +1,14 @@
package db
import (
"log"
"os"
"time"
"github.com/glebarez/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/plugin/dbresolver"
"log"
"os"
"time"
)
var Dao *gorm.DB
@@ -26,7 +27,7 @@ func Init(sqlitePath string) {
var openDb *gorm.DB
var err error
if sqlitePath == "" {
sqlitePath = "data/stock.db?cache=shared&mode=rwc&_journal_mode=WAL"
sqlitePath = "data/stock.db?cache_size=-524288&journal_mode=WAL"
}
openDb, err = gorm.Open(sqlite.Open(sqlitePath), &gorm.Config{
Logger: dbLogger,
@@ -48,8 +49,8 @@ func Init(sqlitePath string) {
if err != nil {
log.Fatalf("openDb.DB error is %s", err.Error())
}
dbCon.SetMaxIdleConns(10)
dbCon.SetMaxOpenConns(100)
dbCon.SetMaxIdleConns(4)
dbCon.SetMaxOpenConns(10)
dbCon.SetConnMaxLifetime(time.Hour)
Dao = openDb
}

View File

@@ -33,14 +33,14 @@
"@vicons/ionicons5": "^0.13.0",
"@vicons/material": "^0.13.0",
"@vicons/tabler": "^0.13.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue": "^6.0.2",
"html-docx-js-typescript": "^0.1.5",
"less": "^4.4.0",
"naive-ui": "^2.41.0",
"naive-ui": "^2.43.2",
"unplugin-auto-import": "^20.0.0",
"unplugin-vue-components": "^29.0.0",
"vfonts": "^0.0.3",
"vite": "^6.3.5"
"vite": "7.2.4"
}
},
"node_modules/@babel/code-frame": {
@@ -480,6 +480,7 @@
"resolved": "https://registry.npmmirror.com/@css-render/vue3-ssr/-/vue3-ssr-0.15.14.tgz",
"integrity": "sha512-//8027GSbxE9n3QlD73xFY6z4ZbHbvrOVB7AO6hsmrEzGbg+h2A09HboUyDgu+xsmj7JnvJD39Irt+2D0+iV8g==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"vue": "^3.0.11"
}
@@ -924,7 +925,8 @@
"version": "3.4.0",
"resolved": "https://registry.npmmirror.com/@juggle/resize-observer/-/resize-observer-3.4.0.tgz",
"integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==",
"dev": true
"dev": true,
"license": "Apache-2.0"
},
"node_modules/@lezer/common": {
"version": "1.2.3",
@@ -1115,6 +1117,13 @@
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@rolldown/pluginutils": {
"version": "1.0.0-beta.50",
"resolved": "https://registry.npmmirror.com/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.50.tgz",
"integrity": "sha512-5e76wQiQVeL1ICOZVUg4LSOVYg9jyhGCin+icYozhsUzM+fHE7kddi1bdiE0jwVqTfkjba3jUFbEkoC9WkdvyA==",
"dev": true,
"license": "MIT"
},
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.43.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.43.0.tgz",
@@ -1486,9 +1495,10 @@
"integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="
},
"node_modules/@types/lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-w/P33JFeySuhN6JLkysYUK2gEmy9kHHFN7E8ro0tkfmlDOgxBDzWEZ/J8cWA+fHqFevpswDTFZnDx+R9lbL6xw=="
"version": "4.17.21",
"resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==",
"license": "MIT"
},
"node_modules/@types/lodash-es": {
"version": "4.17.12",
@@ -1602,15 +1612,19 @@
"dev": true
},
"node_modules/@vitejs/plugin-vue": {
"version": "5.2.1",
"resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-5.2.1.tgz",
"integrity": "sha512-cxh314tzaWwOLqVes2gnnCtvBDcM1UMdn+iFR+UjAn411dPT3tOmqrJjbMd7koZpMAmBM/GqeV4n9ge7JSiJJQ==",
"version": "6.0.2",
"resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-6.0.2.tgz",
"integrity": "sha512-iHmwV3QcVGGvSC1BG5bZ4z6iwa1SOpAPWmnjOErd4Ske+lZua5K9TtAVdx0gMBClJ28DViCbSmZitjWZsWO3LA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@rolldown/pluginutils": "1.0.0-beta.50"
},
"engines": {
"node": "^18.0.0 || >=20.0.0"
"node": "^20.19.0 || >=22.12.0"
},
"peerDependencies": {
"vite": "^5.0.0 || ^6.0.0",
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
"vue": "^3.2.25"
}
},
@@ -2100,7 +2114,8 @@
"version": "0.2.4",
"resolved": "https://registry.npmmirror.com/evtd/-/evtd-0.2.4.tgz",
"integrity": "sha512-qaeGN5bx63s/AXgQo8gj6fBkxge+OoLddLniox5qtLAEY5HSnuSlISXVPxnSae1dWblvTh4/HoMIB+mbMsvZzw==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/exsolve": {
"version": "1.0.7",
@@ -2110,11 +2125,14 @@
"license": "MIT"
},
"node_modules/fdir": {
"version": "6.4.6",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz",
"integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==",
"version": "6.5.0",
"resolved": "https://registry.npmmirror.com/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"picomatch": "^3 || ^4"
},
@@ -2603,46 +2621,36 @@
"license": "MIT"
},
"node_modules/naive-ui": {
"version": "2.41.0",
"resolved": "https://registry.npmmirror.com/naive-ui/-/naive-ui-2.41.0.tgz",
"integrity": "sha512-KnmLg+xPLwXV8QVR7ZZ69eCjvel7R5vru8+eFe4VoAJHEgqAJgVph6Zno9K2IVQRpSF3GBGea3tjavslOR4FAA==",
"version": "2.43.2",
"resolved": "https://registry.npmmirror.com/naive-ui/-/naive-ui-2.43.2.tgz",
"integrity": "sha512-YlLMnGrwGTOc+zMj90sG3ubaH5/7czsgLgGcjTLA981IUaz8r6t4WIujNt8r9PNr+dqv6XNEr0vxkARgPPjfBQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@css-render/plugin-bem": "^0.15.14",
"@css-render/vue3-ssr": "^0.15.14",
"@types/katex": "^0.16.2",
"@types/lodash": "^4.14.198",
"@types/lodash-es": "^4.17.9",
"@types/lodash": "^4.17.20",
"@types/lodash-es": "^4.17.12",
"async-validator": "^4.2.5",
"css-render": "^0.15.14",
"csstype": "^3.1.3",
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"evtd": "^0.2.4",
"highlight.js": "^11.8.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"seemly": "^0.3.8",
"seemly": "^0.3.10",
"treemate": "^0.3.11",
"vdirs": "^0.1.8",
"vooks": "^0.2.12",
"vueuc": "^0.4.63"
"vueuc": "^0.4.65"
},
"peerDependencies": {
"vue": "^3.0.0"
}
},
"node_modules/naive-ui/node_modules/date-fns": {
"version": "3.6.0",
"resolved": "https://registry.npmmirror.com/date-fns/-/date-fns-3.6.0.tgz",
"integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/nanoid": {
"version": "3.3.11",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
@@ -2930,7 +2938,8 @@
"version": "0.3.10",
"resolved": "https://registry.npmmirror.com/seemly/-/seemly-0.3.10.tgz",
"integrity": "sha512-2+SMxtG1PcsL0uyhkumlOU6Qo9TAQ/WyH7tthnPIOQB05/12jz9naq6GZ6iZ6ApVsO3rr2gsnTf3++OV63kE1Q==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/select": {
"version": "1.1.2",
@@ -3074,14 +3083,14 @@
"license": "MIT"
},
"node_modules/tinyglobby": {
"version": "0.2.14",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz",
"integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==",
"version": "0.2.15",
"resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.15.tgz",
"integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"fdir": "^6.4.4",
"picomatch": "^4.0.2"
"fdir": "^6.5.0",
"picomatch": "^4.0.3"
},
"engines": {
"node": ">=12.0.0"
@@ -3309,6 +3318,7 @@
"resolved": "https://registry.npmmirror.com/vdirs/-/vdirs-0.1.8.tgz",
"integrity": "sha512-H9V1zGRLQZg9b+GdMk8MXDN2Lva0zx72MPahDKc30v+DtwKjfyOSXWRIX4t2mhDubM1H09gPhWeth/BJWPHGUw==",
"dev": true,
"license": "MIT",
"dependencies": {
"evtd": "^0.2.2"
},
@@ -3323,24 +3333,24 @@
"dev": true
},
"node_modules/vite": {
"version": "6.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
"version": "7.2.4",
"resolved": "https://registry.npmmirror.com/vite/-/vite-7.2.4.tgz",
"integrity": "sha512-NL8jTlbo0Tn4dUEXEsUg8KeyG/Lkmc4Fnzb8JXN/Ykm9G4HNImjtABMJgkQoVjOBN/j2WAwDTRytdqJbZsah7w==",
"dev": true,
"license": "MIT",
"dependencies": {
"esbuild": "^0.25.0",
"fdir": "^6.4.4",
"picomatch": "^4.0.2",
"postcss": "^8.5.3",
"rollup": "^4.34.9",
"tinyglobby": "^0.2.13"
"fdir": "^6.5.0",
"picomatch": "^4.0.3",
"postcss": "^8.5.6",
"rollup": "^4.43.0",
"tinyglobby": "^0.2.15"
},
"bin": {
"vite": "bin/vite.js"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
"node": "^20.19.0 || >=22.12.0"
},
"funding": {
"url": "https://github.com/vitejs/vite?sponsor=1"
@@ -3349,14 +3359,14 @@
"fsevents": "~2.3.3"
},
"peerDependencies": {
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
"@types/node": "^20.19.0 || >=22.12.0",
"jiti": ">=1.21.0",
"less": "*",
"less": "^4.0.0",
"lightningcss": "^1.21.0",
"sass": "*",
"sass-embedded": "*",
"stylus": "*",
"sugarss": "*",
"sass": "^1.70.0",
"sass-embedded": "^1.70.0",
"stylus": ">=0.54.8",
"sugarss": "^5.0.0",
"terser": "^5.16.0",
"tsx": "^4.8.1",
"yaml": "^2.4.2"
@@ -3442,6 +3452,7 @@
"resolved": "https://registry.npmmirror.com/vooks/-/vooks-0.2.12.tgz",
"integrity": "sha512-iox0I3RZzxtKlcgYaStQYKEzWWGAduMmq+jS7OrNdQo1FgGfPMubGL3uGHOU9n97NIvfFDBGnpSvkWyb/NSn/Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"evtd": "^0.2.2"
},
@@ -3493,10 +3504,11 @@
}
},
"node_modules/vueuc": {
"version": "0.4.64",
"resolved": "https://registry.npmmirror.com/vueuc/-/vueuc-0.4.64.tgz",
"integrity": "sha512-wlJQj7fIwKK2pOEoOq4Aro8JdPOGpX8aWQhV8YkTW9OgWD2uj2O8ANzvSsIGjx7LTOc7QbS7sXdxHi6XvRnHPA==",
"version": "0.4.65",
"resolved": "https://registry.npmmirror.com/vueuc/-/vueuc-0.4.65.tgz",
"integrity": "sha512-lXuMl+8gsBmruudfxnMF9HW4be8rFziylXFu1VHVNbLVhRTXXV4njvpRuJapD/8q+oFEMSfQMH16E/85VoWRyQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@css-render/vue3-ssr": "^0.15.10",
"@juggle/resize-observer": "^3.3.1",

View File

@@ -34,14 +34,14 @@
"@vicons/ionicons5": "^0.13.0",
"@vicons/material": "^0.13.0",
"@vicons/tabler": "^0.13.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue": "^6.0.2",
"html-docx-js-typescript": "^0.1.5",
"less": "^4.4.0",
"naive-ui": "^2.41.0",
"naive-ui": "^2.43.2",
"unplugin-auto-import": "^20.0.0",
"unplugin-vue-components": "^29.0.0",
"vfonts": "^0.0.3",
"vite": "^6.3.5"
"vite": "7.2.4"
},
"keywords": [
"AI赋能股票分析",

View File

@@ -1 +1 @@
b0b9f944d9af9c00b6d48234793db58c
f4fb0059ba6044c039be717fcc2e40bc

View File

@@ -287,7 +287,14 @@ function handleChart(){
<n-collapse-item name="1" >
<template #header>
<n-flex>
<n-tag size="small" :bordered="false" v-for="(item, index) in mainIndex" :type="item.zdf>0?'error':'success'"> {{item.name}} {{item.zxj}} <n-number-animation :precision="2" :from="0" :to="item.zdf"/>%</n-tag>
<n-tag size="small" :bordered="false" v-for="(item, index) in mainIndex" :type="item.zdf>0?'error':'success'">
<n-flex>
<n-image :width="20" :src="item.img" />
<n-text style="font-size: 14px" :type="item.zdf>0?'error':'success'">{{item.name}}&nbsp;{{item.zxj}}</n-text>
<n-number-animation :precision="2" :from="0" :to="item.zdf" style="font-size: 14px"/>
<n-text style="margin-left: -12px;font-size: 14px" :type="item.zdf>0?'error':'success'">%</n-text>
</n-flex>
</n-tag>
</n-flex>
</template>
<template #header-extra>

View File

@@ -125,7 +125,12 @@ function Search() {
// 计算并设置表格宽度
tableScrollX.value = calculateTableWidth(columns.value);
} else {
message.error(res.msg)
if(res.msg){
message.error(res.msg)
}
if(res.message){
message.error(res.message)
}
}
}).catch(err => {
message.error(err)

View File

@@ -46,6 +46,7 @@ const formValue = ref({
httpProxy:"",
httpProxyEnabled:false,
enableAgent: false,
qgqpBId: '',
})
// 添加一个新的AI配置到列表
@@ -105,6 +106,7 @@ onMounted(() => {
formValue.value.httpProxy=res.httpProxy;
formValue.value.httpProxyEnabled=res.httpProxyEnabled;
formValue.value.enableAgent = res.enableAgent;
formValue.value.qgqpBId = res.qgqpBId;
})
@@ -145,6 +147,7 @@ function saveConfig() {
httpProxy:formValue.value.httpProxy,
httpProxyEnabled:formValue.value.httpProxyEnabled,
enableAgent: formValue.value.enableAgent,
qgqpBId: formValue.value.qgqpBId
})
if (config.sponsorCode) {
@@ -235,6 +238,7 @@ function importConfig() {
formValue.value.httpProxy=config.httpProxy
formValue.value.httpProxyEnabled=config.httpProxyEnabled
formValue.value.enableAgent = config.enableAgent
formValue.value.qgqpBId = config.qgqpBId
};
reader.readAsText(file);
};
@@ -328,6 +332,9 @@ function deletePrompt(ID) {
<n-form-item-gi :span="3" label="AI智能体" path="enableAgent">
<n-switch v-model:value="formValue.enableAgent"/>
</n-form-item-gi>
<n-form-item-gi :span="11" label="东财唯一标识:" path="qgqpBId">
<n-input type="text" placeholder="东财唯一标识" v-model:value="formValue.qgqpBId" clearable/>
</n-form-item-gi>
<n-form-item-gi :span="11" label="赞助码:" path="sponsorCode">
<n-input-group>

View File

@@ -24,6 +24,10 @@ import EmbeddedUrl from "./EmbeddedUrl.vue";
<n-tab-pane name="财联社-行情数据" tab="财联社-行情数据">
<embedded-url url="https://www.cls.cn/quotation" :height="'calc(100vh - 252px)'"/>
</n-tab-pane>
<n-tab-pane name="消息墙" tab="消息墙">
<embedded-url url="https://go-stock.sparkmemory.top:16667/go-stock" :height="'calc(100vh - 252px)'"/>
</n-tab-pane>
<n-tab-pane name="欢迎推荐更多有趣的财经网页" tab="欢迎推荐更多有趣的财经网页">

View File

@@ -394,6 +394,7 @@ export namespace data {
httpProxy: string;
httpProxyEnabled: boolean;
enableAgent: boolean;
qgqpBId: string;
aiConfigs: AIConfig[];
static createFrom(source: any = {}) {
@@ -430,6 +431,7 @@ export namespace data {
this.httpProxy = source["httpProxy"];
this.httpProxyEnabled = source["httpProxyEnabled"];
this.enableAgent = source["enableAgent"];
this.qgqpBId = source["qgqpBId"];
this.aiConfigs = this.convertValues(source["aiConfigs"], AIConfig);
}

View File

@@ -48,6 +48,10 @@ export function EventsOff(eventName, ...additionalEventNames) {
return window.runtime.EventsOff(eventName, ...additionalEventNames);
}
export function EventsOffAll() {
return window.runtime.EventsOffAll();
}
export function EventsOnce(eventName, callback) {
return EventsOnMultiple(eventName, callback, 1);
}

109
go.mod
View File

@@ -3,95 +3,95 @@ module go-stock
go 1.25.0
require (
github.com/PuerkitoBio/goquery v1.10.1
github.com/chromedp/chromedp v0.14.1
github.com/cloudwego/eino v0.4.1
github.com/cloudwego/eino-ext/components/model/ark v0.1.19
github.com/cloudwego/eino-ext/components/model/deepseek v0.0.0-20250804092122-8845979a2228
github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250804092122-8845979a2228
github.com/PuerkitoBio/goquery v1.11.0
github.com/chromedp/chromedp v0.14.2
github.com/cloudwego/eino v0.7.3
github.com/cloudwego/eino-ext/components/model/ark v0.1.52
github.com/cloudwego/eino-ext/components/model/deepseek v0.1.0
github.com/cloudwego/eino-ext/components/model/openai v0.1.5
github.com/coocood/freecache v1.2.4
github.com/duke-git/lancet/v2 v2.3.4
github.com/duke-git/lancet/v2 v2.3.8
github.com/energye/systray v1.0.2
github.com/gen2brain/beeep v0.11.1
github.com/glebarez/sqlite v1.11.0
github.com/go-ego/gse v0.80.3
github.com/go-resty/resty/v2 v2.16.2
github.com/go-resty/resty/v2 v2.17.0
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
github.com/robertkrimen/otto v0.5.1
github.com/robfig/cron/v3 v3.0.1
github.com/samber/lo v1.49.1
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.14.4
github.com/wailsapp/wails/v2 v2.10.1
go.uber.org/zap v1.27.0
golang.org/x/net v0.38.0
golang.org/x/sys v0.36.0
golang.org/x/text v0.26.0
github.com/samber/lo v1.52.0
github.com/stretchr/testify v1.11.1
github.com/tidwall/gjson v1.18.0
github.com/wailsapp/wails/v2 v2.11.0
go.uber.org/zap v1.27.1
golang.org/x/net v0.47.0
golang.org/x/sys v0.38.0
golang.org/x/text v0.31.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gorm.io/gorm v1.25.12
gorm.io/plugin/dbresolver v1.5.3
gorm.io/gorm v1.31.1
gorm.io/plugin/dbresolver v1.6.2
gorm.io/plugin/soft_delete v1.2.1
)
require (
git.sr.ht/~jackmordaunt/go-toast v1.1.2 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/bep/debounce v1.2.1 // indirect
github.com/bytedance/sonic v1.14.0 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.2 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chromedp/cdproto v0.0.0-20250803210736-d308e07a266d // indirect
github.com/chromedp/sysutil v1.1.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250804062529-6e67726a4b3f // indirect
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.6 // indirect
github.com/cohesion-org/deepseek-go v1.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/eino-contrib/jsonschema v1.0.3 // indirect
github.com/esiqveland/notify v0.13.3 // indirect
github.com/evanphx/json-patch v0.5.2 // indirect
github.com/getkin/kin-openapi v0.118.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.4.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/godbus/dbus/v5 v5.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/goph/emperror v0.17.2 // indirect
github.com/invopop/yaml v0.1.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/jackmordaunt/icns/v3 v3.0.1 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/labstack/echo/v4 v4.13.3 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/labstack/echo/v4 v4.13.4 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
github.com/leaanthony/gosod v1.0.4 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
github.com/leaanthony/u v1.1.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mailru/easyjson v0.9.1 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/meguminnnnnnnnn/go-openai v0.0.0-20250723112853-3bce976e5ccc // indirect
github.com/meguminnnnnnnnn/go-openai v0.1.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/nikolalohinski/gonja v1.5.3 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/ollama/ollama v0.6.5 // indirect
github.com/openai/openai-go v1.10.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/ollama/ollama v0.13.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -99,35 +99,36 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/sergeymakinen/go-bmp v1.0.0 // indirect
github.com/sergeymakinen/go-ico v1.0.0-beta.0 // indirect
github.com/sergeymakinen/go-ico v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/match v1.2.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
github.com/tkrajina/go-reflector v0.5.8 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vcaesar/cedar v0.20.2 // indirect
github.com/volcengine/volc-sdk-golang v1.0.23 // indirect
github.com/volcengine/volcengine-go-sdk v1.1.21 // indirect
github.com/wailsapp/go-webview2 v1.0.19 // indirect
github.com/volcengine/volc-sdk-golang v1.0.229 // indirect
github.com/volcengine/volcengine-go-sdk v1.1.50 // indirect
github.com/wailsapp/go-webview2 v1.0.23 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/yargevad/filepathx v1.0.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/arch v0.20.0 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.23.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.23.1 // indirect
modernc.org/libc v1.67.1 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.40.1 // indirect
)
// replace github.com/wailsapp/wails/v2 v2.9.2 => C:\Users\spark\go\pkg\mod

933
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -68,6 +68,10 @@ func main() {
// Sort: 0,
//})
log.SugaredLogger.Info("starting...")
log.SugaredLogger.Infof("version: %s commit: %s", Version, VersionCommit)
log.SugaredLogger.Infof("build key: %s", BuildKey)
// Create an instance of the app structure
app := NewApp()
AppMenu := menu.NewMenu()