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