price pipeline
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
d7ec1fb355
commit
d9581d7f7e
16 changed files with 790 additions and 10 deletions
19
migrations/000002_price_history_intraday.up.sql
Normal file
19
migrations/000002_price_history_intraday.up.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
-- Recréation de price_history avec support intraday (plusieurs prix par jour)
|
||||
-- Le job de nettoyage consolide à J-1 en gardant uniquement le dernier fetch
|
||||
DROP TABLE IF EXISTS price_history;
|
||||
|
||||
CREATE TABLE price_history (
|
||||
instrument_id INTEGER NOT NULL REFERENCES instrument(id),
|
||||
fetched_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
prix NUMERIC(24, 8) NOT NULL,
|
||||
PRIMARY KEY (instrument_id, fetched_at)
|
||||
);
|
||||
SELECT create_hypertable('price_history', by_range('fetched_at'));
|
||||
CREATE INDEX idx_price_history_instrument ON price_history(instrument_id, fetched_at DESC);
|
||||
|
||||
-- Cache OpenFIGI (ISIN → ticker Yahoo Finance) et CoinGecko (ticker → coin ID)
|
||||
CREATE TABLE instrument_ticker_cache (
|
||||
instrument_id INTEGER PRIMARY KEY REFERENCES instrument(id) ON DELETE CASCADE,
|
||||
ticker TEXT NOT NULL,
|
||||
fetched_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue