Skip to content

Unilever - #185

Open
Khashayarbayati1 wants to merge 3 commits into
VectorInstitute:mainfrom
mehrshadkafi:unilever
Open

Unilever#185
Khashayarbayati1 wants to merge 3 commits into
VectorInstitute:mainfrom
mehrshadkafi:unilever

Conversation

@Khashayarbayati1

Copy link
Copy Markdown

Summary

Clickup Ticket(s): Link(s) if applicable.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test improvements
  • 🔒 Security fix

Changes Made

Testing

  • Tests pass locally (uv run pytest tests/)
  • Type checking passes (uv run mypy <src_dir>)
  • Linting passes (uv run ruff check src_dir/)
  • Manual testing performed (describe below)

Manual testing details:

Screenshots/Recordings

Related Issues

Deployment Notes

Checklist

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Documentation updated (if applicable)
  • No sensitive information (API keys, credentials) exposed

mehrshad-unilever and others added 2 commits August 6, 2026 13:19
FRED carries no palm kernel oil series, so this targets palm oil
(PPOILUSDM, IMF monthly, USD/tonne, 414 observations). See DATA.md for
the full survey and the open decision on the commodity.

FREDAdapter approximates released_at = timestamp, which would expose a
monthly price up to 42 days before it was published — a leak at every
origin in a monthly backtest. data.py fetches each observation's true
first-publication date from FRED's real-time archive (output_type=4) and
registers the corrected frame, so CutoffEnforcer withholds each price
until FRED actually released it.

- scripts/explore_fred_oils.py: FRED catalogue survey + publication-lag
  measurement, excluding archive backfills that would distort the lag
- implementations/pko/data.py: build_palm_oil_service() with honest
  released_at; verified June 2026 first appears at a 2026-07-13 cutoff
- implementations/pko/plots.py: five interactive Plotly charts on the
  validated categorical palette, with direct labels where contrast needs
  relief
- implementations/pko/01_pko_data_exploration.ipynb: executed tour of the
  series, the 7 candidate cutoffs, and the information gap
- implementations/pko/DATA.md: shareable survey write-up

Two publication blackouts matter for cutoff choice: Dec 2021–Aug 2022
(covering the Indonesian export ban) and Jul 2025–Jan 2026. All 7
candidate cutoffs sit at a 2-month information gap so they stay
comparable.
FRED's monthly palm oil price is published ~2 months late and stopped
entirely for six months twice, which caps the newest usable forecast
origin at 2025-08 and rules out weekly news alignment. The daily CME
Crude Palm Oil settlement price (Yahoo CPO=F) has no publication lag —
timestamp is the release date — so it reaches 2026 origins and supports
weekly GDELT matching.

Registers two series off one fetch: palm_oil_futures_daily (3,916 rows,
2010-05 onward) and palm_oil_futures_weekly (814 Friday closes). The
weekly grid is complete since 2017 — 500 of 500 expected Fridays — so
weekly forecast dates resolve under the harness's exact-timestamp match.
The FRED service and its release-date handling are unchanged, and remain
useful as a monthly cross-check.

KNOWN ISSUE — not yet fixed. CPO=F carries a monthly contract-roll
artifact: 19 of the 20 largest daily moves since 2017 fall on the first
trading day of a month, averaging 3.57% against 0.68% on other days
(5.2x). Cross-checking against FRED confirms these are partly synthetic
— April 2022 shows -12.78% in CPO=F but only -2.40% month-over-month in
FRED. The effect is specific to this contract, not to Yahoo's futures
handling generally (CL=F measures 1.0x with no clustering).

A 4-week forecast window spans one roll, so returns and volatility are
contaminated and a baseline is penalised for missing non-economic jumps.
Resolve before selecting cutoffs — either roll-adjust the series, use
monthly averages of the daily data, or confirm the intended MPOB source.
Caveats are documented inline above the new section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants