如何获取两个日期之间的历史股票数据?

时间:2017-10-08 13:00:35

标签: node.js httprequest stockquotes

我正试图从Google财经中获取findDublicates() { let match = 0; // setting it to 0, so later could assign other number let keys = []; // list of maching keys let elementAt = 0; // index of item of first observable let allKeys$; let validKeys$; // counting the length of both observables, so this will be the number of loops // that checks for dublicates let allKeysLength; let validKeysLength; let allKeysLength$ = Observable.of(2, 1, 4, 5, 7).count() allKeysLength$.subscribe(val => allKeysLength = val) let validKeysLength$ = Observable.of(1, 2, 3, 8, 5).count() validKeysLength$.subscribe(val => validKeysLength = val) let cycles = Math.min(allKeysLength,validKeysLength); // length of the shorter observable // wrapping it in a function so when called variables will take new values function defineObs() { allKeys$ = Observable.of(2, 1, 4, 5, 7) .elementAt(elementAt).take(1); validKeys$ = Observable.of(1, 2, 3, 8, 5) .filter((x) => (x === match)).first(); } for (var i=0; i<=cycles; i++) { defineObs(); allKeys$.subscribe( function (val) { match = val }, function (err) { console.log(err) }, function () { console.log('Done filter')} ); validKeys$.subscribe( function (val) { keys.push(val) }, function (err) { console.log(err) }, function () { console.log('Done push')} ); elementAt += 1; cycles -= 1; } return console.log(keys); } 的历史数据。 但是开始和结束时间总是一样的。

google-finance模块中发送带有这些参数的get请求到Apple

应该会导致日期之间的历史数据,但会在去年返回。

http://www.google.com/finance/historical

var params = { q: 'AAPL', startdate: '2014-01-01', enddate: '2014-12-31', output: 'csv' }; 模块示例:

google-finance

结果总是从今天(2017年8月8日)到一年前(2016年8月8日):

gFinance.historical({
  symbol: 'NASDAQ:AAPL',
  from: '2014-01-01',
  to: '2014-12-31'
}, function (err, quotes) {
   console.log(quotes);
});

我不知道他们是否改变了某些东西,或者他们像雅虎那样关闭它或者我做错了什么。 我搜索了一个星期,一切似乎都过时了。 如何使用http请求在自定义时间之间获取历史数据?

1 个答案:

答案 0 :(得分:0)