|
|
@ -91,32 +91,26 @@ server.get<{
|
|
|
|
server.get<{
|
|
|
|
server.get<{
|
|
|
|
Params: {underlying:string, strike:string, front_expiration:string, back_expiration:string, },
|
|
|
|
Params: {underlying:string, strike:string, front_expiration:string, back_expiration:string, },
|
|
|
|
}>('/option_quotes/:underlying/:strike/:front_expiration/:back_expiration', async (request, reply) => {
|
|
|
|
}>('/option_quotes/:underlying/:strike/:front_expiration/:back_expiration', async (request, reply) => {
|
|
|
|
const strikes = await sql`
|
|
|
|
const prices = await sql`
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
"front"."quote_date",
|
|
|
|
"front_contract"."quote_date",
|
|
|
|
("back"."bid" - "front"."ask") AS "calendar_price"
|
|
|
|
("back_contract"."ask" - "front_contract"."bid") AS "price"
|
|
|
|
FROM "option_quote" AS "front"
|
|
|
|
FROM
|
|
|
|
INNER JOIN "option_quote" AS "back"
|
|
|
|
"option_quote" AS "front_contract"
|
|
|
|
|
|
|
|
INNER JOIN
|
|
|
|
|
|
|
|
"option_quote" AS "back_contract"
|
|
|
|
ON
|
|
|
|
ON
|
|
|
|
"front"."type" = "back"."type"
|
|
|
|
"back_contract"."underlying" = "front_contract"."underlying"
|
|
|
|
AND
|
|
|
|
AND "back_contract"."type" = "front_contract"."type"
|
|
|
|
"front"."underlying" = "back"."underlying"
|
|
|
|
AND "back_contract"."quote_date" = "front_contract"."quote_date"
|
|
|
|
AND
|
|
|
|
AND "back_contract"."strike" = "front_contract"."strike"
|
|
|
|
"front"."strike" = "back"."strike"
|
|
|
|
AND "back_contract"."expiration" = ${request.params.back_expiration}
|
|
|
|
AND
|
|
|
|
|
|
|
|
"front"."quote_date" = "back"."quote_date"
|
|
|
|
|
|
|
|
AND
|
|
|
|
|
|
|
|
"back"."expiration" = ${request.params.back_expiration}
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
WHERE
|
|
|
|
"front"."type" = 'call'
|
|
|
|
"front_contract"."underlying" = ${request.params.underlying}
|
|
|
|
AND
|
|
|
|
AND "front_contract"."type" = 'call'
|
|
|
|
"front"."underlying" = ${request.params.underlying}
|
|
|
|
AND "front_contract"."strike" = ${request.params.strike}
|
|
|
|
AND
|
|
|
|
AND "front_contract"."expiration" = ${request.params.front_expiration}`;
|
|
|
|
"front"."strike" = ${request.params.strike}
|
|
|
|
reply.status(200).send(prices);
|
|
|
|
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) => {
|
|
|
|