trading-calendar ๐
A comprehensive trading calendar for global financial markets, providing holidays, trading hours, and early close information. Built with performance and reliability in mind, this library supports major exchanges worldwide with accurate holiday calculations and timezone handling.
๐ Documentation
- API Documentation - Complete API reference
- Examples - Practical usage examples and tutorials
- Changelog - Version history and changes
- Contributing - How to contribute to the project
- Release Notes v0.2.2 - Detailed release information
โจ Features
- ๐ Multiple Markets: NYSE, NASDAQ, LSE, TSE, TSX with accurate holiday calendars
- โฐ Trading Hours: Regular, pre-market, and after-hours sessions with timezone support
- ๐ Holiday Detection: All market holidays with weekend adjustments and early closes
- ๐ Early Closes: Half-day schedules (Christmas Eve, Black Friday, etc.)
- ๐ Timezone Support: Automatic handling of market timezones (ET, GMT, JST)
- ๐ Performance: Efficient LRU caching for holiday calculations
- ๐ Thread Safe: Concurrent access support with proper synchronization
- ๐ Date Range: Comprehensive support for years 2020-2030
- ๐ง Error Handling: Robust error handling with detailed error messages
- ๐ฆ Serialization: Optional serde support for JSON serialization
๐ Quick Start
Installation
Add to your Cargo.toml:
[]
= "0.2.2"
# With serialization support
= { = "0.2.2", = ["serialization"] }
Basic Usage
use ;
๐ Supported Markets
| Market | Regular Hours (Local) | Pre-Market | After-Hours | Timezone | Status |
|---|---|---|---|---|---|
| NYSE | 9:30 AM - 4:00 PM ET | 4:00 AM - 9:30 AM | 4:00 PM - 8:00 PM | ET | โ Full Support |
| NASDAQ | 9:30 AM - 4:00 PM ET | 4:00 AM - 9:30 AM | 4:00 PM - 8:00 PM | ET | โ Full Support |
| LSE | 8:00 AM - 4:30 PM GMT | - | - | GMT | โ Full Support |
| TSE | 9:00 AM - 3:00 PM JST | - | - | JST | โ Full Support |
| TSX | 9:30 AM - 4:00 PM ET | - | - | ET | โ Full Support |
๐ง API Reference
Core Methods
use ;
let calendar = new?;
// Market status
let is_open = calendar.is_open_now?;
let is_trading = calendar.is_trading_day?;
let is_holiday = calendar.is_holiday?;
// Time navigation
let next_open = calendar.next_open?;
let next_close = calendar.next_close?;
let next_trading_day = calendar.next_trading_day?;
let prev_trading_day = calendar.prev_trading_day?;
// Trading hours
let hours = calendar.trading_hours;
let is_early_close = calendar.is_early_close?;
// Utility methods
let trading_days = calendar.trading_days_in_month?;
let count = calendar.count_trading_days?;
Error Handling
use ;
๐ Thread Safety
The TradingCalendar is thread-safe and can be shared across threads:
use Arc;
use ;
๐ฆ Serialization Support
Enable serialization features for JSON support:
use ;
// In Cargo.toml: trading-calendar = { version = "0.2.2", features = ["serialization"] }
let calendar = new?;
let json = to_string?;
println!;
๐ Examples
See the examples directory for detailed usage examples:
- Basic Usage - Simple calendar operations and market status checks
- Check Holidays - Holiday detection and listing
- Holiday Info - Detailed holiday information and early close handling
Running Examples
# Run a specific example
# Run all examples
for; do
done
๐งช Testing
Run the comprehensive test suite:
# All tests
# Specific test categories
๐ Performance
The library is optimized for performance:
- LRU Caching: Holiday calculations are cached per year
- Thread-Safe: Concurrent access with proper eviction
- Minimal Allocations: Optimized data structures
- Benchmarks: Performance benchmarks available in
benches/
๐ Security
- Security Audits: Automated vulnerability scanning in CI
- Dependency Updates: Regular security updates
- Safe by Default: Memory-safe Rust implementation
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for:
- Code style guidelines
- Testing requirements
- Documentation standards
- Pull request process
- Holiday rule verification
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
๐ Support
- GitHub Issues: Report bugs or request features
- Documentation: Full API documentation
- Examples: Usage examples
- Changelog: Version history
๐ Links
- Crates.io: trading-calendar
- Documentation: docs.rs
- Repository: GitHub
- CI/CD: GitHub Actions
Current Version: 0.2.2
Minimum Rust Version: 1.65
License: MIT OR Apache-2.0