-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.dev.js
47 lines (38 loc) · 1.75 KB
/
index.dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const requestHttp = require('request-promise');
const QuoteSvc = require('./services/quoteService');
const PortFolioSvc = require('./services/portfolioService');
const stockSymbol = 'aapl';
const _ = require('underscore');
// let portfolio = new PortFolio(1);
let portFolioSvc = new PortFolioSvc();
// console.log(portfolio.getUser());
let id = 1;
// const userPortfolio = portFolioSvc.getPortfolioByUserId(id);
// userPortfolio
// const symbolList = _.filter(userPortfolio.txns, function (txn) {
// return txn.symbolName == 'AAPL'
// });
// console.log(symbolList);
// portFolioSvc.getPortfolioBestPerformers(id).then(res => {
// console.log(res);
// });
let quoteSvc = new QuoteSvc();
// quoteSvc.getSymbolInformation(stockSymbol).then(res => {
// let lastRefreshed = new Date(res.latestUpdate);
// let stockDetails = `Stock Details for ${res.companyName} with symbol ${res.symbol} are as follows:
// Open is ${res.open} and Close is ${res.close} with a high of ${res.high} and low of ${res.low}.
// Details last refreshed on ${lastRefreshed.toDateString()} at ${lastRefreshed.toTimeString()}`;
// console.log(stockDetails);
// }).catch(err => {
// console.log('Some Technical Error occurred! Apologies');
// });
quoteSvc.getAllMarketData().then(res => {
let marketDetails = `Dow Jones INDUSTRIAL AVERAGES is at ${res.dji.Close} ${res.dji.changeIdentifier} by ${res.dji.change.toFixed(2)} points, Nasdaq is at ${res.ndq.Close} ${res.ndq.changeIdentifier} by ${res.ndq.change.toFixed(2)} points.`;
console.log(marketDetails)
});
// console.log(portFolioSvc.getOverviewByUserId(1));
// requestHttp(`https://api.iextrading.com/1.0/stock/${stockSymbol}/quote11`).then(res => {
// console.log(res)
// }).catch(err => {
// console.log('hi');
// });