This is a React TypeScript conversion of the original StockInsights application. The application maintains the same functionality for analyzing stock price drops while using modern React patterns and TypeScript for better type safety.
- Max Drop Analysis: Find the maximum percentage drop from peak to valley
- Longest Drop Analysis: Find the longest duration drop period (either recovered or ongoing)
- Interactive Stock Chart: Visualize stock price movements with ApexCharts
- Multiple Summary Panels: Compare analysis results across different stocks and time periods
- Stock Management: Add and remove stocks dynamically
- Responsive Design: Works on desktop and mobile devices
- React 18 with TypeScript
- ApexCharts for data visualization
- Bootstrap 5 for UI components
- Modern Fetch API for data requests
- CSS Grid for responsive layouts
src/
├── components/ # React components
│ ├── StockChart.tsx # ApexCharts integration
│ ├── SummaryPanel.tsx # Analysis results display
│ ├── ControlPanel.tsx # User controls
│ └── AddStockModal.tsx# Stock symbol picker
├── utils/ # Utility functions
│ ├── StockAnalyser.ts # Drop analysis calculations
│ └── ApiService.ts # API communication
├── types/ # TypeScript interfaces
│ └── index.ts # Type definitions
├── App.tsx # Main application component
├── App.css # Global styles
└── index.tsx # Application entry point
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open http://localhost:3000 to view it in the browser.
The application expects a backend API running on localhost:3000 with the following endpoints:
GET /getdefaultlist- Returns default stock symbolsGET /getsymbols- Returns all available stock symbolsGET /:symbol- Returns historical price data for a symbolPUT /addstock?symbol=:symbol- Adds a new stock symbolPUT /deletestock?symbol=:symbol- Removes a stock symbol
The GET /:symbol endpoint must return data in this exact format:
[
"{\"Date\":\"12/2/2022\",\"Open\":20,\"High\":20.3799991607666,\"Low\":20,\"Close\":20.200000762939453,\"Volume\":1383500}",
"{\"Date\":\"12/5/2022\",\"Open\":20.06999969482422,\"High\":20.100000381469727,\"Low\":19.899999618530273,\"Close\":19.93199920654297,\"Volume\":17900}",
"{\"Date\":\"12/6/2022\",\"Open\":19.90999984741211,\"High\":19.975000381469727,\"Low\":19.84000015258789,\"Close\":19.91900062561035,\"Volume\":165200}",
"{\"Date\":\"12/7/2022\",\"Open\":19.850000381469727,\"High\":19.940000534057617,\"Low\":19.799999237060547,\"Close\":19.86199951171875,\"Volume\":28900}",
"{\"Date\":\"12/8/2022\",\"Open\":20.059999465942383,\"High\":20.059999465942383,\"Low\":19.979999542236328,\"Close\":20.027999877929688,\"Volume\":75600}"
]Format Requirements:
- Array of JSON Strings: Each array element is a stringified JSON object
- All Data Elements: Every element contains actual price data (no header element)
- Data Elements: All elements should have consistent field structure
- Required Fields: Each data object must contain:
Date,Open,High,Low,Close,Volume - Date Format: MM/dd/yyyy string format
- Price Fields: Numeric values (can be integers or decimals)
- Volume: Integer representing trading volume
Critical Notes:
- The parser expects ALL data objects to have the same number of fields for consistency
- Missing fields will cause the entire data point to be skipped
- Date strings must be parseable by JavaScript's Date constructor
- This format is parsed by
ApiService.convertRawDataToList()method
Mock Data: Reference implementation available at src/data/mockApiData.json for testing when API is unavailable.
- Component Architecture: Modular React components instead of monolithic JavaScript classes
- Type Safety: Full TypeScript support with interfaces and type checking
- Modern Patterns: React hooks, state management, and functional components
- No jQuery: Pure React DOM manipulation
- Modern API: Fetch API instead of jQuery AJAX
- Responsive Grid: CSS Grid for better mobile support
- Error Handling: Comprehensive error handling and loading states
To build for production:
npm run buildTo run tests:
npm test- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
The application uses modern JavaScript features and requires ES6+ support.