Skip to content

RoryGlenn/PriceProphet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Price Prophet ๐ŸŽฏ

TypeScript React Material-UI License: MIT

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


๐ŸŽฎ Overview

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.

Core Features

  • 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

โœจ Features

๐Ÿ“Š Advanced Data Generation

  • 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

๐Ÿ“ˆ Professional Trading Interface

  • 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

๐ŸŽฏ Game Mechanics

  • 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

๐Ÿ”„ Game Flow

  1. Start Phase

    • Difficulty selection
    • Initial data loading
    • Game state initialization
  2. Prediction Phase

    • Historical data analysis
    • Multiple timeframe review
    • Price selection from options
  3. Feedback Phase

    • Immediate result display
    • Score update
    • Progress tracking
  4. Results Phase

    • Final score calculation
    • Performance statistics
    • Historical comparison
    • Global ranking update

๐Ÿ” Technical Implementation

Data Generation

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)
}

State Management

  • 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

Performance Optimizations

  • Memoized calculations with useMemo
  • Callback optimization with useCallback
  • Virtual scrolling for large datasets
  • Debounced event handlers
  • Efficient data structures
  • Lazy loading of components

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 16+
  • npm or yarn for package management
  • Git for version control

Installation

git clone https://github.com/RoryGlenn/PriceProphet.git
cd PriceProphet
npm install  # or yarn install

Development Setup

# Start development server
npm start

# Run tests in watch mode
npm test

# Build for production
npm run build

๐Ÿ’ป Development

Code Quality Tools

  • TypeScript: Static type checking
  • ESLint: Code linting with custom rules
  • Prettier: Code formatting
  • Husky: Pre-commit hooks
  • lint-staged: Staged files linting

Available Scripts

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

Development Workflow

  1. Create feature branch
  2. Implement changes
  3. Run validation checks
  4. Submit pull request
  5. Address review feedback

๐Ÿงช Testing

Test Coverage Requirements

  • Unit Tests: 80% coverage
  • Integration Tests: Key user flows
  • Component Tests: UI interactions
  • Service Tests: Data management

Running Tests

npm test              # Watch mode
npm run test:coverage # Coverage report
npm run test:ci      # CI mode

๐Ÿ“ Project Structure

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

๐Ÿ“ฆ Dependencies

Core Dependencies

  • React 18+: UI framework
  • TypeScript 4+: Type safety
  • Material-UI 5+: Component library
  • Lightweight Charts: Chart rendering
  • Luxon: Date handling
  • UUID: Unique ID generation

Development Dependencies

  • Jest: Testing framework
  • React Testing Library: Component testing
  • ESLint: Code linting
  • Prettier: Code formatting
  • Husky: Git hooks
  • TypeDoc: Documentation generation

๐Ÿš€ Deployment

Build Process

  1. Run validation: npm run validate
  2. Build app: npm run build
  3. Deploy to hosting platform

Hosting Options

  • GitHub Pages (current)
  • Vercel
  • Netlify
  • AWS S3/CloudFront

๐Ÿค Contributing

Getting Started

  1. Fork repository
  2. Create feature branch
  3. Implement changes
  4. Run tests and checks
  5. Submit pull request

Guidelines

  • Follow TypeScript best practices
  • Write comprehensive tests
  • Update documentation
  • Follow commit conventions

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • TradingView for Lightweight Charts
  • Material-UI team
  • React community
  • All contributors

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published