reduce data points for historical exit quotes by aggregating and applying weighted transparency

clean frontend html structure
This commit is contained in:
Avraham Sakal
2024-06-23 21:07:36 -04:00
parent 28caba57ca
commit ad66397639
3 changed files with 57 additions and 24 deletions
+21 -11
View File
@@ -1,18 +1,28 @@
import _ from './env.js';
import { createClient as createClickhouseClient } from '@clickhouse/client';
import type { DataFormat } from '@clickhouse/client';
import _ from "./env.js";
import { createClient as createClickhouseClient } from "@clickhouse/client";
import type { DataFormat } from "@clickhouse/client";
// prevent from tree-shaking:
console.log(_);
export const clickhouse = createClickhouseClient({
host: process.env.CLICKHOUSE_HOST || "http://localhost:8123",
username:'avraham',
password:'buginoo'
username: "avraham",
password: "buginoo",
});
export async function query<T>(queryString:string, format:DataFormat='JSONEachRow') : Promise<Array<T>>{
return await (await clickhouse.query({
query: queryString,
format
})).json()
}
export async function query<T>(
queryString: string,
format: DataFormat = "JSONEachRow"
): Promise<Array<T>> {
return await (
await clickhouse.query({
query: queryString,
format,
clickhouse_settings: {
output_format_json_quote_64bit_integers: 0,
//output_format_json_quote_64bit_floats: false,
//output_format_json_quote_64bit_decimals: false,
},
})
).json();
}
+5 -3
View File
@@ -281,11 +281,12 @@ const appRouter = router({
lookbackPeriodStart,
lookbackPeriodEnd,
} = opts.input;
return await query<[number, number]>(
return await query<[number, number, number]>(
`
SELECT
FLOOR(strikePercentageFromUnderlyingPrice, 1) as x,
truncate(calendarPrice, 2) as y
FLOOR(calendarPrice, 1) as y,
count(*) as n
FROM calendar_histories
WHERE symbol = '${underlying}'
AND daysToFrontExpiration = ${daysToFrontExpiration}
@@ -294,7 +295,8 @@ const appRouter = router({
AND daysBetweenFrontAndBackExpiration = ${daysBetweenFrontAndBackExpiration}
AND tsStart >= '${lookbackPeriodStart} 00:00:00'
AND tsStart <= '${lookbackPeriodEnd} 00:00:00'
ORDER BY x ASC
GROUP BY x, y
ORDER BY x ASC, y ASC
`,
"JSONEachRow"
);