Compare commits

..

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

@ -2,7 +2,7 @@
FROM node:20-slim AS base FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm" ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH" ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g corepack@latest && corepack enable RUN corepack enable
COPY package.json pnpm-lock.yaml /app/ COPY package.json pnpm-lock.yaml /app/
WORKDIR /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) // SELECT DISTINCT(symbol) as symbol FROM option_contract_existences WHERE asOfDate = (SELECT max(asOfDate) FROM option_contract_existences)
// `) // `)
// ).map(({ symbol }) => symbol); // ).map(({ symbol }) => symbol);
return ["SPY"]; return ["AAPL", "AMD", "GOOGL", "MSFT", "NFLX"];
}); });
export const getAvailableAsOfDates = publicProcedure export const getAvailableAsOfDates = publicProcedure

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

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

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

Loading…
Cancel
Save