Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { msToIsoDate } from "https://esm.town/v/rwev/msToIsoDate";
import { toPercentChange } from "https://esm.town/v/rwev/toPercentChange";
import { polygonTickerSummary } from "https://esm.town/v/rwev/polygonTickerSummary";
export async function polygonEmailTickerSummary(ticker) {
const summary = await polygonTickerSummary(ticker);
const message = `${ticker} closed at ${
summary.day.price
} yesterday, which is ${toPercentChange(
summary.week.price,
summary.day.price
)} compared to a week ago, and ${toPercentChange(
summary.year.price,
summary.day.price
)} compared to a year ago`;
// console.log(message);
console.email(
message,
`Price summary for ${ticker} (${msToIsoDate(Date.now())})`
);
}
October 23, 2023