|
|
@@ -5,27 +5,36 @@ const vscode = require("vscode");
|
|
|
const axios_1 = require("axios");
|
|
|
function activate() {
|
|
|
// 创建国际黄金状态
|
|
|
- const barItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 9999);
|
|
|
+ const oneItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 9999);
|
|
|
+ const twoItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 9998);
|
|
|
setInterval(() => {
|
|
|
axios_1.default.all([
|
|
|
axios_1.default.post('https://webapi.huilv.cc/api/trend/yaho', { pinzhong: 'CNYUSD', longs: 'd1' }),
|
|
|
- axios_1.default.get('https://push2.eastmoney.com/api/qt/clist/get?fs=m:122&fields=f12,f13,f14,f1,f2,f4,f3,f152,f17,f28,f15,f16,f124&pn=1'),
|
|
|
+ axios_1.default.get('https://futsseapi.eastmoney.com/list/variety/101/1?orderBy=zdf&sort=desc&pageSize=12&pageIndex=0&token=1101ffec61617c99be287c1bec3085ff&field=name,dm,zdf,p'),
|
|
|
axios_1.default.get('https://push2.eastmoney.com/api/qt/stock/get?fields=f58,f734,f107,f57,f43,f59,f169,f170,f152,f177,f111,f46,f60,f44,f45,f86,f47,f19,f532,f161,f171,f48,f39,f49,f50&secid=118.AU9999')
|
|
|
]).then(axios_1.default.spread((rate, interGold, gold) => {
|
|
|
const { data: { obj } } = rate; //汇率
|
|
|
- const { data: { data: { diff } } } = interGold; // 国际金
|
|
|
+ const { data: { list } } = interGold; // 国际金
|
|
|
const { data: { data: { f60, f19 } } } = gold; // 国内
|
|
|
+ // 国际
|
|
|
const rateItem = 1 / obj[obj.length - 1].huilv; //汇率转换
|
|
|
- const interGoldItem = diff['13']['f28'];
|
|
|
- const oneGold = Math.floor(interGoldItem * rateItem / 31.1035) / 100; // 国际金转换
|
|
|
- const twoGold = Math.floor(f19) / 100; // 国内金转换
|
|
|
- const twoNum = Math.floor((f19 - f60)) / 100; //营收
|
|
|
- const twoRate = Math.floor((f19 - f60) / f19 * 10000) / 100; //营收率
|
|
|
- const txt = `$(star-full) 国际AU: ${oneGold} / 国内AU999: ${twoGold}(${twoNum > 0 ? '+' + twoNum : twoNum} ${twoRate > 0 ? '+' + twoRate + '%' : twoRate + '%'})`;
|
|
|
- barItem.text = txt;
|
|
|
+ const { p, zdf } = list.find((el) => el.dm === 'GC00Y') || { p: 0, zdf: 0 };
|
|
|
+ const oneGold = Math.floor(p * rateItem / 31.1035 * 100) / 100 || 0; // 国际金转换
|
|
|
+ const oneTxt = `$(star-full) COMEX黄金: ${oneGold}(${zdf}%)`;
|
|
|
+ oneItem.color = zdf > 0 ? 'red' : 'green';
|
|
|
+ oneItem.text = oneTxt;
|
|
|
+ // 国内
|
|
|
+ const twoGold = Math.floor(f19) / 100 || 0; // 国内金转换
|
|
|
+ const twoNum = Math.floor((f19 - f60)) / 100 || 0; //营收
|
|
|
+ const twoRate = Math.floor((f19 - f60) / f19 * 10000) / 100 || 0; //营收率
|
|
|
+ const twoTxt = `国内AU999: ${twoGold}(${twoNum > 0 ? '+' + twoNum : twoNum} ${twoRate > 0 ? '+' + twoRate + '%' : twoRate + '%'})`;
|
|
|
+ twoItem.color = twoNum > 0 ? 'red' : 'green';
|
|
|
+ twoItem.text = twoTxt;
|
|
|
+ console.log(666, p, rateItem, oneGold, twoGold);
|
|
|
}));
|
|
|
}, 1000);
|
|
|
- barItem.show();
|
|
|
+ oneItem.show();
|
|
|
+ twoItem.show();
|
|
|
}
|
|
|
exports.activate = activate;
|
|
|
function deactivate() { }
|