Skip to content

Commit

Permalink
calculation of price at given date failed
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Nov 11, 2024
1 parent 8d01083 commit 7922655
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/api/symbols/[symbol]/historical/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const getPriceAtDate = async (symbol: string, dt: string) => {

const resp = await yf.historical(symbol, {
interval: '1d',
period1: start,
period1: dayjs(start).add(-7, 'day').toDate(), //in case of weekend it somehow blanking out
period2: new Date()
});

return resp.at(0)?.open.toFixed(2);
return resp.at(-1)?.close.toFixed(2);
}

function isUSMarketOpenedForToday(): boolean {
Expand Down

0 comments on commit 7922655

Please sign in to comment.