Files
stonks-oracle/infra/migrations/025_intraday_market_source.sql
T
Celes Renata 2360c501e4 feat: intraday hourly price bars via Polygon range endpoint
- New 'intraday_bars' endpoint in PolygonMarketAdapter: fetches hourly
  bars for today using range_bars URL with timespan=hour, sort=asc
- Scheduler expands intraday_bars global source into per-ticker jobs
  for all active companies (every 15 minutes via polling_interval)
- Migration 025 inserts the intraday source with 900s cadence
- Frontend price matching uses closest-timestamp instead of date-string
  matching, with 2h tolerance for intraday and 36h for daily windows
- Bumped market price fetch limit to 200 for intraday granularity
2026-04-17 01:13:24 +00:00

16 lines
585 B
SQL

-- Add intraday market data source (hourly bars via Polygon range endpoint).
-- The scheduler expands this into per-ticker jobs every 15 minutes.
INSERT INTO sources (source_type, source_name, config, active, company_id)
SELECT
'market_api',
'Polygon Intraday Hourly',
'{"endpoint": "intraday_bars", "provider": "polygon", "timespan": "hour", "multiplier": 1, "adjusted": true, "polling_interval_seconds": 900}'::jsonb,
true,
NULL
WHERE NOT EXISTS (
SELECT 1 FROM sources
WHERE source_type = 'market_api'
AND config->>'endpoint' = 'intraday_bars'
);