使用meteor软件包从雅虎财务中获取数据,有些值不起作用

时间:2015-05-05 01:20:00

标签: json meteor yahoo-finance

我正在使用以下Meteor包https://atmospherejs.com/ajbarry/yahoo-finance 使用YQL控制台并搜索" ENW.V"符号,我可以找回某些数据,但有些数据不起作用。 这是我的模板。

    <template name="stock">
     <h2>{{stock.symbol}}</h2>
       <ul>
        <li><strong>Name</strong> {{stock.name}}</li>
        <li><strong>Ask</strong> {{stock.ask}}</li>
        <li><strong>Bid</strong> {{stock.bid}}</li>
        <li><strong>Average Daily Volume</strong> {{stock.DaysHigh}}</li>
       </ul>
    </template>

Heres是我的客户端代码:

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']);
    });
  }
}

这是我的服务器端代码:

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

以下是json响应的示例,此处是查看它的链接here

 "quote": {
        "symbol": "ENW.V",
        "Ask": "1.12",
        "AverageDailyVolume": "56995",
        "Bid": "1.04",
        "AskRealtime": null,
        "BidRealtime": null,
        "BookValue": "0.14",
        "Change_PercentChange": "+0.06 - +5.94%",
        "Change": "+0.06",
        "Commission": null,
        "Currency": "CAD",
        "ChangeRealtime": null,
        "AfterHoursChangeRealtime": null,
        "DividendShare": null,
        "LastTradeDate": "5/4/2015",
        "TradeDate": null,
        "EarningsShare": "-0.05",
        "ErrorIndicationreturnedforsymbolchangedinvalid": null,
        "EPSEstimateCurrentYear": null,
        "EPSEstimateNextYear": null,
        "EPSEstimateNextQuarter": "0.00",
        "DaysLow": "1.02",
        "DaysHigh": "1.10",
        "YearLow": "0.99",
        "YearHigh": "1.52",
        "HoldingsGainPercent": null,
        "AnnualizedGain": null,
        "HoldingsGain": null,
        "HoldingsGainPercentRealtime": null,
        "HoldingsGainRealtime": null,
        "MoreInfo": null,
        "OrderBookRealtime": null,
        "MarketCapitalization": "90.39M",
        "MarketCapRealtime": null,
        "EBITDA": "-2.87M",
        "ChangeFromYearLow": "0.08",
        "PercentChangeFromYearLow": "+8.08%",
        "LastTradeRealtimeWithTime": null,
        "ChangePercentRealtime": null,
        "ChangeFromYearHigh": "-0.45",
        "PercebtChangeFromYearHigh": "-29.61%",
        "LastTradeWithTime": "3:29pm - <b>1.07</b>",
        "LastTradePriceOnly": "1.07",
        "HighLimit": null,
        "LowLimit": null,
        "DaysRange": "1.02 - 1.10",
        "DaysRangeRealtime": null,
        "FiftydayMovingAverage": "1.07",
        "TwoHundreddayMovingAverage": "1.15",
        "ChangeFromTwoHundreddayMovingAverage": "-0.08",
        "PercentChangeFromTwoHundreddayMovingAverage": "-6.88%",
        "ChangeFromFiftydayMovingAverage": "-0.00",
        "PercentChangeFromFiftydayMovingAverage": "-0.44%",
        "Name": "ENWAVE CORP",
        "Notes": null,
        "Open": "1.05",
        "PreviousClose": "1.01",
        "PricePaid": null,
        "ChangeinPercent": "+5.94%",
        "PriceSales": "16.11",
        "PriceBook": "7.06",
        "ExDividendDate": null,
        "PERatio": null,
        "DividendPayDate": null,
        "PERatioRealtime": null,
        "PEGRatio": "0.00",
        "PriceEPSEstimateCurrentYear": null,
        "PriceEPSEstimateNextYear": null,
        "Symbol": "ENW.V",
        "SharesOwned": null,
        "ShortRatio": "1.60",
        "LastTradeTime": "3:29pm",
        "TickerTrend": null,
        "OneyrTargetPrice": null,
        "Volume": "60650",
        "HoldingsValue": null,
        "HoldingsValueRealtime": null,
        "YearRange": "0.99 - 1.52",
        "DaysValueChange": null,
        "DaysValueChangeRealtime": null,
        "StockExchange": "VAN",
        "DividendYield": null,
        "PercentChange": "+5.94%"
       }
      }

这是无效的库存数据。的 {{stock.DaysHigh}}

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

1 个答案:

答案 0 :(得分:1)

根据README包中的指令,如果需要超过默认值,则需要指定整个字段列表。

这是指向可用字段列表的链接:

https://github.com/pilwon/node-yahoo-finance/blob/master/lib/fields.js

YahooFinance.snapshot({symbols:['ENW.V'], fields:['s','n','g']})

g是DaysHigh符号。