After correcting the design on chart1
This commit is contained in:
parent
f242c9d210
commit
15e860c6db
@ -648,6 +648,11 @@ CREATE TABLE IF NOT EXISTS candle_predict_config (
|
||||
wallet_type_code VARCHAR(32) NOT NULL DEFAULT 'USDT_TRC20',
|
||||
auto_modes JSONB NOT NULL DEFAULT '["each_round","interval"]'::jsonb,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
-- Display-only synthetic instrument branding (OHLC still from Prediqo engine).
|
||||
instrument_symbol VARCHAR(16) NOT NULL DEFAULT 'FO',
|
||||
instrument_display_name VARCHAR(64) NOT NULL DEFAULT 'Full Option',
|
||||
instrument_quote_currency VARCHAR(16) NOT NULL DEFAULT 'USDT',
|
||||
instrument_price_digits SMALLINT NOT NULL DEFAULT 2 CHECK (instrument_price_digits >= 0 AND instrument_price_digits <= 8),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
@ -2712,3 +2717,20 @@ BEGIN
|
||||
);
|
||||
END $$;
|
||||
|
||||
-- Candle Predict chart instrument branding (admin-editable, display-only)
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'candle_predict_config'
|
||||
AND column_name = 'instrument_symbol'
|
||||
) THEN
|
||||
ALTER TABLE candle_predict_config
|
||||
ADD COLUMN instrument_symbol VARCHAR(16) NOT NULL DEFAULT 'FO',
|
||||
ADD COLUMN instrument_display_name VARCHAR(64) NOT NULL DEFAULT 'Full Option',
|
||||
ADD COLUMN instrument_quote_currency VARCHAR(16) NOT NULL DEFAULT 'USDT',
|
||||
ADD COLUMN instrument_price_digits SMALLINT NOT NULL DEFAULT 2
|
||||
CHECK (instrument_price_digits >= 0 AND instrument_price_digits <= 8);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
|
||||
@ -245,6 +245,13 @@ function mapConfig(row: repo.CandlePredictConfigRow) {
|
||||
auto: row.prediction_auto_enabled ?? true,
|
||||
multiCandle: row.prediction_multi_enabled ?? true,
|
||||
},
|
||||
/** Display-only chart identity (synthetic; not an external market symbol). */
|
||||
instrument: {
|
||||
symbol: row.instrument_symbol ?? 'FO',
|
||||
displayName: row.instrument_display_name ?? 'Full Option',
|
||||
quoteCurrency: row.instrument_quote_currency ?? 'USDT',
|
||||
priceDigits: Number(row.instrument_price_digits ?? 2),
|
||||
},
|
||||
updatedAt: row.updated_at.toISOString(),
|
||||
};
|
||||
}
|
||||
@ -632,6 +639,54 @@ export async function updateAdminConfig(body: Record<string, unknown>) {
|
||||
dailyRevenueOverflowStrategy = body.dailyRevenueOverflowStrategy;
|
||||
}
|
||||
|
||||
const instrumentBody =
|
||||
typeof body.instrument === 'object' && body.instrument !== null
|
||||
? (body.instrument as Record<string, unknown>)
|
||||
: null;
|
||||
|
||||
const instrumentSymbol =
|
||||
typeof instrumentBody?.symbol === 'string'
|
||||
? instrumentBody.symbol.trim()
|
||||
: typeof body.instrumentSymbol === 'string'
|
||||
? body.instrumentSymbol.trim()
|
||||
: undefined;
|
||||
const instrumentDisplayName =
|
||||
typeof instrumentBody?.displayName === 'string'
|
||||
? instrumentBody.displayName.trim()
|
||||
: typeof body.instrumentDisplayName === 'string'
|
||||
? body.instrumentDisplayName.trim()
|
||||
: undefined;
|
||||
const instrumentQuoteCurrency =
|
||||
typeof instrumentBody?.quoteCurrency === 'string'
|
||||
? instrumentBody.quoteCurrency.trim()
|
||||
: typeof body.instrumentQuoteCurrency === 'string'
|
||||
? body.instrumentQuoteCurrency.trim()
|
||||
: undefined;
|
||||
const instrumentPriceDigits =
|
||||
typeof instrumentBody?.priceDigits === 'number'
|
||||
? instrumentBody.priceDigits
|
||||
: typeof body.instrumentPriceDigits === 'number'
|
||||
? body.instrumentPriceDigits
|
||||
: undefined;
|
||||
|
||||
if (instrumentSymbol !== undefined && !instrumentSymbol) {
|
||||
throw new Error('instrument.symbol must not be empty');
|
||||
}
|
||||
if (instrumentDisplayName !== undefined && !instrumentDisplayName) {
|
||||
throw new Error('instrument.displayName must not be empty');
|
||||
}
|
||||
if (instrumentQuoteCurrency !== undefined && !instrumentQuoteCurrency) {
|
||||
throw new Error('instrument.quoteCurrency must not be empty');
|
||||
}
|
||||
if (
|
||||
instrumentPriceDigits !== undefined &&
|
||||
(!Number.isInteger(instrumentPriceDigits) ||
|
||||
instrumentPriceDigits < 0 ||
|
||||
instrumentPriceDigits > 8)
|
||||
) {
|
||||
throw new Error('instrument.priceDigits must be an integer between 0 and 8');
|
||||
}
|
||||
|
||||
const updated = await repo.updateConfig({
|
||||
stakeAmounts,
|
||||
minStakeAmount,
|
||||
@ -681,6 +736,10 @@ export async function updateAdminConfig(body: Record<string, unknown>) {
|
||||
typeof (body.predictionTypes as { multiCandle?: boolean }).multiCandle === 'boolean'
|
||||
? (body.predictionTypes as { multiCandle: boolean }).multiCandle
|
||||
: undefined,
|
||||
instrumentSymbol,
|
||||
instrumentDisplayName,
|
||||
instrumentQuoteCurrency,
|
||||
instrumentPriceDigits,
|
||||
});
|
||||
|
||||
// Global enable toggles should win over stale per-interval "on/off" overrides.
|
||||
|
||||
@ -27,6 +27,14 @@ export type CandlePredictConfigRow = {
|
||||
prediction_single_enabled: boolean;
|
||||
prediction_auto_enabled: boolean;
|
||||
prediction_multi_enabled: boolean;
|
||||
/** Short ticker shown on the chart, e.g. FO */
|
||||
instrument_symbol: string;
|
||||
/** Full instrument name, e.g. Full Option */
|
||||
instrument_display_name: string;
|
||||
/** Quote currency for the pair, e.g. USDT */
|
||||
instrument_quote_currency: string;
|
||||
/** Decimal places for chart price labels */
|
||||
instrument_price_digits: number;
|
||||
updated_at: Date;
|
||||
};
|
||||
|
||||
@ -158,6 +166,10 @@ export type ConfigUpdate = Partial<{
|
||||
predictionSingleEnabled: boolean;
|
||||
predictionAutoEnabled: boolean;
|
||||
predictionMultiEnabled: boolean;
|
||||
instrumentSymbol: string;
|
||||
instrumentDisplayName: string;
|
||||
instrumentQuoteCurrency: string;
|
||||
instrumentPriceDigits: number;
|
||||
}>;
|
||||
|
||||
export async function updateConfig(update: ConfigUpdate): Promise<CandlePredictConfigRow> {
|
||||
@ -181,12 +193,16 @@ export async function updateConfig(update: ConfigUpdate): Promise<CandlePredictC
|
||||
wallet_type_code = $15,
|
||||
auto_modes = $16::jsonb,
|
||||
is_active = $17,
|
||||
prediction_single_enabled = $18,
|
||||
prediction_auto_enabled = $19,
|
||||
prediction_multi_enabled = $20,
|
||||
daily_revenue_target = $21,
|
||||
daily_revenue_overflow_strategy = $22,
|
||||
updated_at = NOW()
|
||||
prediction_single_enabled = $18,
|
||||
prediction_auto_enabled = $19,
|
||||
prediction_multi_enabled = $20,
|
||||
daily_revenue_target = $21,
|
||||
daily_revenue_overflow_strategy = $22,
|
||||
instrument_symbol = $23,
|
||||
instrument_display_name = $24,
|
||||
instrument_quote_currency = $25,
|
||||
instrument_price_digits = $26,
|
||||
updated_at = NOW()
|
||||
WHERE id = 1
|
||||
RETURNING *`,
|
||||
[
|
||||
@ -214,6 +230,10 @@ export async function updateConfig(update: ConfigUpdate): Promise<CandlePredictC
|
||||
update.dailyRevenueOverflowStrategy ??
|
||||
current.daily_revenue_overflow_strategy ??
|
||||
'neutral',
|
||||
update.instrumentSymbol ?? current.instrument_symbol ?? 'FO',
|
||||
update.instrumentDisplayName ?? current.instrument_display_name ?? 'Full Option',
|
||||
update.instrumentQuoteCurrency ?? current.instrument_quote_currency ?? 'USDT',
|
||||
update.instrumentPriceDigits ?? current.instrument_price_digits ?? 2,
|
||||
]
|
||||
);
|
||||
return rows[0];
|
||||
|
||||
@ -42,6 +42,19 @@ export const candlePredictAdminConfigBodySchema = atLeastOneField(
|
||||
predictionAutoEnabled: z.boolean().optional(),
|
||||
predictionMultiEnabled: z.boolean().optional(),
|
||||
predictionTypes: predictionTypesSchema,
|
||||
/** Nested chart instrument branding (preferred). */
|
||||
instrument: z
|
||||
.object({
|
||||
symbol: z.string().trim().min(1).max(16).optional(),
|
||||
displayName: z.string().trim().min(1).max(64).optional(),
|
||||
quoteCurrency: z.string().trim().min(1).max(16).optional(),
|
||||
priceDigits: z.number().int().min(0).max(8).optional(),
|
||||
})
|
||||
.optional(),
|
||||
instrumentSymbol: z.string().trim().min(1).max(16).optional(),
|
||||
instrumentDisplayName: z.string().trim().min(1).max(64).optional(),
|
||||
instrumentQuoteCurrency: z.string().trim().min(1).max(16).optional(),
|
||||
instrumentPriceDigits: z.number().int().min(0).max(8).optional(),
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
/// 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).
|
||||
/// Runtime values come from game config and are edited in web Catalog → Candle.
|
||||
class CandlePredictInstrument {
|
||||
const CandlePredictInstrument({
|
||||
required this.id,
|
||||
@ -41,6 +39,17 @@ class CandlePredictInstrument {
|
||||
String priceLabel(double price) =>
|
||||
'$pairSymbol — ${price.toStringAsFixed(priceDigits)}';
|
||||
|
||||
factory CandlePredictInstrument.fromJson(Map<String, dynamic>? json) {
|
||||
if (json == null) return defaultCandlePredictInstrument;
|
||||
final digits = (json['priceDigits'] as num?)?.toInt();
|
||||
return defaultCandlePredictInstrument.copyWith(
|
||||
symbol: (json['symbol'] as String?)?.trim(),
|
||||
displayName: (json['displayName'] as String?)?.trim(),
|
||||
quoteCurrency: (json['quoteCurrency'] as String?)?.trim(),
|
||||
priceDigits: digits == null ? null : digits.clamp(0, 8),
|
||||
);
|
||||
}
|
||||
|
||||
CandlePredictInstrument copyWith({
|
||||
String? id,
|
||||
String? symbol,
|
||||
@ -51,19 +60,25 @@ class CandlePredictInstrument {
|
||||
}) {
|
||||
return CandlePredictInstrument(
|
||||
id: id ?? this.id,
|
||||
symbol: symbol ?? this.symbol,
|
||||
displayName: displayName ?? this.displayName,
|
||||
quoteCurrency: quoteCurrency ?? this.quoteCurrency,
|
||||
symbol: (symbol == null || symbol.isEmpty) ? this.symbol : symbol,
|
||||
displayName:
|
||||
(displayName == null || displayName.isEmpty) ? this.displayName : displayName,
|
||||
quoteCurrency: (quoteCurrency == null || quoteCurrency.isEmpty)
|
||||
? this.quoteCurrency
|
||||
: quoteCurrency,
|
||||
instrumentType: instrumentType ?? this.instrumentType,
|
||||
priceDigits: priceDigits ?? this.priceDigits,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Active chart instrument — edit these fields to rename / rebrand the pair.
|
||||
const candlePredictInstrument = CandlePredictInstrument(
|
||||
/// Fallback branding when API config has not loaded yet.
|
||||
const defaultCandlePredictInstrument = CandlePredictInstrument(
|
||||
id: 'fo',
|
||||
symbol: 'FO',
|
||||
displayName: 'Full Option',
|
||||
quoteCurrency: 'USDT',
|
||||
);
|
||||
|
||||
/// @deprecated Prefer [defaultCandlePredictInstrument] or config.instrument.
|
||||
const candlePredictInstrument = defaultCandlePredictInstrument;
|
||||
@ -1,6 +1,8 @@
|
||||
/// Candle Predict game models parsed from API responses.
|
||||
library;
|
||||
|
||||
import 'candle_predict_instrument.dart';
|
||||
|
||||
class GameStateModel {
|
||||
const GameStateModel({
|
||||
required this.config,
|
||||
@ -96,6 +98,7 @@ class PredictConfigModel {
|
||||
this.walletTypeCode = 'USDT_TRC20',
|
||||
this.predictionTypes = const PredictionTypesModel(),
|
||||
this.autoModes = const ['each_round'],
|
||||
this.instrument = defaultCandlePredictInstrument,
|
||||
});
|
||||
|
||||
final List<double> stakeAmounts;
|
||||
@ -107,6 +110,7 @@ class PredictConfigModel {
|
||||
final String walletTypeCode;
|
||||
final PredictionTypesModel predictionTypes;
|
||||
final List<String> autoModes;
|
||||
final CandlePredictInstrument instrument;
|
||||
|
||||
factory PredictConfigModel.fromJson(Map<String, dynamic> json) =>
|
||||
PredictConfigModel(
|
||||
@ -128,6 +132,9 @@ class PredictConfigModel {
|
||||
autoModes: (json['autoModes'] as List<dynamic>? ?? ['each_round'])
|
||||
.map((e) => e.toString())
|
||||
.toList(),
|
||||
instrument: CandlePredictInstrument.fromJson(
|
||||
json['instrument'] as Map<String, dynamic>?,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../core/theme/app_colors.dart';
|
||||
import '../../../../data/models/prediction_models.dart';
|
||||
import '../../../../data/models/candle_predict_instrument.dart';
|
||||
import '../../../../l10n/app_strings.dart';
|
||||
import '../../../../shared/widgets/pred_card.dart';
|
||||
import '../../../../shared/widgets/pred_text_field.dart';
|
||||
@ -165,6 +166,7 @@ class _PredictionScreenState extends State<PredictionScreen> {
|
||||
candles: state.candles,
|
||||
isLoadingOlder: state.isLoadingOlderCandles,
|
||||
hasMoreOlder: state.hasMoreOlderCandles,
|
||||
instrument: gs?.config.instrument ?? defaultCandlePredictInstrument,
|
||||
),
|
||||
if (context.watch<AuthBloc>().state.isAdmin &&
|
||||
round != null &&
|
||||
|
||||
@ -4,7 +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';
|
||||
import '../../../../data/models/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.
|
||||
@ -14,11 +14,13 @@ class CandleChartWidget extends StatefulWidget {
|
||||
required this.candles,
|
||||
this.isLoadingOlder = false,
|
||||
this.hasMoreOlder = true,
|
||||
this.instrument = defaultCandlePredictInstrument,
|
||||
});
|
||||
|
||||
final List<OhlcCandleModel> candles;
|
||||
final bool isLoadingOlder;
|
||||
final bool hasMoreOlder;
|
||||
final CandlePredictInstrument instrument;
|
||||
|
||||
static const double candleSlot = 14;
|
||||
static const double chartHeight = 240;
|
||||
@ -234,7 +236,7 @@ class _CandleChartWidgetState extends State<CandleChartWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
candlePredictInstrument.pairSymbol,
|
||||
widget.instrument.pairSymbol,
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.white.withValues(alpha: 0.92),
|
||||
@ -244,7 +246,7 @@ class _CandleChartWidgetState extends State<CandleChartWidget> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
candlePredictInstrument.displayName,
|
||||
widget.instrument.displayName,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Colors.white.withValues(alpha: 0.72),
|
||||
shadows: const [
|
||||
@ -255,7 +257,7 @@ class _CandleChartWidgetState extends State<CandleChartWidget> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Text(
|
||||
candlePredictInstrument.priceLabel(candles.last.close),
|
||||
widget.instrument.priceLabel(candles.last.close),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
fontFamily: 'monospace',
|
||||
fontWeight: FontWeight.w600,
|
||||
|
||||
@ -636,6 +636,7 @@ export function CandlePredictPage() {
|
||||
hasMoreOlder={candlesQ.hasMore}
|
||||
loadingOlder={candlesQ.loadingMore}
|
||||
onLoadOlder={() => void candlesQ.loadOlder()}
|
||||
instrument={config?.instrument}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@ -4,7 +4,7 @@ import { memo, useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { OhlcCandle } from '../types';
|
||||
import {
|
||||
getActiveInstrument,
|
||||
resolveInstrument,
|
||||
instrumentChartTitle,
|
||||
instrumentPairSymbol,
|
||||
instrumentPriceLabel,
|
||||
@ -25,6 +25,13 @@ type Props = {
|
||||
hasMoreOlder?: boolean;
|
||||
loadingOlder?: boolean;
|
||||
onLoadOlder?: () => void;
|
||||
/** Synthetic instrument branding from game config (falls back to defaults). */
|
||||
instrument?: {
|
||||
symbol?: string;
|
||||
displayName?: string;
|
||||
quoteCurrency?: string;
|
||||
priceDigits?: number;
|
||||
};
|
||||
};
|
||||
|
||||
function chartCandle(c: OhlcCandle) {
|
||||
@ -67,6 +74,7 @@ export const CandlestickChart = memo(function CandlestickChart({
|
||||
hasMoreOlder = false,
|
||||
loadingOlder = false,
|
||||
onLoadOlder,
|
||||
instrument: instrumentProp,
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
@ -84,7 +92,7 @@ export const CandlestickChart = memo(function CandlestickChart({
|
||||
hasMoreOlderRef.current = hasMoreOlder;
|
||||
loadingOlderRef.current = loadingOlder;
|
||||
|
||||
const instrument = getActiveInstrument();
|
||||
const instrument = resolveInstrument(instrumentProp);
|
||||
const lastClose = candles.length ? candles[candles.length - 1]!.close : null;
|
||||
const pairSymbol = instrumentPairSymbol(instrument);
|
||||
const chartTitle = instrumentChartTitle(instrument);
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
* 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}.
|
||||
* Runtime values are loaded from the game config API (`config.instrument`) and
|
||||
* edited under Options → Catalog → Candle. {@link DEFAULT_CANDLE_PREDICT_INSTRUMENT}
|
||||
* is only a fallback before config arrives / if fields are missing.
|
||||
*/
|
||||
|
||||
export type InstrumentType = 'SYNTHETIC';
|
||||
@ -25,11 +25,8 @@ export type SyntheticInstrumentConfig = {
|
||||
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 = {
|
||||
/** Fallback branding when API config has not loaded yet. */
|
||||
export const DEFAULT_CANDLE_PREDICT_INSTRUMENT: SyntheticInstrumentConfig = {
|
||||
id: 'fo',
|
||||
symbol: 'FO',
|
||||
displayName: 'Full Option',
|
||||
@ -38,21 +35,52 @@ export const CANDLE_PREDICT_INSTRUMENT: SyntheticInstrumentConfig = {
|
||||
priceDigits: 2,
|
||||
};
|
||||
|
||||
/** Returns the instrument currently shown on the Candle Predict chart. */
|
||||
/** @deprecated Use {@link DEFAULT_CANDLE_PREDICT_INSTRUMENT} or {@link resolveInstrument}. */
|
||||
export const CANDLE_PREDICT_INSTRUMENT = DEFAULT_CANDLE_PREDICT_INSTRUMENT;
|
||||
|
||||
type InstrumentPartial = {
|
||||
symbol?: string;
|
||||
displayName?: string;
|
||||
quoteCurrency?: string;
|
||||
priceDigits?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Merges API instrument branding onto the default synthetic instrument.
|
||||
* @param partial Instrument fields from game / admin config (optional).
|
||||
*/
|
||||
export function resolveInstrument(
|
||||
partial?: InstrumentPartial | null
|
||||
): SyntheticInstrumentConfig {
|
||||
if (!partial) return DEFAULT_CANDLE_PREDICT_INSTRUMENT;
|
||||
return {
|
||||
...DEFAULT_CANDLE_PREDICT_INSTRUMENT,
|
||||
symbol: partial.symbol?.trim() || DEFAULT_CANDLE_PREDICT_INSTRUMENT.symbol,
|
||||
displayName: partial.displayName?.trim() || DEFAULT_CANDLE_PREDICT_INSTRUMENT.displayName,
|
||||
quoteCurrency:
|
||||
partial.quoteCurrency?.trim() || DEFAULT_CANDLE_PREDICT_INSTRUMENT.quoteCurrency,
|
||||
priceDigits:
|
||||
typeof partial.priceDigits === 'number' && Number.isFinite(partial.priceDigits)
|
||||
? Math.max(0, Math.min(8, Math.trunc(partial.priceDigits)))
|
||||
: DEFAULT_CANDLE_PREDICT_INSTRUMENT.priceDigits,
|
||||
};
|
||||
}
|
||||
|
||||
/** @deprecated Prefer {@link resolveInstrument} with API config. */
|
||||
export function getActiveInstrument(): SyntheticInstrumentConfig {
|
||||
return CANDLE_PREDICT_INSTRUMENT;
|
||||
return DEFAULT_CANDLE_PREDICT_INSTRUMENT;
|
||||
}
|
||||
|
||||
/** Pair ticker shown on the chart, e.g. FO/USDT */
|
||||
export function instrumentPairSymbol(
|
||||
instrument: SyntheticInstrumentConfig = getActiveInstrument()
|
||||
instrument: SyntheticInstrumentConfig = DEFAULT_CANDLE_PREDICT_INSTRUMENT
|
||||
): string {
|
||||
return `${instrument.symbol}/${instrument.quoteCurrency}`;
|
||||
}
|
||||
|
||||
/** Header line, e.g. FO/USDT — Full Option */
|
||||
export function instrumentChartTitle(
|
||||
instrument: SyntheticInstrumentConfig = getActiveInstrument()
|
||||
instrument: SyntheticInstrumentConfig = DEFAULT_CANDLE_PREDICT_INSTRUMENT
|
||||
): string {
|
||||
return `${instrumentPairSymbol(instrument)} — ${instrument.displayName}`;
|
||||
}
|
||||
@ -60,7 +88,7 @@ export function instrumentChartTitle(
|
||||
/** Price subtitle, e.g. FO/USDT — 105.50 */
|
||||
export function instrumentPriceLabel(
|
||||
price: number,
|
||||
instrument: SyntheticInstrumentConfig = getActiveInstrument()
|
||||
instrument: SyntheticInstrumentConfig = DEFAULT_CANDLE_PREDICT_INSTRUMENT
|
||||
): string {
|
||||
return `${instrumentPairSymbol(instrument)} — ${price.toFixed(instrument.priceDigits)}`;
|
||||
}
|
||||
|
||||
@ -52,6 +52,13 @@ export type MultiCandlePrediction = {
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
export type CandlePredictInstrument = {
|
||||
symbol: string;
|
||||
displayName: string;
|
||||
quoteCurrency: string;
|
||||
priceDigits: number;
|
||||
};
|
||||
|
||||
export type CandlePredictConfig = {
|
||||
stakeAmounts: number[];
|
||||
minStakeAmount: number;
|
||||
@ -78,6 +85,8 @@ export type CandlePredictConfig = {
|
||||
autoModes: string[];
|
||||
isActive: boolean;
|
||||
predictionTypes: PredictionTypeFlags;
|
||||
/** Synthetic chart instrument branding (display-only). */
|
||||
instrument?: CandlePredictInstrument;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
|
||||
@ -49,6 +49,10 @@ export function CandlePredictConfigPanel() {
|
||||
predictionSingleEnabled: true,
|
||||
predictionAutoEnabled: true,
|
||||
predictionMultiEnabled: true,
|
||||
instrumentSymbol: 'FO',
|
||||
instrumentDisplayName: 'Full Option',
|
||||
instrumentQuoteCurrency: 'USDT',
|
||||
instrumentPriceDigits: 2,
|
||||
});
|
||||
const [feedback, setFeedback] = useState<{ severity: 'success' | 'error'; text: string } | null>(
|
||||
null
|
||||
@ -75,6 +79,12 @@ export function CandlePredictConfigPanel() {
|
||||
walletTypeCode: string;
|
||||
isActive: boolean;
|
||||
predictionTypes?: { single: boolean; auto: boolean; multiCandle: boolean };
|
||||
instrument?: {
|
||||
symbol?: string;
|
||||
displayName?: string;
|
||||
quoteCurrency?: string;
|
||||
priceDigits?: number;
|
||||
};
|
||||
};
|
||||
setForm({
|
||||
stakeAmounts: c.stakeAmounts.join(','),
|
||||
@ -97,6 +107,10 @@ export function CandlePredictConfigPanel() {
|
||||
predictionSingleEnabled: c.predictionTypes?.single ?? true,
|
||||
predictionAutoEnabled: c.predictionTypes?.auto ?? true,
|
||||
predictionMultiEnabled: c.predictionTypes?.multiCandle ?? true,
|
||||
instrumentSymbol: c.instrument?.symbol ?? 'FO',
|
||||
instrumentDisplayName: c.instrument?.displayName ?? 'Full Option',
|
||||
instrumentQuoteCurrency: c.instrument?.quoteCurrency ?? 'USDT',
|
||||
instrumentPriceDigits: c.instrument?.priceDigits ?? 2,
|
||||
});
|
||||
}
|
||||
}, [configQ.data]);
|
||||
@ -132,6 +146,12 @@ export function CandlePredictConfigPanel() {
|
||||
auto: form.predictionAutoEnabled,
|
||||
multiCandle: form.predictionMultiEnabled,
|
||||
},
|
||||
instrument: {
|
||||
symbol: form.instrumentSymbol.trim(),
|
||||
displayName: form.instrumentDisplayName.trim(),
|
||||
quoteCurrency: form.instrumentQuoteCurrency.trim(),
|
||||
priceDigits: form.instrumentPriceDigits,
|
||||
},
|
||||
});
|
||||
setFeedback({
|
||||
severity: 'success',
|
||||
@ -179,6 +199,44 @@ export function CandlePredictConfigPanel() {
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<Typography variant="subtitle1" sx={{ fontWeight: 800, gridColumn: '1 / -1', mt: 0.5 }}>
|
||||
{t('admin.catalog.candlePredict.config.instrumentTitle')}
|
||||
</Typography>
|
||||
<Typography sx={{ opacity: 0.75, gridColumn: '1 / -1', mb: 0.5 }}>
|
||||
{t('admin.catalog.candlePredict.config.instrumentIntro')}
|
||||
</Typography>
|
||||
<TextField
|
||||
label={t('admin.catalog.candlePredict.config.instrumentSymbol')}
|
||||
value={form.instrumentSymbol}
|
||||
onChange={(e) => setForm({ ...form, instrumentSymbol: e.target.value })}
|
||||
fullWidth
|
||||
helperText={t('admin.catalog.candlePredict.config.instrumentSymbolHint')}
|
||||
/>
|
||||
<TextField
|
||||
label={t('admin.catalog.candlePredict.config.instrumentDisplayName')}
|
||||
value={form.instrumentDisplayName}
|
||||
onChange={(e) => setForm({ ...form, instrumentDisplayName: e.target.value })}
|
||||
fullWidth
|
||||
/>
|
||||
<TextField
|
||||
label={t('admin.catalog.candlePredict.config.instrumentQuoteCurrency')}
|
||||
value={form.instrumentQuoteCurrency}
|
||||
onChange={(e) => setForm({ ...form, instrumentQuoteCurrency: e.target.value })}
|
||||
fullWidth
|
||||
helperText={t('admin.catalog.candlePredict.config.instrumentQuoteHint', {
|
||||
pair: `${form.instrumentSymbol.trim() || 'FO'}/${form.instrumentQuoteCurrency.trim() || 'USDT'}`,
|
||||
})}
|
||||
/>
|
||||
<TextField
|
||||
label={t('admin.catalog.candlePredict.config.instrumentPriceDigits')}
|
||||
type="number"
|
||||
slotProps={{ htmlInput: { step: 1, min: 0, max: 8 } }}
|
||||
value={form.instrumentPriceDigits}
|
||||
onChange={(e) => setForm({ ...form, instrumentPriceDigits: Number(e.target.value) })}
|
||||
fullWidth
|
||||
helperText={t('admin.catalog.candlePredict.config.instrumentPriceDigitsHint')}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label={t('admin.catalog.candlePredict.config.stakeAmounts')}
|
||||
value={form.stakeAmounts}
|
||||
|
||||
@ -1451,6 +1451,16 @@ export const en = {
|
||||
globalTitle: 'Global settings',
|
||||
globalIntro:
|
||||
'Synthetic candles are generated from player stake pools — no real market data. Interval-specific overrides are managed below; empty fields inherit these defaults.',
|
||||
instrumentTitle: 'Chart instrument',
|
||||
instrumentIntro:
|
||||
'Display-only branding for the candlestick chart. This is a synthetic Prediqo instrument — not a real market pair. Candles still come from the game engine.',
|
||||
instrumentSymbol: 'Symbol',
|
||||
instrumentSymbolHint: 'Short ticker shown on the chart (e.g. FO)',
|
||||
instrumentDisplayName: 'Full name',
|
||||
instrumentQuoteCurrency: 'Quote currency',
|
||||
instrumentQuoteHint: 'Shown as pair {{pair}} on the chart header',
|
||||
instrumentPriceDigits: 'Price decimals',
|
||||
instrumentPriceDigitsHint: 'Decimal places for the live price label (0–8)',
|
||||
stakeAmounts: 'Stake amounts (comma-separated)',
|
||||
stakeAmountsHint: 'Quick-pick buttons for players — each value must be within min/max below',
|
||||
minStake: 'Minimum stake (custom input)',
|
||||
|
||||
@ -1467,6 +1467,16 @@ export const fr = {
|
||||
globalTitle: 'Paramètres globaux',
|
||||
globalIntro:
|
||||
'Les bougies synthétiques sont générées à partir des mises des joueurs — pas de données de marché réelles. Les dérogations par intervalle se gèrent ci-dessous ; les champs vides héritent de ces valeurs par défaut.',
|
||||
instrumentTitle: 'Instrument du graphique',
|
||||
instrumentIntro:
|
||||
'Identité affichée sur le graphique en chandeliers. Instrument synthétique Prediqo — pas une paire de marché réelle. Les bougies viennent toujours du moteur de jeu.',
|
||||
instrumentSymbol: 'Symbole',
|
||||
instrumentSymbolHint: 'Ticker court affiché sur le graphique (ex. FO)',
|
||||
instrumentDisplayName: 'Nom complet',
|
||||
instrumentQuoteCurrency: 'Devise de cotation',
|
||||
instrumentQuoteHint: 'Affiché comme paire {{pair}} dans l’en-tête du graphique',
|
||||
instrumentPriceDigits: 'Décimales du prix',
|
||||
instrumentPriceDigitsHint: 'Nombre de décimales pour le prix live (0–8)',
|
||||
stakeAmounts: 'Montants de mise (séparés par des virgules)',
|
||||
stakeAmountsHint: 'Boutons rapides pour les joueurs — chaque valeur doit être entre min et max ci-dessous',
|
||||
minStake: 'Mise minimale (saisie libre)',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user