Files
RSSHub/lib/v2/xueqiu/snb.js
T
NathanDaiandTony 6996efd070 fix(route):雪球 基金净值数据来源调整为蛋卷基金 (#9489)
* 雪球基金净值更新调整为蛋卷基金

* Update docs/finance.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update docs/finance.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* refactor: migrate to v2

* fix: parseDate

* fix: fund unnecessary String()

* feat: add radar

* fix: stock comments template

* style: add a linebreak

* docs: fund example path
2022-04-08 23:38:33 +08:00

44 lines
1.3 KiB
JavaScript
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.
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const id = ctx.params.id;
const url = 'https://xueqiu.com/p/' + id;
const response = await got({
method: 'get',
url,
});
const data = response.data;
const pattern = /SNB.cubeInfo = (.+?);/;
const info = pattern.exec(data)[1];
const obj = JSON.parse(info);
const rebalancing_histories = obj.sell_rebalancing.rebalancing_histories;
const snb_title = obj.name + ' 的调仓历史';
const snb_description = obj.description;
const title = obj.name + ' 的上一笔调仓';
let description = '';
for (const some_detail of rebalancing_histories) {
const prev_weight_adjusted = some_detail.prev_weight_adjusted ? some_detail.prev_weight_adjusted : 0;
description += some_detail.stock_name + ' from ' + prev_weight_adjusted + ' to ' + some_detail.target_weight + ',\n';
}
const time = obj.sell_rebalancing.updated_at;
const single = {
title,
description,
pubDate: parseDate(time),
link: url,
guid: `xueqiu::snb::${id}::${time}`,
};
ctx.state.data = {
title: snb_title,
link: url,
description: snb_description,
item: [single],
};
};