From 12d6bec4036d2834d4c2405228d8107df93cc080 Mon Sep 17 00:00:00 2001 From: Avraham Sakal Date: Sun, 15 Oct 2023 19:02:49 -0400 Subject: [PATCH] add underlying quote by date --- src/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/index.ts b/src/index.ts index bf2af4a..e5cc2ae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,20 @@ server.get('/ping', async (request, reply) => { return 'pong\n' }) +server.get<{ + Params: {underlying:string, quote_date:string}, +}>('/underlying_quotes/:underlying/:quote_date', async (request, reply) => { + const underlying_quote = (await sql` + SELECT "high", "low", "open", "close" + FROM "stock_quote" + WHERE + "symbol" = ${request.params.underlying} + AND "quote_date" = ${request.params.quote_date} + ;` + ); + reply.status(200).send(underlying_quote); +}) + server.get('/option_quotes/underlyings', async (request, reply) => { const underlyings = (await sql`SELECT * FROM "underlyings";`).map(x=>x.underlying); reply.status(200).send(underlyings);