This commit is contained in:
ArvinLovegood 2025-03-10 22:30:12 +08:00
commit 78150bcecd
6 changed files with 36 additions and 20 deletions

5
app.go
View File

@ -737,7 +737,7 @@ func getScreenResolution() (int, int, error) {
func (a *App) ShareAnalysis(stockCode, stockName string) string {
//http://go-stock.sparkmemory.top:16688/upload
res := data.NewDeepSeekOpenAi(a.ctx).GetAIResponseResult(stockCode)
if res != nil {
if res != nil && len(res.Content) > 100 {
analysisTime := res.CreatedAt.Format("2006/01/02")
logger.SugaredLogger.Infof("%s analysisTime:%s", res.CreatedAt, analysisTime)
response, err := resty.New().SetHeader("ua-x", "go-stock").R().SetFormData(map[string]string{
@ -750,8 +750,9 @@ func (a *App) ShareAnalysis(stockCode, stockName string) string {
return err.Error()
}
return response.String()
} else {
return "分析结果异常"
}
return "获取分析结果失败"
}
func (a *App) GetfundList(key string) []data.FundBasic {

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/duke-git/lancet/v2/convertor"
"github.com/duke-git/lancet/v2/mathutil"
"github.com/duke-git/lancet/v2/strutil"
"github.com/go-resty/resty/v2"
"go-stock/backend/db"
@ -39,6 +40,10 @@ type FollowedFund struct {
NetEstimatedUnit *float64 `json:"netEstimatedUnit"` // 估算单位净值
NetEstimatedTime string `json:"netEstimatedUnitTime"` // 估算单位净值日期
NetAccumulated *float64 `json:"netAccumulated"` // 累计净值
//计算值
NetEstimatedRate *float64 `json:"netEstimatedRate"` // 估算单位净值涨跌幅
FundBasic FundBasic `json:"fundBasic" gorm:"foreignKey:Code;references:Code"`
}
@ -226,6 +231,14 @@ func (f *FundApi) GetFundList(key string) []FundBasic {
func (f *FundApi) GetFollowedFund() []FollowedFund {
var funds []FollowedFund
db.Dao.Preload("FundBasic").Find(&funds)
for i, fund := range funds {
if fund.NetUnitValue != nil && fund.NetEstimatedUnit != nil && *fund.NetUnitValue > 0 {
netEstimatedRate := (*(funds[i].NetEstimatedUnit) - *(funds[i].NetUnitValue)) / *(fund.NetUnitValue) * 100
netEstimatedRate = mathutil.RoundToFloat(netEstimatedRate, 2)
funds[i].NetEstimatedRate = &netEstimatedRate
}
}
return funds
}
func (f *FundApi) FollowFund(fundCode string) string {

View File

@ -478,7 +478,7 @@ func ParseFullSingleStockData(data string) (*StockInfo, error) {
}
var result map[string]string
var err error
if strutil.ContainsAny(datas[0], []string{"hq_str_sz", "hq_str_sh"}) {
if strutil.ContainsAny(datas[0], []string{"hq_str_sz", "hq_str_sh", "hq_str_bj", "hq_str_sb"}) {
result, err = ParseSHSZStockData(datas)
}
if strutil.ContainsAny(datas[0], []string{"hq_str_hk"}) {

View File

@ -85,7 +85,7 @@ func TestParseFullSingleStockData(t *testing.T) {
SetHeader("Host", "hq.sinajs.cn").
SetHeader("Referer", "https://finance.sina.com.cn/").
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").
Get(fmt.Sprintf(sinaStockUrl, time.Now().Unix(), "sh600584,sz000938,hk01810,hk00856,gb_aapl,gb_tsla"))
Get(fmt.Sprintf(sinaStockUrl, time.Now().Unix(), "sh600584,sz000938,hk01810,hk00856,gb_aapl,gb_tsla,sb873721,bj430300"))
if err != nil {
logger.SugaredLogger.Error(err.Error())
}

View File

@ -98,7 +98,7 @@ EventsOn("updateVersion",async (msg) => {
<p>目前已支持A股港股美股未来计划加入基金ETF等支持</p>
<p>支持DeepSeekOpenAI OllamaLMStudioAnythingLLM<a href="https://cloud.siliconflow.cn/i/foufCerk" target="_blank">硅基流动</a><a href="https://www.volcengine.com/experience/ark?utm_term=202502dsinvite&ac=DSASUQY5&rc=IJSE43PZ" target="_blank">火山方舟</a>阿里云百炼等平台或模型</p>
<p>
本软件仅供学习研究AI分析股票结果仅供参考不提供任何投资建议或决策
<i style="color: crimson">本软件仅供学习研究目的AI分析结果仅供参考本软件不提供任何投资建议或决策风险自担</i>
</p>
<p>
欢迎点赞GitHub<a href="https://github.com/ArvinLovegood/go-stock" target="_blank">go-stock</a><n-divider vertical />
@ -107,7 +107,8 @@ EventsOn("updateVersion",async (msg) => {
<a href="https://github.com/ArvinLovegood/go-stock/releases" target="_blank">Releases</a><n-divider vertical />
</p>
<p v-if="updateLog">更新说明{{updateLog}}</p>
<p>项目社区<a href="https://go-stock.sparkmemory.top/" target="_blank">https://go-stock.sparkmemory.top/</a></p>
<p>QQ交流群<a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0YQ8qD3exahsD4YLNhzQTWe5ssstWC89&authKey=usOMMRFtIQDC%2FYcatHYapcxQbJ7PwXPHK9OypTXWzNjAq%2FRVvQu9bj2lRgb%2BSZ3p&noverify=0&group_code=491605333" target="_blank">491605333</a></p>
</div>
</n-space>
<n-divider title-placement="center">关于作者</n-divider>
@ -116,11 +117,6 @@ EventsOn("updateVersion",async (msg) => {
<n-avatar width="100" src="https://avatars.githubusercontent.com/u/7401917?v=4" />
<h2><a href="https://github.com/ArvinLovegood" target="_blank">@ArvinLovegood</a></h2>
<p>一个热爱编程的小白欢迎关注我的Github</p>
<p>
邮箱<a href="mailto:sparkmemory@163.com">sparkmemory@163.com</a><n-divider vertical />
QQ 506808970<n-divider vertical />
微信ArvinLovegood</p>
<p style="color: #FAA04A">*加微信或者QQ时请先备注或留言需求(<a href="#support">技术支持</a>功能建议商业咨询等否则会被忽略)</p>
<p>开源不易如果觉得好用可以请作者喝杯咖啡</p>
<n-flex justify="center">
<n-image width="200" :src="alipay" />
@ -149,6 +145,7 @@ EventsOn("updateVersion",async (msg) => {
</div>
<n-divider title-placement="center">关于版权和技术支持申明</n-divider>
<div style="justify-self: center;text-align: left" >
<p style="color: #FAA04A">如有问题请先查看项目文档如果问题依然存在请优先加群491605333咨询</p>
<p>
如需软件商业授权或定制开发请联系作者微信(备注 商业咨询)ArvinLovegood
</p>
@ -157,8 +154,9 @@ EventsOn("updateVersion",async (msg) => {
本软件基于开源技术构建使用WailsNaiveUIVue等开源项目技术上如有问题可以先向对应的开源社区请求帮助
</p>
<p>
开源不易本人精力和时间有限如确实需要一对一技术支持请先赞助联系微信(备注 技术支持)ArvinLovegood
开源不易本人精力和时间有限如确实需要一对一技术支持<i style="color: crimson">请先赞助</i>联系微信(备注 技术支持)ArvinLovegood
</p>
<p style="color: #FAA04A">*加微信或者QQ时请先备注或留言需求(<a href="#support">技术支持</a>功能建议商业咨询等否则会被忽略)</p>
<n-table id="support">
<n-thead>
<n-tr>

View File

@ -154,9 +154,13 @@ function formatterTitle(title){
<n-tag size="small" :bordered="false" type="info">{{info.code}}</n-tag>&nbsp;
<n-tag size="small" :bordered="false" type="success" @click="unFollow(info.code)"> 取消关注</n-tag>
</template>
<n-tag size="small" :type="info.netEstimatedUnit>0?'error':'success'" :bordered="false" v-if="info.netEstimatedUnit">估算净值{{info.netEstimatedUnit}}({{info.netEstimatedUnitTime}})</n-tag>
<n-tag size="small" :type="info.netEstimatedRate>0?'error':'success'" :bordered="false" v-if="info.netEstimatedUnit">
估算净值{{info.netEstimatedUnit}}&nbsp;
{{info.netEstimatedRate}} %&nbsp;&nbsp;&nbsp;
({{info.netEstimatedUnitTime}})</n-tag>
<n-divider vertical></n-divider>
<n-tag size="small" :type="info.netUnitValue>0?'error':'success'" :bordered="false" v-if="info.netUnitValue">单位净值{{info.netUnitValue}}({{info.netUnitValueDate}})</n-tag>
<n-tag size="small" :type="info.netEstimatedRate>0?'error':'success'" :bordered="false" v-if="info.netUnitValue">
单位净值{{info.netUnitValue}}&nbsp;({{info.netUnitValueDate}})</n-tag>
<n-divider v-if="info.netUnitValue"></n-divider>
<n-flex justify="start">
<n-tag size="small" :type="info.fundBasic.netGrowth1>0?'error':'success'" :bordered="false" v-if="info.fundBasic.netGrowth1">近一月{{info.fundBasic.netGrowth1}}%</n-tag>