Compare commits
2 Commits
ac9554ba21
...
694bb38536
| Author | SHA1 | Date | |
|---|---|---|---|
| 694bb38536 | |||
| 64a5172ea8 |
+1
-1
@@ -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 corepack enable
|
RUN npm install -g corepack@latest && 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 ["AAPL", "AMD", "GOOGL", "MSFT", "NFLX"];
|
return ["SPY"];
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getAvailableAsOfDates = publicProcedure
|
export const getAvailableAsOfDates = publicProcedure
|
||||||
|
|||||||
@@ -31,17 +31,16 @@ export const getChartData = publicProcedure
|
|||||||
return await query<[number, number, number]>(
|
return await query<[number, number, number]>(
|
||||||
`
|
`
|
||||||
SELECT
|
SELECT
|
||||||
FLOOR(strikePercentageFromUnderlyingPrice, 1) as x,
|
moniness as x,
|
||||||
FLOOR(calendarPrice, 1) as y,
|
FLOOR(price, 1) as y,
|
||||||
count(*) as n
|
sum(number_of_quotes) as n
|
||||||
FROM calendar_histories
|
FROM calendar_stats
|
||||||
WHERE symbol = '${underlying}'
|
WHERE dte = ${daysToFrontExpiration}
|
||||||
AND daysToFrontExpiration = ${daysToFrontExpiration}
|
AND moniness >= -0.05
|
||||||
AND strikePercentageFromUnderlyingPrice >= -5.0
|
AND moniness <= 0.05
|
||||||
AND strikePercentageFromUnderlyingPrice <= 5.0
|
AND span = ${daysBetweenFrontAndBackExpiration}
|
||||||
AND daysBetweenFrontAndBackExpiration = ${daysBetweenFrontAndBackExpiration}
|
AND date >= '${lookbackPeriodStart}'
|
||||||
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
|
AND date <= '${lookbackPeriodEnd}'
|
||||||
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
|
||||||
`,
|
`,
|
||||||
|
|||||||
@@ -35,16 +35,15 @@ export const getChartData = publicProcedure
|
|||||||
return await query<[number, number]>(
|
return await query<[number, number]>(
|
||||||
`
|
`
|
||||||
SELECT
|
SELECT
|
||||||
toUnixTimestamp(tsStart) as x,
|
toUnixTimestamp(date) as x,
|
||||||
truncate(calendarPrice, 2) as y
|
price as y
|
||||||
FROM calendar_histories
|
FROM calendar_stats
|
||||||
WHERE symbol = '${underlying}'
|
WHERE dte = ${daysToFrontExpiration}
|
||||||
AND daysToFrontExpiration = ${daysToFrontExpiration}
|
AND moniness >= ${strikePercentageFromUnderlyingPriceRangeMin}
|
||||||
AND strikePercentageFromUnderlyingPrice >= ${strikePercentageFromUnderlyingPriceRangeMin}
|
AND moniness <= ${strikePercentageFromUnderlyingPriceRangeMax}
|
||||||
AND strikePercentageFromUnderlyingPrice <= ${strikePercentageFromUnderlyingPriceRangeMax}
|
AND span = ${daysBetweenFrontAndBackExpiration}
|
||||||
AND daysBetweenFrontAndBackExpiration = ${daysBetweenFrontAndBackExpiration}
|
AND date >= '${lookbackPeriodStart}'
|
||||||
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
|
AND date <= '${lookbackPeriodEnd}'
|
||||||
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
|
|
||||||
`,
|
`,
|
||||||
"JSONEachRow"
|
"JSONEachRow"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ export const getChartData = publicProcedure
|
|||||||
return await query<[number, number]>(
|
return await query<[number, number]>(
|
||||||
`
|
`
|
||||||
SELECT
|
SELECT
|
||||||
toUnixTimestamp(tsStart) as x,
|
toUnixTimestamp(toStartOfHour(ts)) as x,
|
||||||
open as y
|
avg(price) as y
|
||||||
FROM stock_aggregates
|
FROM stock_aggregates_filled
|
||||||
WHERE symbol = '${underlying}'
|
WHERE symbol = '${underlying}'
|
||||||
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
|
AND ts >= '${lookbackPeriodStart} 00:00:00'
|
||||||
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
|
AND ts <= '${lookbackPeriodEnd} 00:00:00'
|
||||||
|
GROUP BY x
|
||||||
ORDER BY x ASC
|
ORDER BY x ASC
|
||||||
`,
|
`,
|
||||||
"JSONEachRow"
|
"JSONEachRow"
|
||||||
|
|||||||
Reference in New Issue
Block a user