/** * Analysis page */ "use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { AnalysisForm } from "@/components/analysis/AnalysisForm"; import { TradingDecision } from "@/components/analysis/TradingDecision"; import { AnalystReport } from "@/components/analysis/AnalystReport"; import { PriceChart } from "@/components/analysis/PriceChart"; import { LoadingSpinner } from "@/components/shared/LoadingSpinner"; import { Button } from "@/components/ui/button"; import { useAnalysis } from "@/hooks/useAnalysis"; import { useAnalysisContext } from "@/context/AnalysisContext"; import type { AnalysisRequest } from "@/lib/types"; export default function AnalysisPage() { const router = useRouter(); const { setAnalysisResult } = useAnalysisContext(); const { runAnalysis, loading, error, result } = useAnalysis(); const handleSubmit = async (request: AnalysisRequest) => { try { await runAnalysis(request); } catch (err) { // Error is handled by the hook console.error("Analysis failed:", err); } }; const handleViewResults = () => { if (result) { setAnalysisResult(result); router.push("/analysis/results"); } }; return (

交易分析

配置並執行全面的多代理交易分析

{loading && ( )} {error && (

錯誤

{error}

)} {result && !loading && (
{/* 查看詳細結果按鈕 */}
{/* 價格圖表 */} {result.price_data && result.price_stats && ( )} {/* 交易決策 */} {/* 分析報告 */} {result.reports && }
)}
); }