|
|
@ -88,6 +88,36 @@ server.get<{
|
|
|
|
).map(x=>x.expiration);
|
|
|
|
).map(x=>x.expiration);
|
|
|
|
reply.status(200).send(expirations);
|
|
|
|
reply.status(200).send(expirations);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
server.get<{
|
|
|
|
|
|
|
|
Params: {underlying:string, strike:string, front_expiration:string, back_expiration:string, },
|
|
|
|
|
|
|
|
}>('/option_quotes/:underlying/:strike/:front_expiration/:back_expiration', async (request, reply) => {
|
|
|
|
|
|
|
|
const strikes = await sql`
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
|
|
"front"."quote_date",
|
|
|
|
|
|
|
|
("back"."bid" - "front"."ask") AS "calendar_price"
|
|
|
|
|
|
|
|
FROM "option_quote" AS "front"
|
|
|
|
|
|
|
|
INNER JOIN "option_quote" AS "back"
|
|
|
|
|
|
|
|
ON
|
|
|
|
|
|
|
|
"front"."type" = "back"."type"
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."underlying" = "back"."underlying"
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."strike" = "back"."strike"
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."quote_date" = "back"."quote_date"
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"back"."expiration" = ${request.params.back_expiration}
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
|
|
"front"."type" = 'call'
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."underlying" = ${request.params.underlying}
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."strike" = ${request.params.strike}
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."expiration" = ${request.params.front_expiration}
|
|
|
|
|
|
|
|
ORDER BY "quote_date";`;
|
|
|
|
|
|
|
|
reply.status(200).send(strikes);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
server.listen({ port: 8234, host: '127.0.0.1' }, (err, address) => {
|
|
|
|
server.listen({ port: 8234, host: '127.0.0.1' }, (err, address) => {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|