Skip to content

Commit

Permalink
区分当前roe和最新财报roe
Browse files Browse the repository at this point in the history
  • Loading branch information
axiaoxin committed Jul 24, 2021
1 parent 5b98922 commit 2eb7eaf
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 20 deletions.
9 changes: 6 additions & 3 deletions models/exportor_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ type ExportorData struct {
ReportOpinion interface{} `json:"report_opinion" csv:"财报审计意见"`
// 价值评估
JZPG string `json:"jzpg" csv:"价值评估"`
// 最新一期 ROE
LatestROE float64 `json:"latest_roe" csv:"最新一期 ROE"`
// 当前 ROE
LatestROE float64 `json:"latest_roe" csv:"当前 ROE"`
// 最近财报 ROE
LatestFinaROE float64 `json:"latest_fina_roe" csv:"最新财报 ROE"`
// ROE 同比增长
ROETBZZ float64 `json:"roe_tbzz" csv:"ROE 同比增长 (%)"`
// 近五年 ROE
Expand Down Expand Up @@ -201,7 +203,8 @@ func NewExportorData(ctx context.Context, stock Stock) ExportorData {
ReportDateName: fina.ReportDateName,
ReportOpinion: reportOpinion,
JZPG: stock.JZPG.String(),
LatestROE: fina.Roejq,
LatestROE: stock.BaseInfo.RoeWeight,
LatestFinaROE: fina.Roejq,
ROETBZZ: fina.Roejqtz,
ROE5Y: stock.HistoricalFinaMainData.ValueList(ctx, eastmoney.ValueListTypeROE, 5, eastmoney.FinaReportTypeYear),
LatestEPS: fina.Epsjb,
Expand Down
1 change: 1 addition & 0 deletions routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ func Routes(app *gin.Engine) {
app.GET("/", StockIndex)
app.POST("/selector", StockSelector)
app.POST("/checker", StockChecker)
app.POST("/chip", StockChip)
app.GET("/fund", FundIndex)
app.GET("/fund/filter", FundFilter)
app.POST("/fund/check", FundCheck)
Expand Down
41 changes: 41 additions & 0 deletions routes/stock.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,44 @@ func StockChecker(c *gin.Context) {
c.JSON(http.StatusOK, data)
return
}

// ParamStockChip StockChip 请求参数
type ParamStockChip struct {
Keyword string `json:"keyword" form:"keyword"`
}

// StockChip 筹码面
func StockChip(c *gin.Context) {
data := gin.H{
"Env": viper.GetString("env"),
"Version": version.Version,
"PageTitle": "X-STOCK | 股票 | 筹码面",
"Error": "",
}
param := ParamStockChip{}
if err := c.ShouldBind(&param); err != nil {
data["Error"] = err.Error()
c.JSON(http.StatusOK, data)
return
}
if param.Keyword == "" {
data["Error"] = "请填写股票代码或简称"
c.JSON(http.StatusOK, data)
return
}
keywords := goutils.SplitStringFields(param.Keyword)
searcher := core.NewSearcher(c)
stocks, err := searcher.SearchStocks(c, keywords)
if err != nil {
data["Error"] = err.Error()
c.JSON(http.StatusOK, data)
return
}
mainNetInflows := gin.H{}
for _, stock := range stocks {
mainNetInflows[stock.BaseInfo.Secucode] = stock.MainMoneyNetInflows
}
data["MainMoneyNetInflows"] = mainNetInflows
c.JSON(http.StatusOK, data)
return
}
51 changes: 36 additions & 15 deletions statics/html/stock_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<ul class="tabs">
<li class="tab col s6"><a class="active" href="#checker">个股检测</a></li>
<li class="tab col s6"><a href="#selector">基本面选股</a></li>
<li class="tab col s6"><a href="#chip">筹码面</a></li>
</ul>
</div>

Expand Down Expand Up @@ -260,6 +261,24 @@
</div>
</div>
<!--selector end-->

<!-- 筹码面 start -->
<div id="chip" class="col s12">
<div class="row">
<form class="col s12" id="chip_form">
<div class="row">
<div class="input-field col s12">
<textarea id="keyword" name="keyword" class="materialize-textarea validate" required></textarea>
<label for="keyword">输入股票代码或简称</label>
</div>
</div>
<div class="row">
<a class="btn waves-effect waves-light red lighten-2 col s12" id="chip_btn" >查询</a>
</div>
</form>
</div>
</div>
<!-- 筹码面 end -->
</div>

{{ template "modal" . }}
Expand All @@ -278,19 +297,20 @@ <h4 class="center">筛选结果</h4>
<li><label><input id="sf_6" type="checkbox" /><span>数据源</span></label></li>
<li><label><input id="sf_7" type="checkbox" /><span>财报审计意见</span></label></li>
<li><label><input id="sf_8" type="checkbox" /><span>价值评估</span></label></li>
<li><label><input id="sf_9" type="checkbox" /><span>最新一期 ROE</span></label></li>
<li><label><input id="sf_10" type="checkbox" /><span>ROE 同比增长 (%)</span></label></li>
<li><label><input id="sf_11" type="checkbox" /><span>近五年 ROE</span></label></li>
<li><label><input id="sf_12" type="checkbox" /><span>最新一期 EPS</span></label></li>
<li><label><input id="sf_13" type="checkbox" /><span>EPS 同比增长 (%)</span></label></li>
<li><label><input id="sf_14" type="checkbox" /><span>近五年 EPS</span></label></li>
<li><label><input id="sf_9" type="checkbox" /><span>当前ROE</span></label></li>
<li><label><input id="sf_55" type="checkbox" /><span>最近财报ROE</span></label></li>
<li><label><input id="sf_10" type="checkbox" /><span>ROE同比增长(%)</span></label></li>
<li><label><input id="sf_11" type="checkbox" /><span>近五年ROE</span></label></li>
<li><label><input id="sf_12" type="checkbox" /><span>最新一期EPS</span></label></li>
<li><label><input id="sf_13" type="checkbox" /><span>EPS同比增长(%)</span></label></li>
<li><label><input id="sf_14" type="checkbox" /><span>近五年EPS</span></label></li>
<li><label><input id="sf_15" type="checkbox" /><span>营业总收入</span></label></li>
<li><label><input id="sf_16" type="checkbox" /><span>营业总收入同比增长 (%)</span></label></li>
<li><label><input id="sf_16" type="checkbox" /><span>营业总收入同比增长(%)</span></label></li>
<li><label><input id="sf_17" type="checkbox" /><span>近五年营收</span></label></li>
<li><label><input id="sf_18" type="checkbox" /><span>归属净利润(元)</span></label></li>
<li><label><input id="sf_19" type="checkbox" /><span>归属净利润同比增长 (%)</span></label></li>
<li><label><input id="sf_19" type="checkbox" /><span>归属净利润同比增长(%)</span></label></li>
<li><label><input id="sf_20" type="checkbox" /><span>近五年净利润</span></label></li>
<li><label><input id="sf_21" type="checkbox" /><span>最新股息率 (%)</span></label></li>
<li><label><input id="sf_21" type="checkbox" /><span>最新股息率(%)</span></label></li>
<li><label><input id="sf_22" type="checkbox" /><span>财报披露日期</span></label></li>
<li><label><input id="sf_23" type="checkbox" /><span>预约财报披露日期</span></label></li>
<li><label><input id="sf_24" type="checkbox" /><span>实际财报披露日期</span></label></li>
Expand All @@ -299,12 +319,12 @@ <h4 class="center">筛选结果</h4>
<li><label><input id="sf_27" type="checkbox" /><span>估算合理价格</span></label></li>
<li><label><input id="sf_28" type="checkbox" /><span>合理价差</span></label></li>
<li><label><input id="sf_29" type="checkbox" /><span>历史波动率</span></label></li>
<li><label><input id="sf_30" type="checkbox" /><span>最新负债率 (%)</span></label></li>
<li><label><input id="sf_30" type="checkbox" /><span>最新负债率(%)</span></label></li>
<li><label><input id="sf_31" type="checkbox" /><span>负债流动比</span></label></li>
<li><label><input id="sf_32" type="checkbox" /><span>净利润 3 年复合增长率 (%)</span></label></li>
<li><label><input id="sf_33" type="checkbox" /><span>营收 3 年复合增长率 (%)</span></label></li>
<li><label><input id="sf_34" type="checkbox" /><span>上市以来年化收益率 (%)</span></label></li>
<li><label><input id="sf_35" type="checkbox" /><span>年化波动率 (%)</span></label></li>
<li><label><input id="sf_32" type="checkbox" /><span>净利润3年复合增长率(%)</span></label></li>
<li><label><input id="sf_33" type="checkbox" /><span>营收3年复合增长率(%)</span></label></li>
<li><label><input id="sf_34" type="checkbox" /><span>上市以来年化收益率(%)</span></label></li>
<li><label><input id="sf_35" type="checkbox" /><span>年化波动率(%)</span></label></li>
<li><label><input id="sf_36" type="checkbox" /><span>市盈率</span></label></li>
<li><label><input id="sf_37" type="checkbox" /><span>PEG</span></label></li>
<li><label><input id="sf_38" type="checkbox" /><span>机构评级</span></label></li>
Expand Down Expand Up @@ -341,7 +361,8 @@ <h4 class="center">筛选结果</h4>
<th class="hide st_6">数据源</th>
<th class="hide st_7">财报审计意见</th>
<th class="hide st_8">价值评估</th>
<th class="hide st_9">最新一期 ROE</th>
<th class="hide st_9">当前ROE</th>
<th class="hide st_55">最近财报ROE</th>
<th class="hide st_10">ROE同比增长</th>
<th class="hide st_11">近五年ROE</th>
<th class="hide st_12">最新一期EPS</th>
Expand Down
62 changes: 60 additions & 2 deletions statics/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $(document).ready(function () {
return result;
};

// 表单提交按钮点击事件
// 基本面选股请求处理
$("#selector_submit_btn").click(function () {
$(this).addClass("disabled");
$("#model_header").text($(this).text() + "中,请稍候...");
Expand Down Expand Up @@ -115,6 +115,10 @@ $(document).ready(function () {
stock.latest_roe +
"%" +
"</td>" +
'<td class="hide st_55">' +
stock.latest_fina_roe +
"%" +
"</td>" +
'<td class="hide st_10">' +
stock.roe_tbzz.toFixed(2) +
"%" +
Expand Down Expand Up @@ -277,6 +281,7 @@ $(document).ready(function () {
});
});

// 个股检测请求处理
$("#checker_submit_btn").click(function () {
if ($("#checker_keyword").val() == "") {
$("#err_msg").text("请填写股票代码或简称");
Expand Down Expand Up @@ -368,6 +373,59 @@ $(document).ready(function () {
});
});

// 筹码面
$("#chip_submit_btn").click(function () {
if ($("#chip_keyword").val() == "") {
$("#err_msg").text("请填写股票代码或简称");
$("#error_modal").modal("open");
return;
}
$(this).addClass("disabled");
$("#model_header").text($(this).text() + "中,请稍候...");
$("#load_modal").modal()[0].M_Modal.options.dismissible = false;
$("#load_modal").modal("open");
$.ajax({
url: "/chip",
type: "post",
data: $("#chip_form").serialize(),
success: function (data) {
if (data.Error) {
$("#err_msg").text(data.Error);
$("#error_modal").modal("open");
$("#checker_submit_btn").removeClass("disabled");
$("#load_modal").modal("close");
return;
}
$("title").text(data.PageTitle);
$("#stock_forms").remove();
$("#chip_results").removeClass("hide");
$.each(data.MainMoneyNetInflows, function (code, inflows) {
$("#chip_result_" + code).append(
'<div class="row">' +
'</br><h5 class="center">年报数据趋势概览</h5>' +
'<div class="col s12 m12 l6">' +
'<svg id="line-chart-' +
i +
'-0"></svg>' +
"</div>" +
'<div class="col s12 m12 l6">' +
'<svg id="line-chart-' +
i +
'-1"></svg>' +
"</div>" +
"</div>"
);
for (let j = 0; j < 2; j++) {
const svg = document.querySelector(`#line-chart-${i}-${j}`);
new chartXkcd.Line(svg, data.Lines[i][j]);
}
});
$("html, body").animate({ scrollTop: 0 }, 0);
$("#load_modal").modal("close");
},
});
});

// 返回顶部按钮
$("#to-top").click(function () {
$("html, body").animate({ scrollTop: 0 }, 500);
Expand Down Expand Up @@ -404,7 +462,7 @@ $(document).ready(function () {
$(".dropdown-content>li>a").css("font-size", "11px");
$(".dropdown-content>li>a").css("font-weight", "normal");

for (let i = 1; i <= 54; i++) {
for (let i = 1; i <= 55; i++) {
$(`#sf_${i}`).change(function () {
checkboxCountCheck();
$(`.st_${i}`).toggleClass("hide");
Expand Down

0 comments on commit 2eb7eaf

Please sign in to comment.