Files
2026FIFAWorldCup/platform/web/app/rlm/page.tsx
QuantBot aa7e3bba76
Some checks failed
2026 World Cup Quant Platform - Production Deployment / Code Quality & Testing (push) Failing after 1m49s
2026 World Cup Quant Platform - Production Deployment / Deploy to Production VM via Rsync (push) Has been skipped
chore: migrate deployment to Gitea Actions with zero-trust rsync
2026-06-16 19:06:50 +08:00

129 lines
4.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import { useState } from 'react';
import { detectReverseLineMovement, type RlmResponse, type RlmRequestPayload } from '@/lib/analytics-api';
import { RLMRadarBoard } from '@/components/RLMRadarBoard';
export default function RlmPage() {
const [matchId, setMatchId] = useState('MATCH-RLM-2026-01');
const [marketType, setMarketType] = useState('1x2');
const [selection, setSelection] = useState('home');
const [ticketThreshold, setTicketThreshold] = useState(80);
const [oddsChangeThreshold, setOddsChangeThreshold] = useState(0.05);
const [loading, setLoading] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [result, setResult] = useState<RlmResponse | null>(null);
async function runRlm() {
setLoading(true);
setErrorMessage('');
try {
const payload: RlmRequestPayload = {
match_id: matchId,
market_type: marketType,
selection,
ticket_threshold: ticketThreshold,
odds_change_threshold: oddsChangeThreshold,
};
const data = await detectReverseLineMovement(payload);
setResult(data);
} catch (error) {
setErrorMessage(error instanceof Error ? error.message : '反向盤口偵測暫時無法使用');
setResult(null);
} finally {
setLoading(false);
}
}
return (
<div className="space-y-4">
<h2 className="dot-matrix text-2xl text-[#7d2a15]"></h2>
<section className="panel-glow rounded-2xl border-dashed p-4">
<p className="text-sm leading-6 text-[#7a5b46]">
</p>
</section>
<section className="panel-glow rounded-2xl p-4">
<h3 className="dot-matrix text-lg text-[#7d2a15]"></h3>
<div className="mt-3 grid gap-3 md:grid-cols-2 lg:grid-cols-4">
<label className="text-sm text-[#7a5b46]">
ID
<input
className="mt-2 w-full rounded-lg border border-[#e0c6a8] bg-white/70 px-3 py-2"
value={matchId}
onChange={(event) => setMatchId(event.target.value)}
/>
</label>
<label className="text-sm text-[#7a5b46]">
<input
className="mt-2 w-full rounded-lg border border-[#e0c6a8] bg-white/70 px-3 py-2"
value={marketType}
onChange={(event) => setMarketType(event.target.value)}
/>
</label>
<label className="text-sm text-[#7a5b46]">
<input
className="mt-2 w-full rounded-lg border border-[#e0c6a8] bg-white/70 px-3 py-2"
value={selection}
onChange={(event) => setSelection(event.target.value)}
/>
</label>
<label className="text-sm text-[#7a5b46]">
%
<input
className="mt-2 w-full rounded-lg border border-[#e0c6a8] bg-white/70 px-3 py-2"
type="number"
value={ticketThreshold}
onChange={(event) => setTicketThreshold(Number(event.target.value))}
/>
</label>
<label className="text-sm text-[#7a5b46]">
<input
className="mt-2 w-full rounded-lg border border-[#e0c6a8] bg-white/70 px-3 py-2"
type="number"
step={0.01}
value={oddsChangeThreshold}
onChange={(event) => setOddsChangeThreshold(Number(event.target.value))}
/>
</label>
</div>
<div className="mt-4">
<button
className="rounded-lg bg-[#7d2a15] px-4 py-2 text-white"
type="button"
onClick={runRlm}
disabled={loading}
>
{loading ? '偵測中…' : '執行反向盤口偵測'}
</button>
</div>
{errorMessage ? <p className="mt-3 text-xs text-[#8c2f2f]">{errorMessage}</p> : null}
</section>
<RLMRadarBoard
alerts={(result?.alerts || []).map((a) => ({
matchName: a.match_id,
market: a.market_type,
selection: a.selection,
ticketPct: a.ticket_pct,
handlePct: a.handle_pct,
openingOdds: a.opening_odds,
currentOdds: a.current_odds,
}))}
/>
<section className="panel-glow rounded-2xl p-4">
<p className="text-sm text-[#7a5b46]">
{result?.total ?? 0}
{' '}
| {result?.alerts ? result.alerts.filter((item) => item.is_triggered).length : 0}
</p>
</section>
</div>
);
}