使用 Meteor Package 从 Yahoo Finance 抓取数据,有些有效有些无效

Grab data from Yahoo Finance using Meteor Package, some work some do not

我正在为 Meteor 使用以下包 https://atmospherejs.com/ajbarry/yahoo-finance

我似乎无法让指定的字段工作,here 是一个 link,其中包含所有可用字段的列表,但是 'j2' 和我测试的其他一些字段没有没用,从某种意义上说,结果对象中没有响应,或者没有 json 密钥对值。

这是我的客户端代码。

Template.stock.rendered = function (){
    if ( _.isEmpty(Session.get('ENW.V')) ) {
        Meteor.call('getQuote', 'ENW.V', function(err, result) {
            Session.set('ENW.V', result['ENW.V']);
            console.log(result)
        });
    }
}


Template.stock.helpers({
    stock: function() {
        return Session.get('ENW.V');
    }
})

服务器端方法

Meteor.methods({
  getQuote: function( stockname ) {
    return YahooFinance.snapshot({symbols: [stockname] , fields:['n','a','b','j2'] });
  }
});

感谢您的提前帮助。如果需要,很乐意添加任何其他信息。

在注释掉该行后进行了测试 运行,似乎工作正常。与包所有者一起创建问题,看看是否可以长期修复它 运行。


您使用的包故意排除了这些字段。什么原因,我说不上来。有关它正在避免的字段的完整列表,请查看此处:

https://github.com/pilwon/node-yahoo-finance/blob/master/lib/index.js#L122