Thank you for your interest in contributing to HyperTrade! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Workflow
- Coding Standards
- Testing
- Documentation
- Submitting Changes
- Review Process
This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
Positive behaviors:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Unacceptable behaviors:
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
- Python 3.12+
uvpackage manager- Node.js 18+ and
pnpm - Git
- Docker and Docker Compose (optional, for PostgreSQL)
-
Fork and Clone:
git clone git@github.com:YOUR_USERNAME/HyperTrade.git cd HyperTrade -
Set Up Python Environment:
uv sync
-
Set Up Frontend:
npm exec --yes pnpm@10 -- -C frontend install -
Configure Environment:
cp .env.example .env # Edit .env with your API keys and configuration -
Initialize Database:
# For SQLite (quickstart) mkdir -p .local export DATABASE_URL="sqlite:///$(pwd)/.local/hypertrade.db" # For PostgreSQL (recommended for development) docker compose up -d postgres export DATABASE_URL="postgresql://hypertrade:hypertrade@localhost:5432/hypertrade" uv run alembic upgrade head
-
Verify Setup:
./scripts/check.sh
Current workflow: Direct commits to main branch.
For future contributions:
- Create a feature branch from
main:git checkout -b feature/your-feature-name - Use descriptive branch names:
feature/,bugfix/,docs/,refactor/
HyperTrade development is organized by sprint contracts in docs/contracts/.
Before starting work:
- Check
docs/contracts/for the active sprint scope - Review related architecture docs in
docs/architecture/ - Understand the acceptance criteria and boundaries
During development:
- Keep changes within the current sprint contract unless explicitly expanded
- Update architecture docs when introducing new patterns or components
- Add eval cases to guard against regressions
-
Create a Branch (future workflow):
git checkout -b feature/add-new-tool
-
Make Your Changes:
- Write clean, readable code
- Follow the coding standards (see below)
- Add tests for new functionality
- Update documentation
-
Test Your Changes:
./scripts/check.sh
-
Commit Your Changes:
git add . git commit -m "Add new market intelligence tool"
Commit message format:
Brief summary (50 chars or less) More detailed explanatory text, if necessary. Wrap it to about 72 characters. The blank line separating the summary from the body is critical. - Bullet points are okay - Use present tense: "Add feature" not "Added feature" - Reference issues: "Fixes #123" or "Related to #456"
Style:
- Follow PEP 8
- Use type hints for function signatures
- Maximum line length: 100 characters
Formatting:
uv run ruff format .Linting:
uv run ruff check .Type Checking:
uv run mypy backend/srcExample:
from typing import Any
def get_market_ticker(
symbol: str,
include_funding: bool = True,
) -> dict[str, Any]:
"""Get market ticker for a symbol.
Args:
symbol: Symbol name (e.g., "BTC", "ETH")
include_funding: Include funding rate data
Returns:
Ticker data dictionary
"""
# Implementation
passStyle:
- Use TypeScript for all new code
- Follow ESLint rules
- Use functional components with hooks
Linting:
npm exec --yes pnpm@10 -- -C frontend lintExample:
interface MarketTickerProps {
symbol: string;
onUpdate?: (data: TickerData) => void;
}
export function MarketTicker({ symbol, onUpdate }: MarketTickerProps) {
const [data, setData] = useState<TickerData | null>(null);
useEffect(() => {
// Implementation
}, [symbol]);
return (
<div className="market-ticker">
{/* Component JSX */}
</div>
);
}Code Comments:
- Write self-documenting code with clear variable and function names
- Add comments only when code cannot express intent clearly
- Document complex algorithms or business logic
- Keep comments up-to-date with code changes
Docstrings:
- Use docstrings for all public functions, classes, and modules
- Follow Google style for Python docstrings
- Include type information and examples when helpful
Full Test Suite:
./scripts/check.shBackend Tests:
uv run pytest tests/ -vFrontend Tests:
npm exec --yes pnpm@10 -- -C frontend testSpecific Test:
uv run pytest tests/test_agent_eval_suite.py::test_eval_tool_choice -vWith Coverage:
uv run pytest --cov=hypertrade --cov-report=htmlTest Structure:
- Place tests in
tests/directory - Name test files
test_*.py - Name test functions
test_* - Use descriptive test names that explain the scenario
Example Test:
def test_market_ticker_returns_valid_data():
"""Test that market ticker returns valid ticker data."""
repo = MarketRepository(db)
ticker = repo.get_ticker("BTC-USDT-SWAP")
assert ticker is not None
assert ticker.inst_id == "BTC-USDT-SWAP"
assert ticker.last > 0
assert ticker.volume_ccy_24h >= 0Add eval cases to AgentEvalSuite to guard against regressions:
def _eval_my_new_feature(self) -> EvalResult:
"""Test my new feature behavior."""
kernel = AgentKernel(self.db, "docs/knowledge", self.settings)
run = kernel.run_chat("Test prompt for my feature")
assert run.status == "completed"
assert "expected_tool" in [t["tool"] for t in run.trace]
return EvalResult(
eval_id="my_new_feature",
status="pass",
message="Feature works correctly"
)Always document:
- New tools, providers, or connectors
- API changes or new endpoints
- Architecture decisions
- Configuration changes
- Operational procedures
Don't document:
- Implementation details visible in code
- Temporary workarounds
- Debug notes or chat history
Architecture Docs (docs/architecture/):
- Module-level design decisions
- Component interactions
- Technical patterns
Knowledge Base (docs/knowledge/):
- Operator guides
- Best practices
- Tool usage examples
Runbooks (docs/runbooks/):
- Deployment procedures
- Troubleshooting guides
- Incident response
Contracts (docs/contracts/):
- Sprint scope and deliverables
- Acceptance criteria
- Technical specifications
- Write in clear, concise English or Chinese
- Use markdown formatting
- Include code examples where helpful
- Keep docs up-to-date with code changes
- Link related documentation
- Code follows project style guidelines
- All tests pass (
./scripts/check.sh) - New tests added for new functionality
- Documentation updated
- Eval cases added if needed
- Commit messages are clear and descriptive
Current workflow (direct to main):
- Ensure your changes are committed
- Push to
origin/main - Automatic deployment via GitHub Actions
Future workflow (with PRs):
- Push your branch to your fork
- Create a Pull Request against
main - Fill out the PR template
- Wait for review and address feedback
- Once approved, changes will be merged
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] All tests pass
- [ ] New tests added
- [ ] Manually tested
## Checklist
- [ ] Code follows style guidelines
- [ ] Documentation updated
- [ ] No breaking changes (or documented)
- [ ] Sprint contract scope respected
## Related Issues
Fixes #123
Related to #456Code Quality:
- Follows project conventions
- Clear and maintainable
- Properly tested
- No unnecessary complexity
Functionality:
- Meets requirements
- Handles edge cases
- No regressions
- Within sprint scope
Documentation:
- Architecture docs updated
- API changes documented
- Usage examples provided
- Reviews typically within 1-2 business days
- Address feedback promptly
- Be patient and respectful
- Changes will be merged to
main - Automatic deployment to production
- Monitor deployment logs
- Verify production health
- Documentation: docs/documentation-index.md
- Architecture: docs/architecture/
- Developer Guide: docs/developer-guide.md
- Issues: Use GitHub Issues for bugs and feature requests
- Discussions: Use GitHub Discussions for questions
- Email: Contact maintainers for sensitive issues
By contributing to HyperTrade, you agree that your contributions will be licensed under the same license as the project.
Contributors will be recognized in:
- Release notes
- CHANGELOG.md
- Project README (if significant contribution)
Thank you for contributing to HyperTrade! 🎉