|
|
|
@ -34,17 +34,16 @@ export const getChartData = publicProcedure
|
|
|
|
|
} = opts.input;
|
|
|
|
|
return await query<[number, number]>(
|
|
|
|
|
`
|
|
|
|
|
SELECT
|
|
|
|
|
toUnixTimestamp(tsStart) as x,
|
|
|
|
|
truncate(calendarPrice, 2) as y
|
|
|
|
|
FROM calendar_histories
|
|
|
|
|
WHERE symbol = '${underlying}'
|
|
|
|
|
AND daysToFrontExpiration = ${daysToFrontExpiration}
|
|
|
|
|
AND strikePercentageFromUnderlyingPrice >= ${strikePercentageFromUnderlyingPriceRangeMin}
|
|
|
|
|
AND strikePercentageFromUnderlyingPrice <= ${strikePercentageFromUnderlyingPriceRangeMax}
|
|
|
|
|
AND daysBetweenFrontAndBackExpiration = ${daysBetweenFrontAndBackExpiration}
|
|
|
|
|
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
|
|
|
|
|
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
|
|
|
|
|
SELECT
|
|
|
|
|
toUnixTimestamp(date) as x,
|
|
|
|
|
price as y
|
|
|
|
|
FROM calendar_stats
|
|
|
|
|
WHERE dte = ${daysToFrontExpiration}
|
|
|
|
|
AND moniness >= ${strikePercentageFromUnderlyingPriceRangeMin}
|
|
|
|
|
AND moniness <= ${strikePercentageFromUnderlyingPriceRangeMax}
|
|
|
|
|
AND span = ${daysBetweenFrontAndBackExpiration}
|
|
|
|
|
AND date >= '${lookbackPeriodStart}'
|
|
|
|
|
AND date <= '${lookbackPeriodEnd}'
|
|
|
|
|
`,
|
|
|
|
|
"JSONEachRow"
|
|
|
|
|
);
|
|
|
|
|