A modern stock price prediction game built with React and TypeScript. Test your market intuition by analyzing historical price data and predicting future movements.
Getting Started โข Features โข How It Works โข Development โข Testing โข Contributing
Price Prophet is an interactive financial game that challenges users to predict future stock prices using simulated market data. The application generates realistic price movements using Geometric Brownian Motion (GBM) and provides a professional-grade trading interface for analysis and prediction.
- Real-time price simulation using GBM
- Multiple timeframe analysis (1m to Monthly)
- Three difficulty levels with increasing prediction horizons
- Interactive candlestick charts with technical analysis tools
- Performance tracking and statistics
- Global leaderboard system
- Cross-device progress persistence
- Geometric Brownian Motion (GBM) implementation for realistic price movements
- Minute-level data generation with configurable parameters:
- Volatility (0.1 to 3.0)
- Drift (-1.0 to 1.0)
- Time horizon (1-365 days)
- Automatic aggregation to multiple timeframes
- Realistic OHLC (Open-High-Low-Close) relationships
-
TradingView Integration
- Lightweight Charts library for optimal performance
- Multiple timeframe support (1m, 5m, 15m, 1h, 4h, D, W, M)
- Smooth data transitions and animations
- Responsive design with touch support
-
Chart Features
- Candlestick visualization
- Price axis formatting
- Time axis with dynamic formatting
- Interactive crosshair
- Custom tooltips
- Zoom and pan controls
-
Difficulty Levels
- Easy: 1-day prediction (24 hours)
- Medium: 7-day prediction (1 week)
- Hard: 30-day prediction (1 month)
-
Scoring System
- Points based on prediction accuracy
- Streak bonuses for consecutive correct predictions
- Difficulty multipliers
- Global ranking system
-
Start Phase
- Difficulty selection
- Initial data loading
- Game state initialization
-
Prediction Phase
- Historical data analysis
- Multiple timeframe review
- Price selection from options
-
Feedback Phase
- Immediate result display
- Score update
- Progress tracking
-
Results Phase
- Final score calculation
- Performance statistics
- Historical comparison
- Global ranking update
The RandomOHLC
class implements GBM for price simulation:
interface RandomOhlcConfig {
daysNeeded: number; // Simulation duration
startPrice: number; // Initial price
volatility: number; // Price volatility (0.1-3.0)
drift: number; // Price trend (-1.0 to 1.0)
}
-
Game State
- React Context for global state
- Local state for component-specific data
- LocalStorage for persistence
-
User Data
- Profile management
- Score history
- Performance statistics
- Device fingerprinting
- Memoized calculations with useMemo
- Callback optimization with useCallback
- Virtual scrolling for large datasets
- Debounced event handlers
- Efficient data structures
- Lazy loading of components
- Node.js 16+
- npm or yarn for package management
- Git for version control
git clone https://github.com/RoryGlenn/PriceProphet.git
cd PriceProphet
npm install # or yarn install
# Start development server
npm start
# Run tests in watch mode
npm test
# Build for production
npm run build
- TypeScript: Static type checking
- ESLint: Code linting with custom rules
- Prettier: Code formatting
- Husky: Pre-commit hooks
- lint-staged: Staged files linting
npm start # Start development server
npm test # Run tests in watch mode
npm run build # Build for production
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint issues
npm run format # Format code with Prettier
npm run validate # Run all checks
- Create feature branch
- Implement changes
- Run validation checks
- Submit pull request
- Address review feedback
- Unit Tests: 80% coverage
- Integration Tests: Key user flows
- Component Tests: UI interactions
- Service Tests: Data management
npm test # Watch mode
npm run test:coverage # Coverage report
npm run test:ci # CI mode
src/
โโโ components/ # React components
โ โโโ ChartComponent.tsx # Interactive candlestick chart
โ โโโ ChartPredictionView.tsx # Main game prediction interface
โ โโโ WelcomePage.tsx # Landing/difficulty selection
โ โโโ ResultsPage.tsx # Game results and statistics
โ โโโ ErrorBoundary.tsx # Error handling component
โ
โโโ services/ # Application services
โ โโโ localStorageService.ts # Game data persistence
โ โโโ userInfoService.ts # User profile management
โ
โโโ styles/ # Styling and theming
โ โโโ theme.ts # Material-UI theme configuration
โ
โโโ utils/ # Utility functions
โ โโโ priceUtils.ts # Price formatting and calculations
โ
โโโ __mocks__/ # Test mock implementations
โ โโโ lightweight-charts.ts # Chart library mocks
โ
โโโ __tests__/ # Test files
โ โโโ components/ # Component tests
โ โโโ services/ # Service tests
โ โโโ utils/ # Utility tests
โ
โโโ types.ts # TypeScript type definitions
โโโ App.tsx # Main application component
โโโ index.tsx # Application entry point
โโโ setupTests.ts # Test configuration
โโโ index.css # Global styles
- React 18+: UI framework
- TypeScript 4+: Type safety
- Material-UI 5+: Component library
- Lightweight Charts: Chart rendering
- Luxon: Date handling
- UUID: Unique ID generation
- Jest: Testing framework
- React Testing Library: Component testing
- ESLint: Code linting
- Prettier: Code formatting
- Husky: Git hooks
- TypeDoc: Documentation generation
- Run validation:
npm run validate
- Build app:
npm run build
- Deploy to hosting platform
- GitHub Pages (current)
- Vercel
- Netlify
- AWS S3/CloudFront
- Fork repository
- Create feature branch
- Implement changes
- Run tests and checks
- Submit pull request
- Follow TypeScript best practices
- Write comprehensive tests
- Update documentation
- Follow commit conventions
This project is licensed under the MIT License. See the LICENSE file for details.
- TradingView for Lightweight Charts
- Material-UI team
- React community
- All contributors