-
-
Notifications
You must be signed in to change notification settings - Fork 167
Added provider for closures of New York Stock Exchange (NYSE) since 2000. #382
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
Changes from 6 commits
3756d3d
6a57cc4
9a660d0
bea83ed
f9bb34f
d5fa50d
f3493cd
bc9213e
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,107 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| /** | ||
| * This file is part of the 'Yasumi' package. | ||
| * | ||
| * The easy PHP Library for calculating holidays. | ||
| * | ||
| * Copyright (c) 2015 - 2025 AzuyaLabs | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| * | ||
| * @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
| * @author Art Kurbakov <admin at mgwebgroup dot com> | ||
| */ | ||
|
|
||
| // This file in addition to regular holidays observed by | ||
| // the New York Stock Exchange (NYSE), | ||
| // includes full day special closure events due to: | ||
| // weather, national emergencies and presidential proclamations. | ||
| // All closure events are included from year 2000. | ||
|
|
||
| namespace Yasumi\Provider\USA; | ||
|
|
||
| use Yasumi\Holiday; | ||
| use Yasumi\Provider\USA; | ||
|
|
||
| class NYSE extends USA | ||
| { | ||
| /** | ||
| * Initialize holidays for the NYSE. | ||
| * | ||
| * @throws Exception | ||
|
mgwebgroup marked this conversation as resolved.
Outdated
|
||
| */ | ||
| public function initialize(): void | ||
|
Check failure on line 37 in src/Yasumi/Provider/USA/NYSE.php
|
||
| { | ||
| $this->timezone = 'America/New_York'; | ||
|
|
||
| // Add exhange-specific holidays | ||
|
mgwebgroup marked this conversation as resolved.
Outdated
|
||
| $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); | ||
| $this->calculateMartinLutherKingday(); | ||
| $this->calculateWashingtonsBirthday(); | ||
| $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); | ||
| $this->calculateMemorialDay(); | ||
| if (2021 < $this->year) { | ||
| $this->calculateJuneteenth(); | ||
| } | ||
| $this->calculateIndependenceDay(); | ||
| $this->calculateLabourDay(); | ||
| $this->calculateThanksgivingDay(); | ||
| $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); | ||
|
|
||
| $this->calculateSubstituteHolidays(); | ||
|
|
||
| // Add other full-day closure events | ||
| $this->addWeatherEvents(); | ||
| $this->addEmergencies(); | ||
| $this->addProclamations(); | ||
| } | ||
|
|
||
| public function getSources(): array | ||
| { | ||
| return [ | ||
| 'https://www.nyse.com/trader-update/history#11507', | ||
| 'https://s3.amazonaws.com/armstrongeconomics-wp/2013/07/NYSE-Closings.pdf', | ||
| 'https://ir.theice.com/press/news-details/2018/New-York-Stock-Exchange-to-Honor-President-George-H-W-Bush/default.aspx', | ||
| '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', | ||
| 'https://www.thecorporatecounsel.net/blog/2021/10/nyse-makes-juneteenth-a-new-market-holiday.html', | ||
| ]; | ||
| } | ||
|
|
||
| private function addWeatherEvents() | ||
|
Check failure on line 74 in src/Yasumi/Provider/USA/NYSE.php
|
||
|
Member
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. This method is missing a return type (void).
Contributor
Author
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. Added void return type. |
||
| { | ||
| if (2012 == $this->year) { | ||
| $this->addHoliday(new Holiday('hurricaneSandy1', [], new \DateTime('2012-10-29', new \DateTimeZone($this->timezone)))); | ||
| $this->addHoliday(new Holiday('hurricaneSandy2', [], new \DateTime('2012-10-30', new \DateTimeZone($this->timezone)))); | ||
| } | ||
| } | ||
|
|
||
| private function addEmergencies() | ||
|
Check failure on line 82 in src/Yasumi/Provider/USA/NYSE.php
|
||
|
Member
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. This method is missing a return type (void).
Contributor
Author
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. Added void return type. |
||
| { | ||
| if (2001 == $this->year) { | ||
| $this->addHoliday(new Holiday('groundZero1', [], new \DateTime('2001-09-11', new \DateTimeZone($this->timezone)))); | ||
| $this->addHoliday(new Holiday('groundZero2', [], new \DateTime('2001-09-12', new \DateTimeZone($this->timezone)))); | ||
| $this->addHoliday(new Holiday('groundZero3', [], new \DateTime('2001-09-13', new \DateTimeZone($this->timezone)))); | ||
| $this->addHoliday(new Holiday('groundZero4', [], new \DateTime('2001-09-14', new \DateTimeZone($this->timezone)))); | ||
| } | ||
| } | ||
|
|
||
| private function addProclamations() | ||
|
Check failure on line 92 in src/Yasumi/Provider/USA/NYSE.php
|
||
|
Member
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. This method is missing a return type (void).
Contributor
Author
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. Added void return type. |
||
| { | ||
| if (2004 == $this->year) { | ||
| $this->addHoliday(new Holiday('ReaganMourning', [], new \DateTime('2004-06-11', new \DateTimeZone($this->timezone)))); | ||
| } | ||
| if (2007 == $this->year) { | ||
| $this->addHoliday(new Holiday('GRFordMourning', [], new \DateTime('2007-01-02', new \DateTimeZone($this->timezone)))); | ||
| } | ||
| if (2018 == $this->year) { | ||
| $this->addHoliday(new Holiday('HWBushMourning', [], new \DateTime('2018-12-05', new \DateTimeZone($this->timezone)))); | ||
| } | ||
| if (2025 == $this->year) { | ||
| $this->addHoliday(new Holiday('CarterMourning', [], new \DateTime('2025-01-09', new \DateTimeZone($this->timezone)))); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| /** | ||
| * This file is part of the 'Yasumi' package. | ||
| * | ||
| * The easy PHP Library for calculating holidays. | ||
| * | ||
| * Copyright (c) 2015 - 2025 AzuyaLabs | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| * | ||
| * @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
| * @author Art Kurbakov <admin at mgwebgroup dot com> | ||
| */ | ||
|
|
||
| namespace Yasumi\tests\USA\NYSE; | ||
|
|
||
| use Yasumi\tests\USA\USABaseTestCase; | ||
|
|
||
| /** | ||
| * Class to test day of closure of NYSE due to Jimmy Carter mourning proclamation | ||
| */ | ||
| class CarterMourningTest extends USABaseTestCase | ||
| { | ||
| /** | ||
| * Name of provider to be tested. | ||
| */ | ||
| public const REGION = 'USA/NYSE'; | ||
|
|
||
| /** | ||
| * The year when the closure was observed. | ||
| */ | ||
| public const OBSERVED_YEAR = 2025; | ||
|
|
||
| /** | ||
| * Tests day of closure on January 9th 2025 | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function testCarterMourning(): void | ||
| { | ||
| $this->assertHoliday( | ||
| self::REGION, | ||
| 'CarterMourning', | ||
| self::OBSERVED_YEAR, | ||
| new \DateTime('2025-01-09', new \DateTimeZone(self::TIMEZONE)) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests years before 2025 | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function testCarterMourningBefore2025(): void | ||
| { | ||
| $this->assertNotHoliday( | ||
| self::REGION, | ||
| 'CarterMourning', | ||
| self::OBSERVED_YEAR - 1 | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests years after 2025 | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function testCarterMourningAfter2025(): void | ||
| { | ||
| $this->assertNotHoliday( | ||
| self::REGION, | ||
| 'CarterMourning', | ||
| self::OBSERVED_YEAR + 1 | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| /** | ||
| * This file is part of the 'Yasumi' package. | ||
| * | ||
| * The easy PHP Library for calculating holidays. | ||
| * | ||
| * Copyright (c) 2015 - 2025 AzuyaLabs | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| * | ||
| * @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
| * @author Art Kurbakov <admin at mgwebgroup dot com> | ||
| */ | ||
|
|
||
| namespace Yasumi\tests\USA\NYSE; | ||
|
|
||
| use Yasumi\tests\USA\USABaseTestCase; | ||
|
|
||
| /** | ||
| * Class to test day of closure of NYSE due to G.R. Ford Mourning proclamation | ||
| */ | ||
| class GRFordMourningTest extends USABaseTestCase | ||
| { | ||
| /** | ||
| * Name of provider to be tested. | ||
| */ | ||
| public const REGION = 'USA/NYSE'; | ||
|
|
||
| /** | ||
| * The year when the closure was observed. | ||
| */ | ||
| public const OBSERVED_YEAR = 2007; | ||
|
|
||
| /** | ||
| * Tests day of closure on January 2nd 2007 | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function testGRFordMourning(): void | ||
| { | ||
| $this->assertHoliday( | ||
| self::REGION, | ||
| 'GRFordMourning', | ||
| self::OBSERVED_YEAR, | ||
| new \DateTime('2007-01-02', new \DateTimeZone(self::TIMEZONE)) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests years before 2007 | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function testGRFordMourningBefore2007(): void | ||
| { | ||
| $this->assertNotHoliday( | ||
| self::REGION, | ||
| 'GRFordMourning', | ||
| self::OBSERVED_YEAR - 1 | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests years after 2007 | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function testGRFordMourningAfter2007(): void | ||
| { | ||
| $this->assertNotHoliday( | ||
| self::REGION, | ||
| 'GRFordMourning', | ||
| self::OBSERVED_YEAR + 1 | ||
| ); | ||
| } | ||
| } |
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.
Should this file be part of your PR?
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.
I grabbed it off of the develop branch when got started. Will remove from my PR.