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);