Chart Features
- Real-time price updates via GraphQL subscriptions
- Candlestick (K-line) visualization
- Built-in technical indicators (RSI, MA, etc.)
- Multiple timeframe support
- Historical data with 500 data points
- Auto-updating latest candle
Chart Implementation
The charting interface is built using KLineCharts, a lightweight charting library optimized for financial data.Basic Chart Component
The main chart component is defined insrc/react-app/src/features/prices/components/prices-chart.tsx:
Fetching Chart Data
Query historical prices
Use GraphQL to fetch historical price data for the chart:Parameters:
last: Number of data points to retrieve (max 500)interval: Time interval (ONE_MINUTE,FIVE_MINUTES,ONE_HOUR,ONE_DAY)where: Filter by symbol
Multi-Chart View
Display multiple cryptocurrency charts side by side using theFocusedPricesCharts component (src/react-app/src/features/prices/components/focused-prices-charts.tsx):
ETH: and BTC:) to fetch data for multiple symbols in a single request.
Adding Technical Indicators
KLineCharts supports numerous technical indicators out of the box:RSI (Relative Strength Index)
Moving Average
MACD
Bollinger Bands
Real-time Updates
To keep charts updated with live prices, implement a polling or subscription strategy:Polling Strategy
GraphQL Subscription
For true real-time updates, use GraphQL subscriptions:Supported Intervals
PriceSignal aggregates price data at multiple intervals:| Interval | GraphQL Value | Use Case |
|---|---|---|
| 1 minute | ONE_MINUTE | Short-term trading |
| 5 minutes | FIVE_MINUTES | Intraday analysis |
| 15 minutes | FIFTEEN_MINUTES | Medium-term trends |
| 1 hour | ONE_HOUR | Daily monitoring |
| 4 hours | FOUR_HOURS | Swing trading |
| 1 day | ONE_DAY | Long-term analysis |
Chart Customization
Customize chart appearance and behavior:Custom Styles
Time Format
Precision
Price Data Structure
The price data returned from the backend follows this schema:Performance Optimization
Limit Data Points
Query only the data you need:Debounce Updates
When receiving frequent updates, debounce chart refreshes:Lazy Load Historical Data
Load older data on demand:Integration with Price Rules
Visualize your price rules on the chart by adding horizontal lines:Troubleshooting
Chart not rendering
- Ensure container has explicit height:
style={{ height: '400px' }} - Verify data is in correct KLineData format
- Check browser console for initialization errors
Updates not showing
- Confirm data array reference is changing (not mutating)
- Use
updateData()for latest candle,applyNewData()for full dataset - Check timestamp formats are consistent
Performance issues
- Reduce number of data points (use
lastparameter) - Disable auto-scaling if not needed
- Remove unused indicators
- Use
requestAnimationFramefor smooth updates
Next Steps
Creating Rules
Set up alerts based on chart patterns
Telegram Setup
Get notified when price targets are hit