diff --git a/ingest-option-quotes.ts b/ingest-option-quotes.ts index 90f4132..df69c63 100644 --- a/ingest-option-quotes.ts +++ b/ingest-option-quotes.ts @@ -9,6 +9,9 @@ dotenv.config(); const env = new Env(); const POLYGON_API_KEY = env.require("POLYGON_API_KEY"); const CONCURRENCY = Number.parseInt(env.get("CONCURRENCY", "6")); +const OPTION_QUOTES_TABLE = env.get("OPTION_QUOTES_TABLE", "option_quotes"); +const START_DATE = env.get("START_DATE", "2022-06-07"); +const END_DATE = env.get("END_DATE", "2025-01-03"); const polygon = restClient(POLYGON_API_KEY, "https://api.polygon.io", { pagination: true, @@ -38,7 +41,7 @@ function* dateRange( } } -for (const date of dateRange("2024-05-02", "2024-05-03")) { +for (const date of dateRange(START_DATE, END_DATE)) { const contracts = await polygon.reference.optionsContracts({ underlying_ticker: "SPY", as_of: date, @@ -62,7 +65,7 @@ for (const date of dateRange("2024-05-02", "2024-05-03")) { ); if (quotes.status?.toLowerCase() === "ok" && quotes.results) { await client.insert({ - table: "option_quotes2", + table: OPTION_QUOTES_TABLE, values: quotes.results.map( ({ bid_price, ask_price, sip_timestamp }) => ({ option_type: contract.contract_type, @@ -76,13 +79,14 @@ for (const date of dateRange("2024-05-02", "2024-05-03")) { ), format: "JSONEachRow", }); - console.log(date, contract.ticker, quotes.results?.length); + // console.log(date, contract.ticker, quotes.results?.length); } } }); } } } + console.log("finished", date); } // const data = await polygon.options.quotes(