A comprehensive technical analysis platform featuring both Python-based strategy development and a modern web interface for strategy testing and visualization. This project demonstrates object-oriented design principles applied to financial data analysis and algorithmic trading research.
This platform provides a complete toolkit for developing, testing, and analyzing trading strategies with both programmatic and web-based interfaces.
Core Engine (src/)
main.py- MarketData class with intelligent indicator cachingindicators.py- Technical indicator implementations (SMA, EMA, RSI, MACD)strategies.py- Trading strategy framework with multiple implementationsback_testing.py- Comprehensive backtesting engine with performance metrics
Web API (backend/)
app.py- FastAPI server with CORS supportmodels.py- Pydantic data models for API requestsrun.py- Backtesting execution interfacestrategy_config.py- Available strategy configurations
Modern React application built with TypeScript and Tailwind CSS featuring:
- Interactive custom strategy configuration interface
- Real-time backtesting execution
- Results visualization with metrics cards
- Trade-by-trade analysis tables
- Simple Moving Average (SMA) - Configurable period lengths
- Exponential Moving Average (EMA) - Smoothed price averaging
- Relative Strength Index (RSI) - Momentum oscillator with customizable periods
- MACD Components - Line, Signal Line, and Histogram with separate implementations
- Moving Average Crossover - Both SMA and EMA with configurable periods
- RSI Crossover - Signal generation based on RSI threshold crossings
- RSI Extremes - Buy/sell signals from overbought/oversold levels
- MACD Crossover - Classic MACD line vs signal line strategy
- MACD Histogram - Momentum signals from histogram zero crossings
- Custom Strategy - Combine multiple strategies with AND/OR logic
- Comprehensive Metrics - Total return, win rate, Sharpe ratio, maximum drawdown
- Trade Analysis - Entry/exit prices, duration, individual trade returns
- Risk Assessment - Drawdown analysis and risk-adjusted returns
- Python 3.8+
- Node.js 16+
- npm or yarn
- Install Python dependencies:
pip install -r requirements.txt- Start the FastAPI server:
python -m backend.appThe API will be available at http://localhost:8000
- Install dependencies:
cd frontend
npm install- Start the development server:
npm run devThe web interface will be available at http://localhost:5173
from src.main import MarketData
from src.strategies import MovingAverageCross, RSICross
from src.back_testing import BackTest
# Create market data instance
data = MarketData("AAPL", "2y")
# Configure strategy
strategy = MovingAverageCross(lower_period=50, upper_period=200, ma_type="SMA")
# Run backtest
backtest = BackTest(initial_capital=10000)
results = backtest.run_backtest(data, strategy)
backtest.print_results(results)- Open the web application
- Add one or more trading strategies using the interface
- Enter a stock ticker symbol (e.g., "AAPL", "TSLA")
- Set initial capital and time period
- Click "Test Strategy" to run the backtest
- Review comprehensive results including performance metrics and trade history
Moving Average Crossover:
- Lower Period: 50
- Upper Period: 200
- MA Type: SMA
RSI Extremes:
- RSI Period: 14
- Oversold Threshold: 30
- Overbought Threshold: 70
MACD Crossover:
- Short Period: 12
- Long Period: 26
- Signal Period: 9
- Abstract Base Classes - Strategy and Indicator interfaces ensure consistency
- Intelligent Caching - Indicators are cached to prevent recomputation
- Parameterized Strategies - Easy experimentation with different configurations
- Data Validation - Comprehensive input validation and error handling
- RESTful Interface - Clean API endpoints for strategy execution
- Type Safety - Pydantic models for request/response validation
- CORS Support - Enables frontend-backend communication
- Error Handling - Graceful error responses with detailed messages
- TypeScript - Type-safe React components
- Tailwind CSS - Utility-first styling framework
- Component Architecture - Reusable UI components for consistency
- State Management - Efficient state handling for strategy configuration
The project includes comprehensive testing:
# Run Python tests
python -m pytest tests/
# Run frontend linting
cd frontend
npm run lintPOST /backtest- Execute strategy backtestGET /strategies- Retrieve available strategy configurations
tech-analysis/
├── src/ # Core Python engine
│ ├── main.py # Market data management
│ ├── indicators.py # Technical indicators
│ ├── strategies.py # Trading strategies
│ └── back_testing.py # Backtesting framework
├── backend/ # FastAPI web server
│ ├── app.py # Main API application
│ ├── models.py # Data models
│ └── run.py # Execution interface
├── frontend/ # React web application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Application pages
│ │ ├── services/ # API communication
│ │ └── utils/ # Helper functions
│ └── package.json
├── tests/ # Test suite
└── requirements.txt # Python dependencies
This project demonstrates modern software engineering practices applied to financial markets. Contributions and suggestions for improvements are welcome.
This software is for educational and research purposes only. Past performance does not guarantee future results. Trading strategies should be thoroughly tested and validated before any real-world application.