hyperliquid_backtest/
api_docs.rs

1//! # API Documentation and Stability Guarantees
2//!
3//! This module provides comprehensive documentation for the public API and outlines
4//! stability guarantees for different components of the hyperliquid-backtester crate.
5//!
6//! ## Public API Overview
7//!
8//! The hyperliquid-backtester crate provides a stable public API through the [`prelude`](crate::prelude) module.
9//! All items exported in the prelude are considered part of the stable public API and follow
10//! semantic versioning guarantees.
11//!
12//! ### Core Data Types
13//!
14//! #### [`HyperliquidData`](crate::data::HyperliquidData)
15//! 
16//! The primary data structure for market data with OHLC prices and funding rates.
17//!
18//! **Stability**: ✅ Stable - Fields and methods will not be removed in minor versions
19//!
20//! **Key Methods**:
21//! - `fetch()` - Async data fetching from Hyperliquid API
22//! - `to_rs_backtester_data()` - Convert to rs-backtester format
23//! - `get_funding_rate_at()` - Get funding rate at specific timestamp
24//! - `len()`, `is_empty()` - Data size information
25//!
26//! #### [`HyperliquidBacktest`](crate::backtest::HyperliquidBacktest)
27//!
28//! Enhanced backtesting engine with funding rate calculations.
29//!
30//! **Stability**: ✅ Stable - Core interface will not change in minor versions
31//!
32//! **Key Methods**:
33//! - `new()` - Create new backtest instance
34//! - `calculate_with_funding()` - Run backtest with funding calculations
35//! - `enhanced_report()` - Generate comprehensive report
36//! - `funding_report()` - Get funding-specific metrics
37//!
38//! #### [`HyperliquidCommission`](crate::backtest::HyperliquidCommission)
39//!
40//! Commission structure with maker/taker rates and funding settings.
41//!
42//! **Stability**: ✅ Stable - Structure and default values are stable
43//!
44//! **Key Methods**:
45//! - `default()` - Standard Hyperliquid commission rates
46//! - `new()` - Custom commission configuration
47//! - `calculate_fee()` - Calculate trading fees
48//!
49//! ### Strategy Types
50//!
51//! #### [`HyperliquidStrategy`](crate::strategies::HyperliquidStrategy)
52//!
53//! Trait for implementing funding-aware strategies.
54//!
55//! **Stability**: ✅ Stable - Trait methods will not change in minor versions
56//!
57//! **Key Methods**:
58//! - `funding_config()` - Get funding configuration
59//! - `process_funding()` - Process funding rate signals
60//! - `combine_signals()` - Combine base and funding signals
61//!
62//! #### Strategy Functions
63//!
64//! - [`funding_arbitrage_strategy()`](crate::strategies::funding_arbitrage_strategy) - ✅ Stable
65//! - [`enhanced_sma_cross()`](crate::strategies::enhanced_sma_cross) - ✅ Stable
66//!
67//! ### Error Handling
68//!
69//! #### [`HyperliquidBacktestError`](crate::errors::HyperliquidBacktestError)
70//!
71//! Comprehensive error type with user-friendly messages.
72//!
73//! **Stability**: ⚠️ Semi-stable - New variants may be added, existing ones will not be removed
74//!
75//! **Key Methods**:
76//! - `user_message()` - Get user-friendly error message with suggestions
77//! - `is_recoverable()` - Check if error is recoverable
78//! - `category()` - Get error category for logging
79//!
80//! ### Reporting and Export
81//!
82//! #### [`FundingReport`](crate::funding_report::FundingReport)
83//!
84//! Detailed funding rate analysis and metrics.
85//!
86//! **Stability**: ✅ Stable - Core metrics will not change
87//!
88//! #### [`EnhancedCsvExport`](crate::csv_export::EnhancedCsvExport)
89//!
90//! Enhanced CSV export with funding data.
91//!
92//! **Stability**: ✅ Stable - Export format is stable
93//!
94//! ## API Versioning Strategy
95//!
96//! ### Pre-1.0 Development (Current: 0.1.x)
97//!
98//! During the pre-1.0 phase:
99//! - **Minor versions** (0.1.x → 0.2.0) may include breaking changes
100//! - **Patch versions** (0.1.0 → 0.1.1) are backward compatible
101//! - Breaking changes will be documented in CHANGELOG.md
102//! - Migration guides provided for significant API changes
103//!
104//! ### Post-1.0 Stability (Future: 1.x.x)
105//!
106//! After reaching 1.0:
107//! - **Major versions** (1.x.x → 2.0.0): Breaking changes allowed
108//! - **Minor versions** (1.0.x → 1.1.0): New features, backward compatible
109//! - **Patch versions** (1.0.0 → 1.0.1): Bug fixes only
110//!
111//! ## Stability Classifications
112//!
113//! ### ✅ Stable
114//! - API will not change in backward-incompatible ways within major versions
115//! - New methods may be added
116//! - Existing methods will not be removed or change signatures
117//! - Default values and behavior will remain consistent
118//!
119//! ### ⚠️ Semi-stable
120//! - Core functionality is stable
121//! - New variants/options may be added
122//! - Existing functionality will not be removed
123//! - May have minor behavioral changes with clear migration path
124//!
125//! ### 🚧 Experimental
126//! - API may change significantly
127//! - Use with caution in production
128//! - Feedback welcome for API design
129//! - Will be stabilized in future versions
130//!
131//! ## Breaking Change Policy
132//!
133//! ### What Constitutes a Breaking Change
134//!
135//! 1. **Removing public items** (functions, types, modules)
136//! 2. **Changing function signatures** (parameters, return types)
137//! 3. **Changing struct fields** (removing, renaming, changing types)
138//! 4. **Changing enum variants** (removing, changing data)
139//! 5. **Changing default behavior** in ways that affect existing code
140//!
141//! ### What is NOT a Breaking Change
142//!
143//! 1. **Adding new public items** (functions, types, modules)
144//! 2. **Adding new struct fields** (with default values)
145//! 3. **Adding new enum variants** (in non-exhaustive enums)
146//! 4. **Adding new trait methods** (with default implementations)
147//! 5. **Performance improvements** that don't change behavior
148//! 6. **Bug fixes** that correct documented behavior
149//!
150//! ## Migration Support
151//!
152//! ### Migration Guides
153//!
154//! Comprehensive migration guides are provided for:
155//! - Upgrading from rs-backtester to hyperliquid-backtester
156//! - Major version upgrades within hyperliquid-backtester
157//! - Significant API changes during pre-1.0 development
158//!
159//! See [`migration`](crate::migration) module for detailed guides.
160//!
161//! ### Deprecation Policy
162//!
163//! Before removing functionality:
164//! 1. **Deprecation warning** added in minor version
165//! 2. **Alternative provided** with migration instructions
166//! 3. **Minimum one major version** before removal
167//! 4. **Clear timeline** communicated in documentation
168//!
169//! ## Feature Flags and Optional Dependencies
170//!
171//! ### Current Feature Flags
172//!
173//! Currently, all features are enabled by default. Future versions may introduce:
174//! - `funding-rates` - Enable funding rate calculations (default: enabled)
175//! - `csv-export` - Enable CSV export functionality (default: enabled)
176//! - `advanced-strategies` - Enable advanced strategy implementations (default: enabled)
177//!
178//! ### Optional Dependencies
179//!
180//! Core dependencies are required, but some features may become optional:
181//! - CSV export functionality
182//! - Advanced mathematical indicators
183//! - Visualization helpers
184//!
185//! ## API Documentation Standards
186//!
187//! All public API items must include:
188//!
189//! ### Required Documentation
190//! - **Purpose**: What the item does
191//! - **Parameters**: Description of all parameters
192//! - **Returns**: Description of return value
193//! - **Errors**: Possible error conditions
194//! - **Examples**: At least one working example
195//!
196//! ### Optional Documentation
197//! - **Performance notes**: For performance-critical items
198//! - **Thread safety**: For items used in concurrent contexts
199//! - **Stability**: Explicit stability guarantees
200//!
201//! ## Testing and Quality Assurance
202//!
203//! ### API Stability Testing
204//! - **Compilation tests**: Ensure API changes don't break existing code
205//! - **Integration tests**: Test complete workflows
206//! - **Documentation tests**: Ensure examples compile and run
207//! - **Regression tests**: Prevent API regressions
208//!
209//! ### Quality Metrics
210//! - **Documentation coverage**: >95% for public API
211//! - **Test coverage**: >90% for core functionality
212//! - **Example coverage**: All public functions have examples
213//!
214//! ## Community and Feedback
215//!
216//! ### Feedback Channels
217//! - **GitHub Issues**: Bug reports and feature requests
218//! - **GitHub Discussions**: API design discussions
219//! - **Documentation**: Inline comments and suggestions
220//!
221//! ### API Design Principles
222//! 1. **Ergonomic**: Easy to use correctly, hard to use incorrectly
223//! 2. **Consistent**: Similar patterns across the API
224//! 3. **Discoverable**: Clear naming and organization
225//! 4. **Composable**: Components work well together
226//! 5. **Performant**: Efficient by default, with optimization options
227//!
228//! ## Future Roadmap
229//!
230//! ### Planned API Additions (Non-breaking)
231//! - Additional strategy implementations
232//! - Enhanced reporting formats
233//! - Performance optimization utilities
234//! - Integration with more data sources
235//!
236//! ### Potential Breaking Changes (Major Version)
237//! - Async trait methods for strategies
238//! - Enhanced error handling with more context
239//! - Streaming data interfaces
240//! - Plugin architecture for custom indicators
241//!
242//! ## Conclusion
243//!
244//! The hyperliquid-backtester API is designed for long-term stability while allowing
245//! for growth and improvement. By following semantic versioning and providing clear
246//! migration paths, we aim to minimize disruption while continuously improving the
247//! developer experience.
248//!
249//! For the most up-to-date API documentation, always refer to the latest version
250//! on [docs.rs](https://docs.rs/hyperliquid-backtester).