-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (41 loc) · 1.02 KB
/
index.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
const arvish = require("arvish");
const apiToken = process.env.token;
arvish
.fetch(
`https://cloud.iexapis.com/v1/stock/${
arvish.input
}/quote?token=${apiToken.trim()}`
)
.then((result) => {
const percentage = (result.changePercent * 100).toFixed(2);
const week52Low = result.week52Low.toFixed(2);
const week52High = result.week52High.toFixed(2);
const extendedChange = (result.extendedChangePercent * 100).toFixed(2);
let emoji = "📈";
if (percentage < 0) {
emoji = "📉";
}
const items = [
{
title:
result.symbol +
": " +
result.latestPrice +
" | Change: " +
percentage +
"%" +
emoji,
subtitle:
"Extended Change Percent:" +
extendedChange +
"% | 52 Week Low/High: " +
week52Low +
" - " +
week52High,
},
];
arvish.output(items);
})
.catch((err) => {
arvish.error("Stock Is " + err.statusMessage);
});