Thank you for your interest in contributing to Trading System! This document provides guidelines and information for contributors.
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone.
Before creating a bug report, please check existing issues to avoid duplicates.
When reporting a bug, include:
- Description - Clear description of the issue
- Steps to Reproduce - Detailed steps to reproduce the behavior
- Expected Behavior - What you expected to happen
- Actual Behavior - What actually happened
- Environment - OS, Rust version, etc.
- Logs/Screenshots - Any relevant output or screenshots
Feature requests are welcome! Please include:
- Problem Statement - What problem does this solve?
- Proposed Solution - How would you like it to work?
- Alternatives Considered - Other solutions you've thought about
- Additional Context - Any other relevant information
- Fork the repository and create your branch from
main - Make your changes following the coding standards below
- Add tests for any new functionality
- Ensure all tests pass with
cargo test --workspace - Update documentation if needed
- Submit a pull request with a clear description
- Rust 1.75 or later
- Git
# Clone your fork
git clone https://github.com/yourusername/trading-system.git
cd trading-system
# Add upstream remote
git remote add upstream https://github.com/originalowner/trading-system.git
# Create a feature branch
git checkout -b feature/your-feature-name
# Build the project
cargo build
# Run tests
cargo test --workspace- Follow the Rust API Guidelines
- Use
cargo fmtbefore committing - Address all
cargo clippywarnings - Write documentation for public APIs
# Format code
cargo fmt
# Check formatting
cargo fmt -- --check
# Run linter
cargo clippy --workspace -- -D warningsFollow the Conventional Commits specification:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting, etc.)refactor- Code refactoringtest- Adding or modifying testschore- Maintenance tasks
Examples:
feat(strategies): add MACD crossover strategy
fix(backtest): correct drawdown calculation
docs(readme): add installation instructions
- Write unit tests for new functionality
- Ensure existing tests pass
- Add integration tests for complex features
# Run all tests
cargo test --workspace
# Run specific test
cargo test -p trading-strategies test_name
# Run tests with output
cargo test -- --nocapture
# Run benchmarks
cargo bench- Document all public APIs with doc comments
- Include examples where helpful
- Update README.md for user-facing changes
/// Calculates the Simple Moving Average (SMA) for a given period.
///
/// # Arguments
///
/// * `data` - Slice of price data
/// * `period` - Number of periods for the average
///
/// # Returns
///
/// Vector of SMA values, or empty if insufficient data
///
/// # Example
///
/// ```
/// let prices = vec![1.0, 2.0, 3.0, 4.0, 5.0];
/// let sma = calculate_sma(&prices, 3);
/// ```
pub fn calculate_sma(data: &[f64], period: usize) -> Vec<f64> {
// implementation
}Understanding the crate structure helps you find where to make changes:
| Crate | Purpose |
|---|---|
trading-core |
Core types, traits, and errors |
trading-indicators |
Technical indicators (add new indicators here) |
trading-strategies |
Strategy implementations (add new strategies here) |
trading-risk |
Risk management components |
trading-data |
Data sources and loading |
trading-broker |
Broker integrations |
trading-backtest |
Backtesting engine |
trading-monitor |
TUI dashboard |
trading-config |
Configuration management |
- Create a new file in
crates/trading-strategies/src/ - Implement the
Strategytrait fromtrading-core - Add configuration struct with
StrategyConfigtrait - Register in
registry.rs - Add tests
- Update documentation
Example skeleton:
use trading_core::{
traits::{Strategy, StrategyConfig},
types::{BarSeries, Signal},
};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyStrategyConfig {
pub symbols: Vec<String>,
pub param1: f64,
}
impl StrategyConfig for MyStrategyConfig {
fn validate(&self) -> Result<(), StrategyError> {
// validation logic
Ok(())
}
}
pub struct MyStrategy {
config: MyStrategyConfig,
}
impl Strategy for MyStrategy {
fn name(&self) -> &str { "My Strategy" }
fn on_bar(&mut self, series: &BarSeries) -> Option<Signal> {
// strategy logic
None
}
// ... other trait methods
}- Create a new file in
crates/trading-indicators/src/ - Implement the
Indicatortrait - Add SIMD optimization if applicable
- Add tests and benchmarks
- Export from
lib.rs
- All PRs require at least one review
- CI must pass (tests, formatting, clippy)
- Documentation must be updated if applicable
- Breaking changes require discussion
- Open an issue for questions
- Check existing documentation
- Look at similar implementations in the codebase
Contributors will be recognized in:
- Git commit history
- CHANGELOG.md for significant contributions
- README.md contributors section (for major contributions)
Thank you for contributing!