Thank you for your interest in contributing to Optionix! This guide will help you get started.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Code Style
- Testing Requirements
- Pull Request Process
- Documentation
- Security
We pledge to make participation in our project a harassment-free experience for everyone.
- Using welcoming and inclusive language
- Being respectful of differing viewpoints
- Accepting constructive criticism gracefully
- Focusing on what is best for the community
-
Fork the Repository
# Fork on GitHub, then clone your fork git clone https://github.com/quantsingularity/Optionix.git cd Optionix
-
Add Upstream Remote
git remote add upstream https://github.com/quantsingularity/Optionix.git
-
Create a Branch
git checkout -b feature/your-feature-name
- Python 3.11+
- Node.js 16+
- PostgreSQL 13+
- Redis 6+
- Git
# Run automated setup
./scripts/setup_optionix_env.sh
# Or manual setup
python3 -m venv venv
source venv/bin/activate
pip install -r code/requirements.txt
pip install -r code/requirements-dev.txt # Development dependencies
# Frontend
cd web-frontend
npm install# Copy example env file
cp .env.example .env
# Edit with your settings
nano .envgit fetch upstream
git rebase upstream/main- Write clear, concise commit messages
- Keep commits atomic (one logical change per commit)
- Follow existing code patterns
# Backend tests
cd code/backend
pytest
# Frontend tests
cd web-frontend
npm test
# Run all tests
./scripts/comprehensive_test.sh# Run linters
./scripts/lint-all.sh --fix
# Or individually
cd code/backend
black .
flake8 .
mypy .
cd web-frontend
npm run lint:fixFollow PEP 8 with these specifics:
- Line Length: 88 characters (Black default)
- Imports: Organized by
isort - Docstrings: Google style
- Type Hints: Required for all functions
Example:
from typing import Optional
def calculate_option_price(
spot_price: float,
strike_price: float,
volatility: float,
time_to_expiry: float,
) -> float:
"""
Calculate Black-Scholes option price.
Args:
spot_price: Current price of underlying asset
strike_price: Option strike price
volatility: Implied volatility (annual)
time_to_expiry: Time to expiration (years)
Returns:
Option price in dollars
Raises:
ValueError: If any parameter is negative
"""
if spot_price <= 0:
raise ValueError("Spot price must be positive")
# Implementation here
return priceFollow Airbnb Style Guide with these additions:
- Functional Components: Use React hooks
- Type Safety: Explicit types, no
any - Props: Interface or type definition required
Example:
interface OptionPriceProps {
spotPrice: number;
strikePrice: number;
volatility: number;
onCalculate: (price: number) => void;
}
export const OptionPriceCalculator: React.FC<OptionPriceProps> = ({
spotPrice,
strikePrice,
volatility,
onCalculate,
}) => {
const [result, setResult] = useState<number | null>(null);
const handleCalculate = useCallback(() => {
const price = calculatePrice(spotPrice, strikePrice, volatility);
setResult(price);
onCalculate(price);
}, [spotPrice, strikePrice, volatility, onCalculate]);
return (
<div className="option-calculator">
{/* Component JSX */}
</div>
);
};- Version: Solidity 0.8.19+
- Style: Follow Solidity Style Guide
- NatSpec: Required for all public functions
Example:
/**
* @notice Creates a new options contract
* @param optionType Type of option (call or put)
* @param strikePrice Strike price in wei
* @param expirationTime Unix timestamp of expiration
* @return optionId The ID of the newly created option
*/
function createOption(
OptionType optionType,
uint256 strikePrice,
uint256 expirationTime
) external returns (uint256 optionId) {
require(strikePrice > 0, "Invalid strike price");
require(expirationTime > block.timestamp, "Invalid expiration");
// Implementation
}- Coverage: Minimum 80% for new code
- Framework: pytest (Python), Jest (TypeScript)
- Mocking: Use appropriate mocking libraries
Example:
import pytest
from backend.services.pricing_engine import PricingEngine
def test_black_scholes_call_option():
"""Test Black-Scholes pricing for call option."""
engine = PricingEngine()
result = engine.price_option(
spot_price=100.0,
strike_price=100.0,
time_to_expiry=1.0,
risk_free_rate=0.05,
volatility=0.25,
option_type='call'
)
assert result['price'] > 0
assert 0 <= result['delta'] <= 1
assert result['gamma'] >= 0- Test API endpoints end-to-end
- Use TestClient for FastAPI
- Mock external services
const OptionsContract = artifacts.require("OptionsContract");
contract("OptionsContract", (accounts) => {
it("should create a new option", async () => {
const contract = await OptionsContract.deployed();
const result = await contract.createOption(
0, // Call option
web3.utils.toWei("100", "ether"),
Math.floor(Date.now() / 1000) + 86400,
{ from: accounts[0] },
);
assert.ok(result.logs[0].args.optionId);
});
});- All tests pass locally
- Code follows style guidelines
- Documentation updated
- Commit messages are clear
- Branch is up-to-date with main
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review performed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings generated- Automated Checks: CI/CD pipeline runs automatically
- Code Review: At least one maintainer review required
- Testing: All tests must pass
- Approval: Maintainer approves PR
- Merge: Squash and merge to main
Python:
def complex_function(param1: int, param2: str) -> Dict[str, Any]:
"""
One-line summary.
Detailed explanation if needed.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Dictionary containing result fields
Raises:
ValueError: When validation fails
"""TypeScript:
/**
* Calculate option Greeks.
*
* @param spotPrice - Current spot price
* @param strikePrice - Strike price
* @returns Object containing all Greeks
*/
function calculateGreeks(spotPrice: number, strikePrice: number): Greeks {
// Implementation
}When adding new features:
- Update relevant
.mdfiles indocs/ - Add examples to
docs/EXAMPLES/ - Update API reference if applicable
- Add to
docs/FEATURE_MATRIX.md
DO NOT open public issues for security vulnerabilities.
Email security concerns to: security@optionix.com
Include:
- Description of vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if any)
-
Never commit secrets
- Use environment variables
- Add secrets to
.gitignore - Use
.env.exampleas template
-
Input Validation
- Validate all user input
- Use Pydantic schemas
- Sanitize output
-
Authentication
- Use provided auth service
- Never bypass authentication
- Implement rate limiting
-
Dependencies
- Keep dependencies updated
- Run
pip-auditregularly - Check for known vulnerabilities
type(scope): subject
body
footer
- feat: New feature
- fix: Bug fix
- docs: Documentation only
- style: Code style (formatting, no logic change)
- refactor: Code refactoring
- test: Adding or updating tests
- chore: Maintenance tasks
feat(pricing): add barrier option pricing
Implement up-and-out and down-and-out barrier options
using Monte Carlo simulation.
Closes #123
<type>/<short-description>
Examples:
feature/add-asian-options
fix/volatility-calculation-bug
docs/update-api-reference
- Keep PRs focused and small
- Write clear PR descriptions
- Respond to feedback promptly
- Request review when ready
- Be constructive and respectful
- Focus on code quality and design
- Suggest improvements, don't demand
- Approve when ready
VSCode Extensions:
- Python
- Pylance
- ESLint
- Prettier
- GitLens
PyCharm Plugins:
- Black
- MyPy
- pytest
# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
# Run manually
pre-commit run --all-files