|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types = 1); |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is part of the 'Yasumi' package. |
| 7 | + * |
| 8 | + * The easy PHP Library for calculating holidays. |
| 9 | + * |
| 10 | + * Copyright (c) 2015 - 2025 AzuyaLabs |
| 11 | + * |
| 12 | + * For the full copyright and license information, please view the LICENSE |
| 13 | + * file that was distributed with this source code. |
| 14 | + * |
| 15 | + * @author Sacha Telgenhof <me at sachatelgenhof dot com> |
| 16 | + */ |
| 17 | + |
| 18 | +namespace Yasumi\Provider\USA; |
| 19 | + |
| 20 | +use Yasumi\Holiday; |
| 21 | +use Yasumi\Provider\USA; |
| 22 | + |
| 23 | +/** |
| 24 | + * Class NYSE in addition to regular holidays observed by the New York Stock |
| 25 | + * Exchange (NYSE), includes full day special closure events due to: |
| 26 | + * weather, national emergencies and presidential proclamations. |
| 27 | + * All trading closure events are included from year 2000. |
| 28 | + * |
| 29 | + * @author Art Kurbakov <admin at mgwebgroup dot com> |
| 30 | + */ |
| 31 | +class NYSE extends USA |
| 32 | +{ |
| 33 | + /** |
| 34 | + * Code to identify this Holiday Provider. Typically, this is the ISO3166 code corresponding to the respective |
| 35 | + * country or sub-region. |
| 36 | + */ |
| 37 | + public const ID = 'US-NYSE'; |
| 38 | + |
| 39 | + /** |
| 40 | + * Initialize holidays for the NYSE. |
| 41 | + * |
| 42 | + * @throws \Exception |
| 43 | + */ |
| 44 | + public function initialize(): void |
| 45 | + { |
| 46 | + $this->timezone = 'America/New_York'; |
| 47 | + |
| 48 | + // Add exhange-specific holidays |
| 49 | + $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); |
| 50 | + $this->calculateMartinLutherKingday(); |
| 51 | + $this->calculateWashingtonsBirthday(); |
| 52 | + $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); |
| 53 | + $this->calculateMemorialDay(); |
| 54 | + if (2021 < $this->year) { |
| 55 | + $this->calculateJuneteenth(); |
| 56 | + } |
| 57 | + $this->calculateIndependenceDay(); |
| 58 | + $this->calculateLabourDay(); |
| 59 | + $this->calculateThanksgivingDay(); |
| 60 | + $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); |
| 61 | + |
| 62 | + $this->calculateSubstituteHolidays(); |
| 63 | + |
| 64 | + // Add other full-day closure events |
| 65 | + $this->addWeatherEvents(); |
| 66 | + $this->addEmergencies(); |
| 67 | + $this->addProclamations(); |
| 68 | + } |
| 69 | + |
| 70 | + public function getSources(): array |
| 71 | + { |
| 72 | + return [ |
| 73 | + 'https://www.nyse.com/trader-update/history#11507', |
| 74 | + 'https://s3.amazonaws.com/armstrongeconomics-wp/2013/07/NYSE-Closings.pdf', |
| 75 | + 'https://ir.theice.com/press/news-details/2018/New-York-Stock-Exchange-to-Honor-President-George-H-W-Bush/default.aspx', |
| 76 | + 'https://ir.theice.com/press/news-details/2024/The-New-York-Stock-Exchange-Will-Close-Markets-on-January-9-to-Honor-the-Passing-of-Former-President-Jimmy-Carter-on-National-Day-of-Mourning/default.aspx', |
| 77 | + 'https://www.thecorporatecounsel.net/blog/2021/10/nyse-makes-juneteenth-a-new-market-holiday.html', |
| 78 | + ]; |
| 79 | + } |
| 80 | + |
| 81 | + private function addWeatherEvents(): void |
| 82 | + { |
| 83 | + if (2012 == $this->year) { |
| 84 | + $this->addHoliday(new Holiday('hurricaneSandy1', [], new \DateTime('2012-10-29', new \DateTimeZone($this->timezone)))); |
| 85 | + $this->addHoliday(new Holiday('hurricaneSandy2', [], new \DateTime('2012-10-30', new \DateTimeZone($this->timezone)))); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + private function addEmergencies(): void |
| 90 | + { |
| 91 | + if (2001 == $this->year) { |
| 92 | + $this->addHoliday(new Holiday('groundZero1', [], new \DateTime('2001-09-11', new \DateTimeZone($this->timezone)))); |
| 93 | + $this->addHoliday(new Holiday('groundZero2', [], new \DateTime('2001-09-12', new \DateTimeZone($this->timezone)))); |
| 94 | + $this->addHoliday(new Holiday('groundZero3', [], new \DateTime('2001-09-13', new \DateTimeZone($this->timezone)))); |
| 95 | + $this->addHoliday(new Holiday('groundZero4', [], new \DateTime('2001-09-14', new \DateTimeZone($this->timezone)))); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + private function addProclamations(): void |
| 100 | + { |
| 101 | + if (2004 == $this->year) { |
| 102 | + $this->addHoliday(new Holiday('ReaganMourning', [], new \DateTime('2004-06-11', new \DateTimeZone($this->timezone)))); |
| 103 | + } |
| 104 | + if (2007 == $this->year) { |
| 105 | + $this->addHoliday(new Holiday('GRFordMourning', [], new \DateTime('2007-01-02', new \DateTimeZone($this->timezone)))); |
| 106 | + } |
| 107 | + if (2018 == $this->year) { |
| 108 | + $this->addHoliday(new Holiday('HWBushMourning', [], new \DateTime('2018-12-05', new \DateTimeZone($this->timezone)))); |
| 109 | + } |
| 110 | + if (2025 == $this->year) { |
| 111 | + $this->addHoliday(new Holiday('CarterMourning', [], new \DateTime('2025-01-09', new \DateTimeZone($this->timezone)))); |
| 112 | + } |
| 113 | + } |
| 114 | +} |
0 commit comments