diff --git a/prediqo_mobile/android/build/reports/problems/problems-report.html b/prediqo_mobile/android/build/reports/problems/problems-report.html index 06960060..d3f963a9 100644 --- a/prediqo_mobile/android/build/reports/problems/problems-report.html +++ b/prediqo_mobile/android/build/reports/problems/problems-report.html @@ -650,7 +650,7 @@ code + .copy-button { diff --git a/prediqo_mobile/lib/features/prediction/domain/candle_predict_instrument.dart b/prediqo_mobile/lib/features/prediction/domain/candle_predict_instrument.dart new file mode 100644 index 00000000..4b6cebf8 --- /dev/null +++ b/prediqo_mobile/lib/features/prediction/domain/candle_predict_instrument.dart @@ -0,0 +1,69 @@ +/// Synthetic chart instrument for Candle Predict (display identity only). +/// +/// OHLC always comes from the Prediqo backend — never from an external market. +/// +/// Candle Predict uses a **single** active instrument. To change what the chart +/// shows, edit [candlePredictInstrument] (symbol, displayName, quoteCurrency). +class CandlePredictInstrument { + const CandlePredictInstrument({ + required this.id, + required this.symbol, + required this.displayName, + required this.quoteCurrency, + this.instrumentType = 'SYNTHETIC', + this.priceDigits = 2, + }); + + /// Stable internal key (not shown on the chart). + final String id; + + /// Short ticker, e.g. FO. + final String symbol; + + /// Human-readable name, e.g. Full Option. + final String displayName; + + /// Quote unit for the price, e.g. USDT. + final String quoteCurrency; + + final String instrumentType; + + /// Decimal places for price labels on the chart. + final int priceDigits; + + /// Pair ticker, e.g. FO/USDT. + String get pairSymbol => '$symbol/$quoteCurrency'; + + /// Header line, e.g. FO/USDT — Full Option. + String get chartTitle => '$pairSymbol — $displayName'; + + /// Price subtitle, e.g. FO/USDT — 105.50. + String priceLabel(double price) => + '$pairSymbol — ${price.toStringAsFixed(priceDigits)}'; + + CandlePredictInstrument copyWith({ + String? id, + String? symbol, + String? displayName, + String? quoteCurrency, + String? instrumentType, + int? priceDigits, + }) { + return CandlePredictInstrument( + id: id ?? this.id, + symbol: symbol ?? this.symbol, + displayName: displayName ?? this.displayName, + quoteCurrency: quoteCurrency ?? this.quoteCurrency, + instrumentType: instrumentType ?? this.instrumentType, + priceDigits: priceDigits ?? this.priceDigits, + ); + } +} + +/// Active chart instrument — edit these fields to rename / rebrand the pair. +const candlePredictInstrument = CandlePredictInstrument( + id: 'fo', + symbol: 'FO', + displayName: 'Full Option', + quoteCurrency: 'USDT', +); diff --git a/prediqo_mobile/lib/features/prediction/presentation/widgets/candle_chart_widget.dart b/prediqo_mobile/lib/features/prediction/presentation/widgets/candle_chart_widget.dart index ff363fe1..c22547d9 100644 --- a/prediqo_mobile/lib/features/prediction/presentation/widgets/candle_chart_widget.dart +++ b/prediqo_mobile/lib/features/prediction/presentation/widgets/candle_chart_widget.dart @@ -4,6 +4,7 @@ import '../../../../core/theme/app_colors.dart'; import '../../../../data/models/prediction_models.dart'; import '../../../../l10n/app_strings.dart'; import '../../bloc/prediction_bloc.dart'; +import '../../domain/candle_predict_instrument.dart'; /// Horizontally scrollable candlestick chart (latest candles on the right). /// Y-scale fits the **visible** window so candle size stays consistent across intervals. @@ -217,7 +218,7 @@ class _CandleChartWidgetState extends State { ), if (widget.isLoadingOlder) const Positioned( - left: 8, + right: 8, top: 8, child: SizedBox( width: 16, @@ -225,6 +226,50 @@ class _CandleChartWidgetState extends State { child: CircularProgressIndicator(strokeWidth: 2), ), ), + Positioned( + left: 10, + top: 8, + child: IgnorePointer( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + candlePredictInstrument.pairSymbol, + style: Theme.of(context).textTheme.titleSmall?.copyWith( + fontWeight: FontWeight.w800, + color: Colors.white.withValues(alpha: 0.92), + shadows: const [ + Shadow(blurRadius: 8, color: Colors.black54), + ], + ), + ), + Text( + candlePredictInstrument.displayName, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Colors.white.withValues(alpha: 0.72), + shadows: const [ + Shadow(blurRadius: 6, color: Colors.black54), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(top: 2), + child: Text( + candlePredictInstrument.priceLabel(candles.last.close), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + fontFamily: 'monospace', + fontWeight: FontWeight.w600, + color: const Color(0xFFD6B25E).withValues(alpha: 0.95), + shadows: const [ + Shadow(blurRadius: 6, color: Colors.black54), + ], + ), + ), + ), + ], + ), + ), + ), ], ); }, diff --git a/prediqo_web/src/features/candle-predict/components/CandlestickChart.tsx b/prediqo_web/src/features/candle-predict/components/CandlestickChart.tsx index 4dce5441..393bce11 100644 --- a/prediqo_web/src/features/candle-predict/components/CandlestickChart.tsx +++ b/prediqo_web/src/features/candle-predict/components/CandlestickChart.tsx @@ -1,8 +1,14 @@ -import { Box, CircularProgress, Typography } from '@mui/material'; +import { Box, CircularProgress, Stack, Typography } from '@mui/material'; import { CandlestickSeries, ColorType, createChart, type IChartApi, type ISeriesApi } from 'lightweight-charts'; import { memo, useEffect, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import type { OhlcCandle } from '../types'; +import { + getActiveInstrument, + instrumentChartTitle, + instrumentPairSymbol, + instrumentPriceLabel, +} from '../instrumentConfig'; /** Fixed viewport: always show this many candles at the same pixel width. */ const VISIBLE_CANDLE_COUNT = 20; @@ -78,6 +84,12 @@ export const CandlestickChart = memo(function CandlestickChart({ hasMoreOlderRef.current = hasMoreOlder; loadingOlderRef.current = loadingOlder; + const instrument = getActiveInstrument(); + const lastClose = candles.length ? candles[candles.length - 1]!.close : null; + const pairSymbol = instrumentPairSymbol(instrument); + const chartTitle = instrumentChartTitle(instrument); + const priceLine = lastClose != null ? instrumentPriceLabel(lastClose, instrument) : pairSymbol; + useEffect(() => { if (!containerRef.current) return; @@ -244,13 +256,67 @@ export const CandlestickChart = memo(function CandlestickChart({ 'linear-gradient(180deg, rgba(18,23,36,0.95) 0%, rgba(11,14,20,0.85) 100%)', }} /> + + + {pairSymbol} + + + {instrument.displayName} + + {lastClose != null && ( + + {priceLine} + + )} + {loadingOlder && ( diff --git a/prediqo_web/src/features/candle-predict/instrumentConfig.ts b/prediqo_web/src/features/candle-predict/instrumentConfig.ts new file mode 100644 index 00000000..154c6452 --- /dev/null +++ b/prediqo_web/src/features/candle-predict/instrumentConfig.ts @@ -0,0 +1,66 @@ +/** + * Synthetic chart instrument for Candle Predict. + * + * Display-only identity — OHLC always comes from our backend engine, never from + * TradingView / Binance / any external market feed. + * + * Candle Predict uses a single active instrument. To change it, edit + * {@link CANDLE_PREDICT_INSTRUMENT} below (symbol, name, quote currency). + * Helpers always resolve through {@link getActiveInstrument}. + */ + +export type InstrumentType = 'SYNTHETIC'; + +export type SyntheticInstrumentConfig = { + /** Stable internal key (not shown on the chart). */ + id: string; + /** Short ticker, e.g. FO */ + symbol: string; + /** Human-readable name, e.g. Full Option */ + displayName: string; + /** Quote unit for the price, e.g. USDT */ + quoteCurrency: string; + instrumentType: InstrumentType; + /** Decimal places for price labels on the chart. */ + priceDigits: number; +}; + +/** + * Active chart instrument — edit this object to rename / rebrand the pair. + * Keep a single entry; multi-instrument switching is not required today. + */ +export const CANDLE_PREDICT_INSTRUMENT: SyntheticInstrumentConfig = { + id: 'fo', + symbol: 'FO', + displayName: 'Full Option', + quoteCurrency: 'USDT', + instrumentType: 'SYNTHETIC', + priceDigits: 2, +}; + +/** Returns the instrument currently shown on the Candle Predict chart. */ +export function getActiveInstrument(): SyntheticInstrumentConfig { + return CANDLE_PREDICT_INSTRUMENT; +} + +/** Pair ticker shown on the chart, e.g. FO/USDT */ +export function instrumentPairSymbol( + instrument: SyntheticInstrumentConfig = getActiveInstrument() +): string { + return `${instrument.symbol}/${instrument.quoteCurrency}`; +} + +/** Header line, e.g. FO/USDT — Full Option */ +export function instrumentChartTitle( + instrument: SyntheticInstrumentConfig = getActiveInstrument() +): string { + return `${instrumentPairSymbol(instrument)} — ${instrument.displayName}`; +} + +/** Price subtitle, e.g. FO/USDT — 105.50 */ +export function instrumentPriceLabel( + price: number, + instrument: SyntheticInstrumentConfig = getActiveInstrument() +): string { + return `${instrumentPairSymbol(instrument)} — ${price.toFixed(instrument.priceDigits)}`; +}