Compare commits

..

No commits in common. '694bb3853661a462c9eb9d353ad336576c027c85' and 'ac9554ba21aa39477fb9ba6e76595402bc80f44c' have entirely different histories.

@ -2,7 +2,7 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g corepack@latest && corepack enable
RUN corepack enable
COPY package.json pnpm-lock.yaml /app/
WORKDIR /app

@ -13,7 +13,7 @@ export const getAvailableUnderlyings = publicProcedure.query(async (opts) => {
// SELECT DISTINCT(symbol) as symbol FROM option_contract_existences WHERE asOfDate = (SELECT max(asOfDate) FROM option_contract_existences)
// `)
// ).map(({ symbol }) => symbol);
return ["SPY"];
return ["AAPL", "AMD", "GOOGL", "MSFT", "NFLX"];
});
export const getAvailableAsOfDates = publicProcedure

@ -30,17 +30,18 @@ export const getChartData = publicProcedure
} = opts.input;
return await query<[number, number, number]>(
`
SELECT
moniness as x,
FLOOR(price, 1) as y,
sum(number_of_quotes) as n
FROM calendar_stats
WHERE dte = ${daysToFrontExpiration}
AND moniness >= -0.05
AND moniness <= 0.05
AND span = ${daysBetweenFrontAndBackExpiration}
AND date >= '${lookbackPeriodStart}'
AND date <= '${lookbackPeriodEnd}'
SELECT
FLOOR(strikePercentageFromUnderlyingPrice, 1) as x,
FLOOR(calendarPrice, 1) as y,
count(*) as n
FROM calendar_histories
WHERE symbol = '${underlying}'
AND daysToFrontExpiration = ${daysToFrontExpiration}
AND strikePercentageFromUnderlyingPrice >= -5.0
AND strikePercentageFromUnderlyingPrice <= 5.0
AND daysBetweenFrontAndBackExpiration = ${daysBetweenFrontAndBackExpiration}
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
GROUP BY x, y
ORDER BY x ASC, y ASC
`,

@ -34,16 +34,17 @@ export const getChartData = publicProcedure
} = opts.input;
return await query<[number, number]>(
`
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}'
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'
`,
"JSONEachRow"
);

@ -17,13 +17,12 @@ export const getChartData = publicProcedure
return await query<[number, number]>(
`
SELECT
toUnixTimestamp(toStartOfHour(ts)) as x,
avg(price) as y
FROM stock_aggregates_filled
toUnixTimestamp(tsStart) as x,
open as y
FROM stock_aggregates
WHERE symbol = '${underlying}'
AND ts >= '${lookbackPeriodStart} 00:00:00'
AND ts <= '${lookbackPeriodEnd} 00:00:00'
GROUP BY x
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
ORDER BY x ASC
`,
"JSONEachRow"

Loading…
Cancel
Save