-
-
Notifications
You must be signed in to change notification settings - Fork 705
Add London Stock Exchange (LSE) holidays #3654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 5 commits
949dcc8
613b182
b0d20a8
57ea02b
9616c6b
9ae5b15
0e8d186
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # holidays | ||
| # -------- | ||
| # A fast, efficient Python library for generating country, province and state | ||
| # specific sets of holidays on the fly. It aims to make determining whether a | ||
| # specific date is a holiday as fast and flexible as possible. | ||
| # | ||
| # Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
| # dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
| # ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
|
|
||
| from gettext import gettext as tr | ||
|
|
||
| from holidays.constants import HALF_DAY, PUBLIC | ||
| from holidays.countries.united_kingdom import UnitedKingdom | ||
| from holidays.mixins.child_entity import ChildEntity | ||
|
|
||
|
|
||
| class LondonStockExchange(ChildEntity, UnitedKingdom): | ||
| """London Stock Exchange (LSE) holidays. | ||
|
|
||
| The London Stock Exchange is closed on the bank holidays observed in | ||
| England and Wales. | ||
|
|
||
| On Christmas Eve and New Year's Eve the exchange runs a shortened trading | ||
| session. | ||
|
|
||
| References: | ||
| * <https://en.wikipedia.org/wiki/London_Stock_Exchange> | ||
| * <https://en.wikipedia.org/wiki/Bank_holiday> | ||
| * [LSE business days](https://www.londonstockexchange.com/equities-trading/business-days) | ||
| """ | ||
|
|
||
| country = None # type: ignore[assignment] | ||
| market = "XLON" | ||
| parent_entity = UnitedKingdom | ||
| parent_entity_subdivision_code = "ENG" | ||
| supported_categories = (HALF_DAY, PUBLIC) | ||
| start_year = 2000 | ||
|
|
||
| def _populate_half_day_holidays(self) -> None: | ||
| # %s (markets close at 12:30pm). | ||
| close_12_30pm_label = tr("%s (markets close at 12:30pm)") | ||
|
|
||
| self._add_christmas_eve( | ||
| # Christmas Eve. | ||
| self._format_holiday_name(close_12_30pm_label, tr("Christmas Eve")) | ||
| ) | ||
|
|
||
| self._add_new_years_eve( | ||
| # New Year's Eve. | ||
| self._format_holiday_name(close_12_30pm_label, tr("New Year's Eve")) | ||
| ) | ||
|
|
||
|
|
||
| class XLON(LondonStockExchange): | ||
| pass | ||
|
|
||
|
|
||
| class LSE(LondonStockExchange): | ||
| pass | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # holidays | ||
| # -------- | ||
| # A fast, efficient Python library for generating country, province and state | ||
| # specific sets of holidays on the fly. It aims to make determining whether a | ||
| # specific date is a holiday as fast and flexible as possible. | ||
| # | ||
| # Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
| # dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
| # ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
| # | ||
| # London Stock Exchange (LSE) holidays. | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Holidays 0.100\n" | ||
| "Report-Msgid-Bugs-To: l10n@vacanza.dev\n" | ||
| "POT-Creation-Date: 2026-07-09 00:00+0530\n" | ||
| "PO-Revision-Date: 2026-07-09 00:00+0530\n" | ||
| "Last-Translator: eeshsaxena <eeshsaxena@gmail.com>\n" | ||
| "Language-Team: Holidays Localization Team\n" | ||
| "Language: en_GB\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Generated-By: Lingva 5.0.6\n" | ||
| "X-Source-Language: en_GB\n" | ||
|
|
||
| #. %s (markets close at 12:30pm). | ||
| #, c-format | ||
| msgid "%s (markets close at 12:30pm)" | ||
| msgstr "" | ||
|
|
||
| #. Christmas Eve. | ||
| msgid "Christmas Eve" | ||
| msgstr "" | ||
|
|
||
| #. New Year's Eve. | ||
| msgid "New Year's Eve" | ||
| msgstr "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # holidays | ||
| # -------- | ||
| # A fast, efficient Python library for generating country, province and state | ||
| # specific sets of holidays on the fly. It aims to make determining whether a | ||
| # specific date is a holiday as fast and flexible as possible. | ||
| # | ||
| # Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
| # dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
| # ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
| # | ||
| # London Stock Exchange (LSE) holidays en_US localization. | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Holidays 0.100\n" | ||
| "Report-Msgid-Bugs-To: l10n@vacanza.dev\n" | ||
| "POT-Creation-Date: 2026-07-09 00:00+0530\n" | ||
| "PO-Revision-Date: 2026-07-09 00:00+0530\n" | ||
| "Last-Translator: eeshsaxena <eeshsaxena@gmail.com>\n" | ||
| "Language-Team: Holidays Localization Team\n" | ||
| "Language: en_US\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Generated-By: Lingva 5.0.6\n" | ||
| "X-Source-Language: en_GB\n" | ||
|
|
||
| #. %s (markets close at 12:30pm). | ||
| #, c-format | ||
| msgid "%s (markets close at 12:30pm)" | ||
| msgstr "%s (markets close at 12:30pm)" | ||
|
|
||
| #. Christmas Eve. | ||
| msgid "Christmas Eve" | ||
| msgstr "Christmas Eve" | ||
|
|
||
| #. New Year's Eve. | ||
| msgid "New Year's Eve" | ||
| msgstr "New Year's Eve" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # holidays | ||
| # -------- | ||
| # A fast, efficient Python library for generating country, province and state | ||
| # specific sets of holidays on the fly. It aims to make determining whether a | ||
| # specific date is a holiday as fast and flexible as possible. | ||
| # | ||
| # Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
| # dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
| # ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
| # | ||
| # London Stock Exchange (LSE) holidays th localization. | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Holidays 0.100\n" | ||
| "Report-Msgid-Bugs-To: l10n@vacanza.dev\n" | ||
| "POT-Creation-Date: 2026-07-09 00:00+0530\n" | ||
| "PO-Revision-Date: 2026-07-09 00:00+0530\n" | ||
| "Last-Translator: eeshsaxena <eeshsaxena@gmail.com>\n" | ||
| "Language-Team: Holidays Localization Team\n" | ||
| "Language: th\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Generated-By: Lingva 5.0.6\n" | ||
| "X-Source-Language: en_GB\n" | ||
|
|
||
| #. %s (markets close at 12:30pm). | ||
| #, c-format | ||
| msgid "%s (markets close at 12:30pm)" | ||
| msgstr "%s (ตลาดปิดเวลา 12:30 น.)" | ||
|
|
||
| #. Christmas Eve. | ||
| msgid "Christmas Eve" | ||
| msgstr "วันคริสต์มาสอีฟ" | ||
|
|
||
| #. New Year's Eve. | ||
| msgid "New Year's Eve" | ||
| msgstr "วันสิ้นปี" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,106 @@ | ||||||||||||||||
| # holidays | ||||||||||||||||
|
KJhellico marked this conversation as resolved.
|
||||||||||||||||
| # -------- | ||||||||||||||||
| # A fast, efficient Python library for generating country, province and state | ||||||||||||||||
| # specific sets of holidays on the fly. It aims to make determining whether a | ||||||||||||||||
| # specific date is a holiday as fast and flexible as possible. | ||||||||||||||||
| # | ||||||||||||||||
| # Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||||||||||||||||
| # dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||||||||||||||||
| # ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||||||||||||||||
| # Website: https://github.com/vacanza/holidays | ||||||||||||||||
| # License: MIT (see LICENSE file) | ||||||||||||||||
|
|
||||||||||||||||
| from unittest import TestCase | ||||||||||||||||
|
|
||||||||||||||||
| from holidays.financial.london_stock_exchange import LondonStockExchange, XLON, LSE | ||||||||||||||||
| from tests.common import CommonFinancialTests | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class TestLondonStockExchange(CommonFinancialTests, TestCase): | ||||||||||||||||
| @classmethod | ||||||||||||||||
| def setUpClass(cls): | ||||||||||||||||
| super().setUpClass(LondonStockExchange) | ||||||||||||||||
|
|
||||||||||||||||
| def test_code(self): | ||||||||||||||||
| self.assertTrue(hasattr(self.holidays, "market")) | ||||||||||||||||
| self.assertIsNone(getattr(self.holidays, "country", None)) | ||||||||||||||||
|
|
||||||||||||||||
| def test_market_aliases(self): | ||||||||||||||||
| self.assertAliases(LondonStockExchange, XLON, LSE) | ||||||||||||||||
|
|
||||||||||||||||
| def test_no_holidays(self): | ||||||||||||||||
| self.assertNoHolidays(LondonStockExchange(years=1999)) | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+28
to
+33
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eeshsaxena, this remains relevant. |
||||||||||||||||
| def test_2022(self): | ||||||||||||||||
| # Exercises the royal one-off bank holidays alongside the regular | ||||||||||||||||
| # England & Wales calendar; year-by-year correctness of the underlying | ||||||||||||||||
| # calendar itself is covered by the United Kingdom test suite. | ||||||||||||||||
| self.assertHolidays( | ||||||||||||||||
| LondonStockExchange(years=2022), | ||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
An place this test before l10n tests.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eeshsaxena, the suggestion includes removing the redundant comment. |
||||||||||||||||
| ("2022-01-01", "New Year's Day"), | ||||||||||||||||
| ("2022-01-03", "New Year's Day (observed)"), | ||||||||||||||||
| ("2022-04-15", "Good Friday"), | ||||||||||||||||
| ("2022-04-18", "Easter Monday"), | ||||||||||||||||
| ("2022-05-02", "May Day"), | ||||||||||||||||
| ("2022-06-02", "Spring Bank Holiday"), | ||||||||||||||||
| ("2022-06-03", "Platinum Jubilee of Elizabeth II"), | ||||||||||||||||
| ("2022-08-29", "Late Summer Bank Holiday"), | ||||||||||||||||
| ("2022-09-19", "State Funeral of Queen Elizabeth II"), | ||||||||||||||||
| ("2022-12-25", "Christmas Day"), | ||||||||||||||||
| ("2022-12-26", "Boxing Day"), | ||||||||||||||||
| ("2022-12-27", "Christmas Day (observed)"), | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| def test_christmas_eve(self): | ||||||||||||||||
| name = "Christmas Eve (markets close at 12:30pm)" | ||||||||||||||||
| self.assertNoHolidayName(name) | ||||||||||||||||
| self.assertHalfDayHolidayName(name, (f"{year}-12-24" for year in self.full_range)) | ||||||||||||||||
|
|
||||||||||||||||
| def test_new_years_eve(self): | ||||||||||||||||
| name = "New Year's Eve (markets close at 12:30pm)" | ||||||||||||||||
| self.assertNoHolidayName(name) | ||||||||||||||||
| self.assertHalfDayHolidayName(name, (f"{year}-12-31" for year in self.full_range)) | ||||||||||||||||
|
|
||||||||||||||||
| def test_l10n_default(self): | ||||||||||||||||
| self.assertLocalizedHolidays( | ||||||||||||||||
| ("2024-01-01", "New Year's Day"), | ||||||||||||||||
| ("2024-03-29", "Good Friday"), | ||||||||||||||||
| ("2024-04-01", "Easter Monday"), | ||||||||||||||||
| ("2024-05-06", "May Day"), | ||||||||||||||||
| ("2024-05-27", "Spring Bank Holiday"), | ||||||||||||||||
| ("2024-08-26", "Late Summer Bank Holiday"), | ||||||||||||||||
| ("2024-12-24", "Christmas Eve (markets close at 12:30pm)"), | ||||||||||||||||
| ("2024-12-25", "Christmas Day"), | ||||||||||||||||
| ("2024-12-26", "Boxing Day"), | ||||||||||||||||
| ("2024-12-31", "New Year's Eve (markets close at 12:30pm)"), | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| def test_l10n_en_us(self): | ||||||||||||||||
| self.assertLocalizedHolidays( | ||||||||||||||||
| "en_US", | ||||||||||||||||
| ("2024-01-01", "New Year's Day"), | ||||||||||||||||
| ("2024-03-29", "Good Friday"), | ||||||||||||||||
| ("2024-04-01", "Easter Monday"), | ||||||||||||||||
| ("2024-05-06", "May Day"), | ||||||||||||||||
| ("2024-05-27", "Spring Bank Holiday"), | ||||||||||||||||
| ("2024-08-26", "Late Summer Bank Holiday"), | ||||||||||||||||
| ("2024-12-24", "Christmas Eve (markets close at 12:30pm)"), | ||||||||||||||||
| ("2024-12-25", "Christmas Day"), | ||||||||||||||||
| ("2024-12-26", "Boxing Day"), | ||||||||||||||||
| ("2024-12-31", "New Year's Eve (markets close at 12:30pm)"), | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| def test_l10n_th(self): | ||||||||||||||||
| self.assertLocalizedHolidays( | ||||||||||||||||
| "th", | ||||||||||||||||
| ("2024-01-01", "วันขึ้นปีใหม่"), | ||||||||||||||||
| ("2024-03-29", "วันศุกร์ประเสริฐ"), | ||||||||||||||||
| ("2024-04-01", "วันจันทร์อีสเตอร์"), | ||||||||||||||||
| ("2024-05-06", "วันเมย์เดย์"), | ||||||||||||||||
| ("2024-05-27", "วันหยุดฤดูใบไม้ผลิของธนาคาร"), | ||||||||||||||||
| ("2024-08-26", "วันหยุดช่วงปลายฤดูร้อนของธนาคาร"), | ||||||||||||||||
| ("2024-12-24", "วันคริสต์มาสอีฟ (ตลาดปิดเวลา 12:30 น.)"), | ||||||||||||||||
| ("2024-12-25", "วันคริสต์มาส"), | ||||||||||||||||
| ("2024-12-26", "วันเปิดกล่องของขวัญ"), | ||||||||||||||||
| ("2024-12-31", "วันสิ้นปี (ตลาดปิดเวลา 12:30 น.)"), | ||||||||||||||||
| ) | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eeshsaxena the LSE also observes early closures/half days (like Christmas Eve and New Year's Eve). Here is the reference link
We will need to add half-day support to make this fully accurate. I've already done the research on this, so I am happy to help you implement this section if you'd like! Just let me know