Compare commits
2 Commits
ac9554ba21
...
694bb38536
| Author | SHA1 | Date | |
|---|---|---|---|
| 694bb38536 | |||
| 64a5172ea8 |
+1
-1
@@ -2,7 +2,7 @@
|
||||
FROM node:20-slim AS base
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
RUN npm install -g corepack@latest && 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 ["AAPL", "AMD", "GOOGL", "MSFT", "NFLX"];
|
||||
return ["SPY"];
|
||||
});
|
||||
|
||||
export const getAvailableAsOfDates = publicProcedure
|
||||
|
||||
@@ -30,18 +30,17 @@ export const getChartData = publicProcedure
|
||||
} = opts.input;
|
||||
return await query<[number, number, number]>(
|
||||
`
|
||||
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'
|
||||
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}'
|
||||
GROUP BY x, y
|
||||
ORDER BY x ASC, y ASC
|
||||
`,
|
||||
|
||||
@@ -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"
|
||||
);
|
||||
|
||||
@@ -17,12 +17,13 @@ export const getChartData = publicProcedure
|
||||
return await query<[number, number]>(
|
||||
`
|
||||
SELECT
|
||||
toUnixTimestamp(tsStart) as x,
|
||||
open as y
|
||||
FROM stock_aggregates
|
||||
toUnixTimestamp(toStartOfHour(ts)) as x,
|
||||
avg(price) as y
|
||||
FROM stock_aggregates_filled
|
||||
WHERE symbol = '${underlying}'
|
||||
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
|
||||
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
|
||||
AND ts >= '${lookbackPeriodStart} 00:00:00'
|
||||
AND ts <= '${lookbackPeriodEnd} 00:00:00'
|
||||
GROUP BY x
|
||||
ORDER BY x ASC
|
||||
`,
|
||||
"JSONEachRow"
|
||||
|
||||
Reference in New Issue
Block a user