Skip to content

wtn/commercial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commercial

Ruby gem for determining business days based on the SIFMA holiday schedule for financial institutions. Covers the United States, the United Kingdom, and Japan.

For US equity market trading calendar, see Bourse.

Usage

All methods accept an optional Date parameter, which defaults to Date.today.

Check business days

Commercial::US.business_day?(date)  # => true if banks are open
Commercial::US.holiday?(date)       # => true if US holiday
Commercial::US.weekend?(date)       # => true if Saturday/Sunday

Navigation

Commercial::US.next_business_day(date)    # => next business day after date
Commercial::US.prev_business_day(date)    # => previous business day before date
Commercial::US.latest_business_day(date)  # => most recent business day on or before date

Commercial::US.succ(date)                 # => alias for next_business_day
Commercial::US.pred(date)                 # => alias for prev_business_day

Examples

include Commercial

# United States
US.business_day?(Date.new(2025, 4, 18))       # => false (Good Friday)
US.holiday?(Date.new(2025, 7, 4))             # => true (Independence Day)

# United Kingdom
GB.business_day?(Date.new(2024, 12, 26))      # => false (Boxing Day)
GB.boxing_day?(Date.new(2024, 12, 26))        # => true

# Japan (uses holiday_japan gem)
JP.business_day?(Date.new(2025, 5, 5))        # => false (Children's Day)
JP.shogatsu?(Date.new(2025, 1, 3))            # => true

# Navigation
US.next_business_day(Date.new(2025, 7, 4))    # => 2025-07-07 (skips holiday & weekend)
US.prev_business_day(Date.new(2025, 1, 6))    # => 2025-01-03 (skips weekend)
US.latest_business_day(Date.new(2025, 1, 4))  # => 2025-01-03 (Saturday back to Friday)

# Cross-market checks
date = Date.new(2024, 12, 26)                     # Boxing Day
GB.business_day?(date) && US.business_day?(date)  # => false (UK closed)
JP.business_day?(date) && US.business_day?(date)  # => true (JP & US open)

See source code or type signatures for complete method list.

Development

Run bin/setup to install dependencies, then rake to run tests.

To validate the type signatures:

rbs -I sig -r date validate

To generate documentation:

rake doc

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors