some changes

This commit is contained in:
eduard committed 2025-12-12 14:47:36 +01:00
commit 3568453103
45 files changed
+4557

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
node_modules
dist
+16
View File
@@ -0,0 +1,16 @@
# Build stage
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
+16
View File
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Stock Sentiment Analyzer</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+20
View File
@@ -0,0 +1,20 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://192.168.178.42:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 300;
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "stock-analyzer-frontend",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.6.7",
"chart.js": "^4.4.1",
"pinia": "^2.1.7",
"vue": "^3.4.21",
"vue-chartjs": "^5.3.0",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@types/node": "^24.10.1",
"@vitejs/plugin-vue": "^5.0.4",
"typescript": "~5.2.2",
"vite": "^5.1.6",
"vue-tsc": "^1.8.27"
}
}
+91
View File
@@ -0,0 +1,91 @@
<script setup lang="ts">
import { RouterView } from 'vue-router'
</script>
<template>
<div class="app-container">
<header class="app-header">
<div class="header-content">
<h1 class="app-title">
<span class="icon">📈</span>
Stock Sentiment Analyzer
</h1>
<!-- Navigation removed as we merged Dashboard into History -->
</div>
</header>
<main class="app-main">
<RouterView />
</main>
</div>
</template>
<style scoped>
.app-container {
min-height: 100vh;
background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}
.app-header {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
position: sticky;
top: 0;
z-index: 100;
}
.header-content {
max-width: 1400px;
margin: 0 auto;
padding: 1.5rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.app-title {
font-size: 1.5rem;
font-weight: 700;
color: #fff;
margin: 0;
display: flex;
align-items: center;
gap: 0.5rem;
}
.icon {
font-size: 1.8rem;
}
.app-nav {
display: flex;
gap: 1rem;
}
.nav-link {
padding: 0.5rem 1.5rem;
border-radius: 8px;
color: rgba(255, 255, 255, 0.7);
text-decoration: none;
font-weight: 500;
transition: all 0.3s ease;
position: relative;
}
.nav-link:hover {
color: #fff;
background: rgba(255, 255, 255, 0.1);
}
.nav-link.router-link-active {
color: #fff;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.app-main {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
</style>
+307
View File
@@ -0,0 +1,307 @@
<script setup lang="ts">
import { ref } from 'vue'
import type { AnalysisResult } from '../store'
defineProps<{
result: AnalysisResult
}>()
const expanded = ref(false)
</script>
<template>
<div class="analysis-card glass-card">
<!-- Header -->
<div class="card-header" @click="expanded = !expanded">
<div class="stock-header">
<h3 class="stock-symbol">{{ result.symbol }}</h3>
<p class="stock-isin">{{ result.isin }}</p>
</div>
<div class="predictions">
<span class="badge badge-info">
OpenAI: {{ result.llmAnalysisOpenai?.prediction || 'N/A' }}
</span>
<span class="badge badge-warning">
Anthropic: {{ result.llmAnalysisAnthropic?.prediction || 'N/A' }}
</span>
</div>
<button class="expand-btn">
{{ expanded ? '▼' : '▶' }}
</button>
</div>
<!-- Expanded Content -->
<div v-if="expanded" class="card-content">
<!-- Price Metrics -->
<div class="metrics-grid grid grid-cols-2 mb-3">
<div class="metric-card">
<div class="metric-label">Current Price</div>
<div class="metric-value">
{{ result.price !== null && result.price !== undefined ? '$' + result.price.toFixed(2) : 'N/A' }}
</div>
</div>
<div class="metric-card">
<div class="metric-label">24h Change</div>
<div
v-if="result.changePercent !== null && result.changePercent !== undefined"
class="metric-value"
:style="{ color: result.changePercent >= 0 ? '#4ade80' : '#f87171' }"
>
{{ result.changePercent >= 0 ? '▲' : '▼' }}
{{ Math.abs(result.changePercent).toFixed(2) }}%
</div>
<div v-else class="metric-value text-muted">N/A</div>
</div>
</div>
<!-- Fundamentals & Technicals -->
<div class="section mb-3">
<h4 class="section-title">Fundamentals & Technicals</h4>
<div class="grid grid-cols-4 gap-2">
<div class="metric-card">
<div class="metric-label">P/E Ratio</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.fundamentals?.peRatio || 'N/A' }}
</div>
</div>
<div class="metric-card">
<div class="metric-label">Market Cap</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.fundamentals?.marketCap && result.fundamentals.marketCap !== 'N/A' && !isNaN(Number(result.fundamentals.marketCap))
? '$' + (Number(result.fundamentals.marketCap) / 1e9).toFixed(2) + 'B'
: 'N/A' }}
</div>
</div>
<div class="metric-card">
<div class="metric-label">RSI (14)</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.technicals?.rsi && result.technicals.rsi !== 'N/A' && !isNaN(Number(result.technicals.rsi))
? Number(result.technicals.rsi).toFixed(2)
: 'N/A' }}
</div>
</div>
<div class="metric-card">
<div class="metric-label">SMA (20)</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.technicals?.sma20 && result.technicals.sma20 !== 'N/A' && !isNaN(Number(result.technicals.sma20))
? '$' + Number(result.technicals.sma20).toFixed(2)
: 'N/A' }}
</div>
</div>
</div>
<div class="grid grid-cols-2 gap-2 mt-2">
<div class="metric-card">
<div class="metric-label">Analyst Rating</div>
<div class="metric-value" style="font-size: 1rem; text-transform: uppercase;">
{{ result.fundamentals?.recommendationKey || 'N/A' }}
</div>
</div>
<div class="metric-card">
<div class="metric-label">Target Price</div>
<div class="metric-value" style="font-size: 1rem;">
{{ result.fundamentals?.targetMeanPrice && result.fundamentals.targetMeanPrice !== 'N/A' && !isNaN(Number(result.fundamentals.targetMeanPrice))
? '$' + Number(result.fundamentals.targetMeanPrice).toFixed(2)
: 'N/A' }}
</div>
</div>
</div>
</div>
<!-- AI Analysis -->
<div class="section mb-3">
<h4 class="section-title">AI Analysis</h4>
<!-- OpenAI -->
<div class="analysis-box mb-2">
<div class="analysis-header">
<span class="badge badge-info">OpenAI (GPT-4o)</span>
</div>
<div class="analysis-content" v-if="result.llmAnalysisOpenai">
<div class="flex gap-2 mb-2">
<div class="metric-card" style="flex: 1;">
<div class="metric-label">Prediction</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.llmAnalysisOpenai.prediction }}
</div>
</div>
<div class="metric-card" style="flex: 1;">
<div class="metric-label">Probability</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.llmAnalysisOpenai.probability }}%
</div>
</div>
</div>
<div class="reasoning">
<strong>Reasoning:</strong> {{ result.llmAnalysisOpenai.reasoning }}
</div>
</div>
<div class="analysis-content" v-else>
<div class="text-muted">Analysis not available</div>
</div>
</div>
<!-- Anthropic -->
<div class="analysis-box">
<div class="analysis-header">
<span class="badge badge-warning">Anthropic (Claude Sonnet 4.5)</span>
</div>
<div class="analysis-content" v-if="result.llmAnalysisAnthropic">
<div class="flex gap-2 mb-2">
<div class="metric-card" style="flex: 1;">
<div class="metric-label">Prediction</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.llmAnalysisAnthropic.prediction }}
</div>
</div>
<div class="metric-card" style="flex: 1;">
<div class="metric-label">Probability</div>
<div class="metric-value" style="font-size: 1.1rem;">
{{ result.llmAnalysisAnthropic.probability }}%
</div>
</div>
</div>
<div class="reasoning">
<strong>Reasoning:</strong> {{ result.llmAnalysisAnthropic.reasoning }}
</div>
</div>
<div class="analysis-content" v-else>
<div class="text-muted">Analysis not available</div>
</div>
</div>
</div>
<!-- News & Sentiment -->
<div class="section">
<h4 class="section-title">News & Sentiment</h4>
<div class="mb-2">
<h5 class="subsection-title">Recent Headlines</h5>
<ul class="news-list">
<li v-for="(headline, index) in result.newsHeadlines.slice(0, 3)" :key="index">
{{ headline }}
</li>
</ul>
</div>
<div>
<h5 class="subsection-title">Web Sentiment</h5>
<ul class="news-list">
<li v-for="(post, index) in result.socialPosts.slice(0, 3)" :key="index">
{{ post.substring(0, 200) }}...
</li>
</ul>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.analysis-card {
cursor: pointer;
transition: all var(--transition-base);
}
.card-header {
display: flex;
align-items: center;
gap: 1rem;
}
.stock-header {
flex: 1;
}
.stock-symbol {
color: var(--text-primary);
font-size: 1.25rem;
margin: 0;
}
.stock-isin {
color: var(--text-muted);
font-size: 0.875rem;
margin: 0.25rem 0 0 0;
}
.predictions {
display: flex;
gap: 0.5rem;
}
.expand-btn {
background: none;
border: none;
color: var(--text-secondary);
font-size: 1.2rem;
cursor: pointer;
padding: 0.5rem;
transition: transform var(--transition-base);
}
.card-content {
margin-top: 1.5rem;
padding-top: 1.5rem;
border-top: 1px solid var(--glass-border);
}
.section {
padding: 1rem;
background: rgba(255, 255, 255, 0.02);
border-radius: var(--radius-md);
}
.section-title {
color: var(--text-primary);
font-size: 1.1rem;
margin-bottom: 1rem;
}
.subsection-title {
color: var(--text-secondary);
font-size: 0.95rem;
margin-bottom: 0.5rem;
}
.metrics-grid {
gap: 1rem;
}
.analysis-box {
background: rgba(255, 255, 255, 0.03);
border-radius: var(--radius-md);
padding: 1rem;
}
.analysis-header {
margin-bottom: 1rem;
}
.analysis-content {
color: var(--text-secondary);
}
.reasoning {
color: var(--text-secondary);
line-height: 1.6;
font-size: 0.9rem;
}
.news-list {
list-style: none;
padding: 0;
}
.news-list li {
color: var(--text-secondary);
font-size: 0.875rem;
padding: 0.5rem 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
line-height: 1.5;
}
.news-list li:last-child {
border-bottom: none;
}
</style>
@@ -0,0 +1,228 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useStockStore } from '../store'
const store = useStockStore()
const newIsin = ref('')
const adding = ref(false)
onMounted(async () => {
await store.fetchWatchlist()
})
async function handleAdd() {
if (!newIsin.value.trim()) {
return
}
adding.value = true
try {
await store.addToWatchlist(newIsin.value.trim().toUpperCase())
newIsin.value = ''
} catch (error: any) {
alert('Error adding stock: ' + (error.response?.data?.error || error.message))
} finally {
adding.value = false
}
}
async function handleRemove(isin: string) {
if (!confirm(`Remove ${isin} from watchlist?`)) {
return
}
try {
await store.removeFromWatchlist(isin)
} catch (error: any) {
alert('Error removing stock: ' + error.message)
}
}
</script>
<template>
<div class="sidebar glass-card">
<h2 class="sidebar-title">Watchlist</h2>
<!-- Add ISIN Form -->
<div class="add-form">
<input
v-model="newIsin"
type="text"
placeholder="Enter ISIN (e.g., US0378331005)"
class="input"
@keyup.enter="handleAdd"
:disabled="adding"
/>
<button
@click="handleAdd"
:disabled="adding || !newIsin.trim()"
class="btn btn-primary btn-sm"
style="width: 100%; margin-top: 0.5rem;"
>
{{ adding ? 'Adding...' : '➕ Add Stock' }}
</button>
</div>
<!-- Watchlist Items -->
<div class="watchlist-section">
<div class="watchlist-header">
<span class="text-secondary">Stocks ({{ store.watchlist.length }})</span>
</div>
<div v-if="store.watchlist.length === 0" class="empty-state">
<p class="text-muted" style="font-size: 0.875rem;">No stocks in watchlist</p>
</div>
<div v-else class="watchlist-items">
<div
v-for="stock in store.watchlist"
:key="stock.isin"
class="watchlist-item"
>
<div class="stock-info">
<div class="stock-name">{{ stock.name || stock.symbol }}</div>
<div class="stock-isin">{{ stock.isin }}</div>
</div>
<button
@click="handleRemove(stock.isin)"
class="btn-remove"
title="Remove from watchlist"
>
❌
</button>
</div>
</div>
</div>
<!-- API Status -->
<div class="api-status">
<div class="status-header text-secondary">API Status</div>
<div class="status-items">
<div class="status-item">
<span>✅ OpenAI</span>
</div>
<div class="status-item">
<span>✅ Anthropic</span>
</div>
<div class="status-item">
<span>✅ NewsAPI</span>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.sidebar {
position: sticky;
top: 100px;
padding: 1.5rem;
max-height: calc(100vh - 120px);
overflow-y: auto;
}
.sidebar-title {
color: var(--text-primary);
margin-bottom: 1.5rem;
font-size: 1.25rem;
}
.add-form {
margin-bottom: 1.5rem;
padding-bottom: 1.5rem;
border-bottom: 1px solid var(--glass-border);
}
.watchlist-section {
margin-bottom: 1.5rem;
padding-bottom: 1.5rem;
border-bottom: 1px solid var(--glass-border);
}
.watchlist-header {
margin-bottom: 1rem;
font-weight: 600;
}
.empty-state {
text-align: center;
padding: 1rem;
}
.watchlist-items {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.watchlist-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem;
background: rgba(255, 255, 255, 0.03);
border-radius: var(--radius-md);
border: 1px solid rgba(255, 255, 255, 0.05);
transition: all var(--transition-base);
}
.watchlist-item:hover {
background: rgba(255, 255, 255, 0.05);
border-color: rgba(255, 255, 255, 0.1);
}
.stock-info {
flex: 1;
min-width: 0;
}
.stock-name {
color: var(--text-primary);
font-weight: 600;
font-size: 0.9rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.stock-isin {
color: var(--text-muted);
font-size: 0.75rem;
margin-top: 0.125rem;
}
.btn-remove {
background: none;
border: none;
cursor: pointer;
font-size: 1rem;
opacity: 0.6;
transition: opacity var(--transition-fast);
padding: 0.25rem;
}
.btn-remove:hover {
opacity: 1;
}
.api-status {
padding-top: 1rem;
}
.status-header {
font-weight: 600;
margin-bottom: 0.75rem;
font-size: 0.875rem;
}
.status-items {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.status-item {
font-size: 0.875rem;
color: var(--text-secondary);
}
</style>
+12
View File
@@ -0,0 +1,12 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import router from './router/index'
import App from './App.vue'
import './style.css'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.mount('#app')
+15
View File
@@ -0,0 +1,15 @@
import { createRouter, createWebHistory } from 'vue-router'
import History from '../views/History.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'history',
component: History
}
]
})
export default router
+278
View File
@@ -0,0 +1,278 @@
import { defineStore } from 'pinia'
import axios from 'axios'
import { ref } from 'vue'
export interface Stock {
isin: string
symbol: string | null
name: string | null
addedAt: string
}
export interface LLMAnalysis {
prediction: string
probability: number
reasoning: string
error?: string
}
export interface Fundamentals {
peRatio: string
marketCap: string
high52w: string
low52w: string
targetMeanPrice: string
recommendationKey: string
}
export interface Technicals {
sma20: string
rsi: string
}
export interface MarketContext {
symbol: string
changePercent: number
price: number
}
export interface AnalysisResult {
id?: string
isin: string
symbol: string
price: number
realPrice?: number
changePercent: number
fundamentals: Fundamentals
technicals: Technicals
marketContext: MarketContext | null
newsHeadlines: string[]
socialPosts: string[]
llmAnalysisOpenai: LLMAnalysis
llmAnalysisAnthropic: LLMAnalysis
analyzedAt: string
date: string
targetDate: string
}
export interface AnalysisJob {
id: string
isin: string
symbol: string
status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'CANCELLED'
error?: string
createdAt: string
startedAt?: string
completedAt?: string
}
export const useStockStore = defineStore('stock', () => {
const watchlist = ref<Stock[]>([])
const analysisResults = ref<AnalysisResult[]>([])
const analysisJobs = ref<AnalysisJob[]>([])
const marketContext = ref<MarketContext | null>(null)
const loading = ref(false)
const error = ref<string | null>(null)
const apiClient = axios.create({
baseURL: '/api'
})
async function fetchWatchlist() {
try {
const response = await apiClient.get<Stock[]>('/watchlist')
watchlist.value = response.data
} catch (e: any) {
error.value = e.message
throw e
}
}
async function addToWatchlist(isin: string) {
try {
loading.value = true
await apiClient.post('/watchlist', { isin })
await fetchWatchlist()
} catch (e: any) {
error.value = e.response?.data?.error || e.message
throw e
} finally {
loading.value = false
}
}
async function removeFromWatchlist(isin: string) {
try {
await apiClient.delete(`/watchlist/${isin}`)
await fetchWatchlist()
} catch (e: any) {
error.value = e.message
throw e
}
}
async function startAnalysis(isin?: string) {
try {
loading.value = true
error.value = null
const url = isin ? `/analysis/run/${isin}` : '/analysis/run'
// This now returns a list of created jobs
const response = await apiClient.post<AnalysisJob[]>(url)
analysisJobs.value = response.data
// Start polling
pollJobs()
return response.data
} catch (e: any) {
error.value = e.message
loading.value = false // Stop loading if start failed
throw e
}
}
async function stopAnalysis() {
try {
await apiClient.post('/analysis/stop')
await fetchJobs() // Refresh status immediately
} catch (e: any) {
error.value = e.message
throw e
}
}
async function fetchJobs() {
try {
const response = await apiClient.get<AnalysisJob[]>('/analysis/jobs')
analysisJobs.value = response.data
// If there are active jobs, set loading to true and start polling
const hasActiveJobs = analysisJobs.value.some(job =>
job.status === 'PENDING' || job.status === 'PROCESSING'
)
if (hasActiveJobs) {
loading.value = true
pollJobs()
}
} catch (e) {
console.error("Failed to fetch jobs", e)
}
}
let pollingInterval: any = null
async function pollJobs() {
if (pollingInterval) return // Already polling
pollingInterval = setInterval(async () => {
try {
const response = await apiClient.get<AnalysisJob[]>('/analysis/jobs')
analysisJobs.value = response.data
// Check if all jobs are done (COMPLETED or FAILED)
const hasActiveJobs = analysisJobs.value.some(job =>
job.status === 'PENDING' || job.status === 'PROCESSING'
)
if (!hasActiveJobs) {
clearInterval(pollingInterval)
pollingInterval = null
loading.value = false
// Fetch latest results to show them
const latestResults = await fetchHistory()
analysisResults.value = latestResults.filter(r =>
analysisJobs.value.some(j => j.isin === r.isin && j.status === 'COMPLETED')
)
}
} catch (e) {
console.error("Polling failed", e)
}
}, 2000)
}
async function fetchMarketContext() {
try {
const response = await apiClient.get<MarketContext & { error?: string }>('/analysis/market-context')
if (!response.data.error) {
marketContext.value = response.data as MarketContext
}
} catch (e: any) {
console.error('Failed to fetch market context:', e)
}
}
async function fetchHistory() {
try {
const response = await apiClient.get<AnalysisResult[]>('/analysis/history')
return response.data
} catch (e: any) {
error.value = e.message
throw e
}
}
async function fetchHistoryByIsin(isin: string) {
try {
const response = await apiClient.get<AnalysisResult[]>(`/analysis/history/${isin}`)
return response.data
} catch (e: any) {
error.value = e.message
throw e
}
}
async function deleteHistoryByDateRange(startDate: string, endDate: string) {
try {
const response = await apiClient.delete('/analysis/history', {
data: { startDate, endDate }
})
return response.data
} catch (e: any) {
error.value = e.message
throw e
}
}
async function getHistoricalPrice(symbol: string, date: string) {
try {
const response = await apiClient.get(`/analysis/historical-price/${symbol}/${date}`)
return response.data.price || null
} catch (e: any) {
return null
}
}
async function refreshRealPrice(id: string) {
try {
const response = await apiClient.post<AnalysisResult>(`/analysis/history/${id}/refresh-price`)
return response.data
} catch (e: any) {
throw e
}
}
return {
watchlist,
analysisResults,
analysisJobs,
marketContext,
loading,
error,
fetchWatchlist,
addToWatchlist,
removeFromWatchlist,
startAnalysis,
stopAnalysis,
fetchJobs,
fetchMarketContext,
fetchHistory,
fetchHistoryByIsin,
deleteHistoryByDateRange,
getHistoricalPrice,
refreshRealPrice
}
})
+394
View File
@@ -0,0 +1,394 @@
:root {
/* Color Palette */
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
--success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
--danger-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
--bg-primary: #0f0c29;
--bg-secondary: #302b63;
--bg-tertiary: #24243e;
--text-primary: #ffffff;
--text-secondary: rgba(255, 255, 255, 0.7);
--text-muted: rgba(255, 255, 255, 0.5);
--glass-bg: rgba(255, 255, 255, 0.05);
--glass-border: rgba(255, 255, 255, 0.1);
/* Spacing */
--spacing-xs: 0.25rem;
--spacing-sm: 0.5rem;
--spacing-md: 1rem;
--spacing-lg: 1.5rem;
--spacing-xl: 2rem;
/* Border Radius */
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--radius-xl: 16px;
/* Shadows */
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
/* Transitions */
--transition-fast: 0.15s ease;
--transition-base: 0.3s ease;
--transition-slow: 0.5s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
color: var(--text-primary);
background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
min-height: 100vh;
line-height: 1.6;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* Glass Card */
.glass-card {
background: var(--glass-bg);
backdrop-filter: blur(10px);
border: 1px solid var(--glass-border);
border-radius: var(--radius-lg);
padding: var(--spacing-lg);
box-shadow: var(--shadow-md);
transition: all var(--transition-base);
}
.glass-card:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-lg);
border-color: rgba(255, 255, 255, 0.2);
}
/* Buttons */
.btn {
padding: 0.75rem 1.5rem;
border: none;
border-radius: var(--radius-md);
font-weight: 600;
font-size: 0.95rem;
cursor: pointer;
transition: all var(--transition-base);
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.btn-primary {
background: var(--primary-gradient);
color: white;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-secondary {
background: var(--glass-bg);
color: var(--text-primary);
border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.2);
}
.btn-danger {
background: var(--danger-gradient);
color: white;
box-shadow: 0 4px 15px rgba(250, 112, 154, 0.4);
}
.btn-danger:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(250, 112, 154, 0.6);
}
.btn-sm {
padding: 0.5rem 1rem;
font-size: 0.875rem;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none !important;
}
/* Input Fields */
.input {
width: 100%;
padding: 0.75rem 1rem;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
border-radius: var(--radius-md);
color: var(--text-primary);
font-size: 0.95rem;
transition: all var(--transition-base);
}
.input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.input::placeholder {
color: var(--text-muted);
}
/* Metrics */
.metric-card {
background: var(--glass-bg);
backdrop-filter: blur(10px);
border: 1px solid var(--glass-border);
border-radius: var(--radius-md);
padding: var(--spacing-md);
text-align: center;
}
.metric-label {
font-size: 0.875rem;
color: var(--text-secondary);
margin-bottom: 0.5rem;
}
.metric-value {
font-size: 1.5rem;
font-weight: 700;
color: var(--text-primary);
}
.metric-change {
font-size: 0.875rem;
margin-top: 0.25rem;
}
.metric-change.positive {
color: #4ade80;
}
.metric-change.negative {
color: #f87171;
}
/* Tables */
.table-container {
overflow-x: auto;
border-radius: var(--radius-lg);
background: var(--glass-bg);
backdrop-filter: blur(10px);
border: 1px solid var(--glass-border);
}
table {
width: 100%;
border-collapse: collapse;
}
thead {
background: rgba(255, 255, 255, 0.05);
}
th {
padding: 1rem;
text-align: left;
font-weight: 600;
color: var(--text-primary);
border-bottom: 1px solid var(--glass-border);
}
td {
padding: 1rem;
color: var(--text-secondary);
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
tbody tr {
transition: background var(--transition-fast);
}
tbody tr:hover {
background: rgba(255, 255, 255, 0.03);
}
/* Badges */
.badge {
display: inline-block;
padding: 0.25rem 0.75rem;
border-radius: var(--radius-sm);
font-size: 0.875rem;
font-weight: 600;
}
.badge-success {
background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
color: white;
}
.badge-danger {
background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
color: white;
}
.badge-warning {
background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
color: white;
}
.badge-info {
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
color: white;
}
/* Loading Spinner */
.spinner {
border: 3px solid var(--glass-border);
border-top: 3px solid #667eea;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Progress Bar */
.progress-bar {
width: 100%;
height: 8px;
background: var(--glass-bg);
border-radius: var(--radius-sm);
overflow: hidden;
}
.progress-fill {
height: 100%;
background: var(--primary-gradient);
transition: width var(--transition-base);
animation: shimmer 2s infinite;
}
@keyframes shimmer {
0% { opacity: 0.6; }
50% { opacity: 1; }
100% { opacity: 0.6; }
}
/* Alerts */
.alert {
padding: 1rem 1.5rem;
border-radius: var(--radius-md);
margin-bottom: var(--spacing-md);
display: flex;
align-items: center;
gap: 0.75rem;
}
.alert-info {
background: rgba(59, 130, 246, 0.1);
border: 1px solid rgba(59, 130, 246, 0.3);
color: #60a5fa;
}
.alert-success {
background: rgba(34, 197, 94, 0.1);
border: 1px solid rgba(34, 197, 94, 0.3);
color: #4ade80;
}
.alert-warning {
background: rgba(245, 158, 11, 0.1);
border: 1px solid rgba(245, 158, 11, 0.3);
color: #fbbf24;
}
.alert-error {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.3);
color: #f87171;
}
/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }
/* Responsive Grid */
.grid {
display: grid;
gap: var(--spacing-lg);
}
.grid-cols-2 {
grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1024px) {
.grid-cols-4 {
grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 640px) {
.grid-cols-4,
.grid-cols-3,
.grid-cols-2 {
grid-template-columns: 1fr;
}
}
+231
View File
@@ -0,0 +1,231 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { useStockStore } from '../store'
import WatchlistSidebar from '../components/WatchlistSidebar.vue'
import AnalysisCard from '../components/AnalysisCard.vue'
const store = useStockStore()
const analyzing = ref(false)
const recentJobs = computed(() => {
const jobsByIsin = new Map();
// Sort by creation time to ensure we process in order
const sortedJobs = [...store.analysisJobs].sort((a, b) =>
new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()
);
for (const job of sortedJobs) {
jobsByIsin.set(job.isin, job);
}
return Array.from(jobsByIsin.values());
});
onMounted(async () => {
await store.fetchWatchlist()
await store.fetchMarketContext()
await store.fetchJobs()
})
async function handleAnalyze() {
if (store.watchlist.length === 0) {
alert('Please add stocks to your watchlist first.')
return
}
analyzing.value = true
try {
await store.startAnalysis()
} catch (error: any) {
alert('Error starting analysis: ' + error.message)
analyzing.value = false
}
}
async function handleStop() {
if (!confirm('Are you sure you want to stop pending analyses?')) {
return
}
try {
await store.stopAnalysis()
} catch (error: any) {
alert('Error stopping analysis: ' + error.message)
}
}
</script>
<template>
<div class="dashboard">
<WatchlistSidebar />
<div class="main-content">
<!-- Market Context -->
<div v-if="store.marketContext" class="glass-card mb-3">
<div class="flex items-center justify-between">
<div>
<h3 class="text-secondary">Market Context</h3>
<p class="text-muted" style="font-size: 0.875rem;">S&P 500 Performance</p>
</div>
<div class="text-right">
<div class="metric-value">${{ store.marketContext.price.toFixed(2) }}</div>
<div
class="metric-change"
:class="store.marketContext.changePercent >= 0 ? 'positive' : 'negative'"
>
{{ store.marketContext.changePercent >= 0 ? '▲' : '▼' }}
{{ Math.abs(store.marketContext.changePercent).toFixed(2) }}%
</div>
</div>
</div>
</div>
<!-- Analyze Button -->
<div class="analyze-section mb-3">
<div class="flex gap-2">
<button
@click="handleAnalyze"
:disabled="store.loading || store.watchlist.length === 0"
class="btn btn-primary"
style="flex: 1;"
>
<span v-if="!store.loading">🔍 Analyze Watchlist</span>
<span v-else>
<div class="spinner" style="width: 20px; height: 20px; border-width: 2px;"></div>
Analyzing...
</span>
</button>
<button
v-if="store.loading"
@click="handleStop"
class="btn btn-danger"
style="width: auto;"
title="Stop Analysis"
>
⏹️ Stop
</button>
</div>
<!-- Job Status -->
<div v-if="store.loading && recentJobs.length > 0" class="mt-3">
<h4 class="mb-2" style="color: var(--text-secondary);">Analysis Progress</h4>
<div class="glass-card p-2">
<div v-for="job in recentJobs" :key="job.id" class="flex justify-between items-center mb-1 last:mb-0">
<span>{{ job.symbol }}</span>
<div>
<span v-if="job.status === 'PENDING'" class="badge badge-secondary">Pending</span>
<span v-if="job.status === 'PROCESSING'" class="badge badge-info">Processing...</span>
<span v-if="job.status === 'COMPLETED'" class="badge badge-success">Done</span>
<span v-if="job.status === 'FAILED'" class="badge badge-danger">Failed</span>
<span v-if="job.status === 'CANCELLED'" class="badge badge-warning">Cancelled</span>
</div>
</div>
</div>
</div>
</div>
<!-- Results Summary -->
<div v-if="store.analysisResults.length > 0">
<h2 class="mb-2" style="color: var(--text-primary);">Analysis Results</h2>
<div class="table-container mb-3">
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Price</th>
<th>Change</th>
<th>OpenAI</th>
<th>Anthropic</th>
</tr>
</thead>
<tbody>
<tr v-for="result in store.analysisResults" :key="result.isin">
<td>
<strong style="color: var(--text-primary);">{{ result.symbol }}</strong>
<br>
<span class="text-muted" style="font-size: 0.75rem;">{{ result.isin }}</span>
</td>
<td>
<span v-if="result.price !== null && result.price !== undefined">${{ result.price.toFixed(2) }}</span>
<span v-else class="text-muted">N/A</span>
</td>
<td>
<span
v-if="result.changePercent !== null && result.changePercent !== undefined"
:class="result.changePercent >= 0 ? 'badge-success' : 'badge-danger'"
class="badge"
>
{{ result.changePercent >= 0 ? '▲' : '▼' }}
{{ Math.abs(result.changePercent).toFixed(2) }}%
</span>
<span v-else class="text-muted">N/A</span>
</td>
<td>
<span v-if="result.llmAnalysisOpenai" class="badge badge-info">
{{ result.llmAnalysisOpenai.prediction }}
({{ result.llmAnalysisOpenai.probability }}%)
</span>
<span v-else class="text-muted">N/A</span>
</td>
<td>
<span v-if="result.llmAnalysisAnthropic" class="badge badge-warning">
{{ result.llmAnalysisAnthropic.prediction }}
({{ result.llmAnalysisAnthropic.probability }}%)
</span>
<span v-else class="text-muted">N/A</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Detailed Analysis Cards -->
<h2 class="mb-2" style="color: var(--text-primary);">Detailed Analysis</h2>
<div class="analysis-grid">
<AnalysisCard
v-for="result in store.analysisResults"
:key="result.isin"
:result="result"
/>
</div>
</div>
<!-- Empty State -->
<div v-else class="glass-card text-center" style="padding: 3rem;">
<div style="font-size: 3rem; margin-bottom: 1rem;">📊</div>
<h3 style="color: var(--text-primary); margin-bottom: 0.5rem;">No Analysis Yet</h3>
<p class="text-secondary">Add stocks to your watchlist and click "Analyze Watchlist" to get started.</p>
</div>
</div>
</div>
</template>
<style scoped>
.dashboard {
display: grid;
grid-template-columns: 320px 1fr;
gap: 2rem;
align-items: start;
}
.main-content {
min-height: 600px;
}
.analyze-section {
position: relative;
}
.analysis-grid {
display: grid;
gap: 1.5rem;
}
@media (max-width: 1024px) {
.dashboard {
grid-template-columns: 1fr;
}
}
</style>
+543
View File
@@ -0,0 +1,543 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useStockStore, type AnalysisResult } from '../store'
import WatchlistSidebar from '../components/WatchlistSidebar.vue'
const store = useStockStore()
const historyByIsin = ref<Map<string, AnalysisResult[]>>(new Map())
const loading = ref(false)
const showDeleteModal = ref(false)
const startDate = ref('')
const endDate = ref('')
// Navigation & Filtering
const selectedIsin = ref<string | null>(null)
const searchQuery = ref('')
const sortBy = ref<'date' | 'symbol' | 'accuracy'>('date')
onMounted(async () => {
await store.fetchJobs()
await loadHistory()
})
async function loadHistory() {
loading.value = true
try {
await store.fetchWatchlist()
const historyMap = new Map<string, AnalysisResult[]>()
for (const stock of store.watchlist) {
const results = await store.fetchHistoryByIsin(stock.isin)
if (results.length > 0) {
historyMap.set(stock.isin, results)
} else {
historyMap.set(stock.isin, [])
}
}
historyByIsin.value = historyMap
} catch (error: any) {
alert('Error loading history: ' + error.message)
} finally {
loading.value = false
}
}
// Computed Data for Main Table
const tableData = computed(() => {
const data: any[] = []
historyByIsin.value.forEach((results, isin) => {
// Find symbol from results or watchlist
let symbol = results.length > 0 ? results[0].symbol : ''
if (!symbol) {
const stock = store.watchlist.find(s => s.isin === isin)
symbol = stock ? (stock.symbol || isin) : isin
}
if (results.length === 0) {
data.push({
isin,
symbol,
latestResult: null,
accuracy: { openaiPct: 0, anthropicPct: 0, total: 0 }
})
return
}
// Sort results by date descending to find latest
const sortedResults = [...results].sort((a, b) =>
new Date(b.analyzedAt).getTime() - new Date(a.analyzedAt).getTime()
)
const latest = sortedResults[0]
const accuracy = calculateAccuracy(results)
data.push({
isin,
symbol: latest.symbol,
latestResult: latest,
accuracy
})
})
return data
})
const filteredData = computed(() => {
let data = tableData.value
// Filter
if (searchQuery.value) {
const query = searchQuery.value.toLowerCase()
data = data.filter(item =>
item.symbol.toLowerCase().includes(query) ||
item.isin.toLowerCase().includes(query)
)
}
// Sort
data.sort((a, b) => {
if (sortBy.value === 'date') {
const timeA = a.latestResult ? new Date(a.latestResult.analyzedAt).getTime() : 0
const timeB = b.latestResult ? new Date(b.latestResult.analyzedAt).getTime() : 0
return timeB - timeA
} else if (sortBy.value === 'symbol') {
return a.symbol.localeCompare(b.symbol)
} else if (sortBy.value === 'accuracy') {
return (b.accuracy.openaiPct + b.accuracy.anthropicPct) - (a.accuracy.openaiPct + a.accuracy.anthropicPct)
}
return 0
})
return data
})
const selectedDetails = computed(() => {
if (!selectedIsin.value) return []
return historyByIsin.value.get(selectedIsin.value) || []
})
function calculateAccuracy(results: AnalysisResult[]) {
let openaiCorrect = 0
let anthropicCorrect = 0
let total = 0
for (const result of results) {
if (result.realPrice !== undefined && result.realPrice !== null && result.price) {
total++
const startPrice = result.price
const endPrice = result.realPrice
// OpenAI
const openaiPred = result.llmAnalysisOpenai?.prediction?.toUpperCase() || ''
if ((openaiPred.includes('BULLISH') && endPrice > startPrice) ||
(openaiPred.includes('BEARISH') && endPrice < startPrice)) {
openaiCorrect++
}
// Anthropic
const anthropicPred = result.llmAnalysisAnthropic?.prediction?.toUpperCase() || ''
if ((anthropicPred.includes('BULLISH') && endPrice > startPrice) ||
(anthropicPred.includes('BEARISH') && endPrice < startPrice)) {
anthropicCorrect++
}
}
}
const openaiPct = total > 0 ? Math.round((openaiCorrect / total) * 100) : 0
const anthropicPct = total > 0 ? Math.round((anthropicCorrect / total) * 100) : 0
return { openaiPct, anthropicPct, total }
}
async function handleDeleteByDateRange() {
if (!startDate.value || !endDate.value) {
alert('Please select both start and end dates')
return
}
if (new Date(startDate.value) > new Date(endDate.value)) {
alert('Start date must be before end date')
return
}
if (!confirm(`Are you sure you want to delete all records between ${startDate.value} and ${endDate.value}?`)) {
return
}
try {
const result = await store.deleteHistoryByDateRange(startDate.value, endDate.value)
alert(`Deleted ${result.deleted} records`)
showDeleteModal.value = false
await loadHistory()
} catch (error: any) {
alert('Error deleting records: ' + error.message)
}
}
async function handleRefreshPrice(result: AnalysisResult) {
if (!result.id) return
try {
const updatedResult = await store.refreshRealPrice(result.id)
// Update local state
const results = historyByIsin.value.get(result.isin)
if (results) {
const index = results.findIndex(r => r.id === result.id)
if (index !== -1) {
results[index] = updatedResult
}
}
} catch (error: any) {
alert('Error refreshing price: ' + error.message)
}
}
function isDateInPast(dateStr: string) {
return new Date(dateStr) < new Date()
}
async function handleAnalyzeAll() {
try {
await store.startAnalysis()
} catch (error: any) {
alert('Error starting analysis: ' + error.message)
}
}
async function handleAnalyzeSingle(isin: string, event: Event) {
event.stopPropagation()
try {
await store.startAnalysis(isin)
} catch (error: any) {
alert('Error starting analysis: ' + error.message)
}
}
async function handleStop() {
if (!confirm('Are you sure you want to stop pending analyses?')) {
return
}
try {
await store.stopAnalysis()
} catch (error: any) {
alert('Error stopping analysis: ' + error.message)
}
}
function getJobStatus(isin: string) {
return store.analysisJobs.find(j => j.isin === isin && (j.status === 'PENDING' || j.status === 'PROCESSING'))?.status
}
</script>
<template>
<div class="dashboard-layout">
<WatchlistSidebar />
<div class="main-content">
<div class="history-view">
<!-- Header -->
<div class="flex justify-between items-center mb-3">
<div class="flex items-center gap-3">
<button v-if="selectedIsin" @click="selectedIsin = null" class="btn btn-secondary">
⬅️ Back
</button>
<h1 style="color: var(--text-primary);">
{{ selectedIsin ? 'Details: ' + selectedDetails[0]?.symbol : 'History Overview' }}
</h1>
</div>
<div class="flex gap-2">
<button
v-if="store.loading"
@click="handleStop"
class="btn btn-danger"
>
⏹️ Stop All
</button>
<button
v-else
@click="handleAnalyzeAll"
class="btn btn-primary"
:disabled="store.watchlist.length === 0"
>
🔍 Analyze All
</button>
<button @click="loadHistory" class="btn btn-secondary">
🔄 Refresh
</button>
<button @click="showDeleteModal = true" class="btn btn-danger">
🗑️ Delete by Date
</button>
</div>
</div>
<!-- Main Table View -->
<div v-if="!selectedIsin">
<div class="glass-card mb-3 p-3 flex gap-3">
<div style="flex: 1;">
<input
v-model="searchQuery"
placeholder="Search Symbol or ISIN..."
class="input"
style="width: 100%;"
/>
</div>
<div style="width: 200px;">
<select v-model="sortBy" class="input" style="width: 100%;">
<option value="date">Sort by Date</option>
<option value="symbol">Sort by Symbol</option>
<option value="accuracy">Sort by Accuracy</option>
</select>
</div>
</div>
<div class="glass-card table-container">
<table class="history-table">
<thead>
<tr>
<th>Symbol</th>
<th>Latest Analysis</th>
<th>Target Date</th>
<th>Latest Prediction (OpenAI)</th>
<th>Latest Prediction (Anthropic)</th>
<th>Accuracy</th>
<th>History Size</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr v-for="item in filteredData" :key="item.isin" @click="selectedIsin = item.isin" class="clickable-row">
<td>
<strong style="color: var(--text-primary); font-size: 1.1rem;">{{ item.symbol }}</strong>
<div class="text-muted" style="font-size: 0.8rem;">{{ item.isin }}</div>
</td>
<td>
{{ item.latestResult ? new Date(item.latestResult.analyzedAt).toLocaleDateString() : 'Never' }}
</td>
<td>
{{ item.latestResult ? new Date(item.latestResult.targetDate).toLocaleDateString() : '-' }}
</td>
<td>
<span v-if="item.latestResult?.llmAnalysisOpenai" class="badge badge-info">
{{ item.latestResult.llmAnalysisOpenai.prediction }}
</span>
<span v-else class="text-muted">N/A</span>
</td>
<td>
<span v-if="item.latestResult?.llmAnalysisAnthropic" class="badge badge-warning">
{{ item.latestResult.llmAnalysisAnthropic.prediction }}
</span>
<span v-else class="text-muted">N/A</span>
</td>
<td>
<div class="flex flex-col gap-1" style="font-size: 0.75rem;">
<span class="text-info">OpenAI: {{ item.accuracy.openaiPct }}%</span>
<span class="text-warning">Anthropic: {{ item.accuracy.anthropicPct }}%</span>
<span class="text-muted" style="font-size: 0.7rem;">({{ item.accuracy.total }} verified)</span>
</div>
</td>
<td>{{ historyByIsin.get(item.isin)?.length || 0 }} records</td>
<td>
<div v-if="getJobStatus(item.isin)" class="flex items-center gap-1">
<div class="spinner" style="width: 12px; height: 12px; border-width: 2px;"></div>
<span class="text-info" style="font-size: 0.8rem;">{{ getJobStatus(item.isin) }}</span>
</div>
<button v-else @click="handleAnalyzeSingle(item.isin, $event)" class="btn btn-sm btn-primary">
Analyze
</button>
</td>
</tr>
<tr v-if="filteredData.length === 0">
<td colspan="7" class="text-center text-muted" style="padding: 2rem;">
No history found matching your criteria.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Detail View -->
<div v-else>
<div class="glass-card mb-3">
<div class="history-header">
<div>
<h3 style="color: var(--text-primary);">{{ selectedDetails[0]?.symbol }}</h3>
<p class="text-muted" style="font-size: 0.875rem;">{{ selectedIsin }}</p>
</div>
<div class="accuracy-badges">
<span class="badge badge-info">
OpenAI Accuracy: {{ calculateAccuracy(selectedDetails).openaiPct }}%
</span>
<span class="badge badge-warning">
Anthropic Accuracy: {{ calculateAccuracy(selectedDetails).anthropicPct }}%
</span>
</div>
</div>
<div class="table-container mt-2">
<table>
<thead>
<tr>
<th>Analyzed Date</th>
<th>Target Date</th>
<th>Analyzed Price</th>
<th>Real Price</th>
<th>OpenAI</th>
<th>Anthropic</th>
</tr>
</thead>
<tbody>
<tr v-for="result in selectedDetails" :key="result.id">
<td>{{ new Date(result.date).toLocaleDateString() }}</td>
<td>{{ new Date(result.targetDate).toLocaleDateString() }}</td>
<td>
<span v-if="result.price !== null && result.price !== undefined">${{ result.price.toFixed(2) }}</span>
<span v-else class="text-muted">N/A</span>
</td>
<td>
<span v-if="result.realPrice !== null && result.realPrice !== undefined">
${{ result.realPrice.toFixed(2) }}
</span>
<button
v-else-if="isDateInPast(result.targetDate)"
@click="handleRefreshPrice(result)"
class="btn btn-sm btn-secondary"
style="font-size: 0.75rem; padding: 0.25rem 0.5rem;"
>
🔄 Fetch
</button>
<span v-else class="text-muted">Pending</span>
</td>
<td>
<div v-if="result.llmAnalysisOpenai">
<span class="badge badge-info">
{{ result.llmAnalysisOpenai.prediction }}
</span>
<span class="text-muted"> ⏳</span>
</div>
<div v-if="result.llmAnalysisOpenai" class="text-muted" style="font-size: 0.75rem; margin-top: 0.25rem;">
{{ result.llmAnalysisOpenai.reasoning.substring(0, 100) }}...
</div>
<div v-else class="text-muted">N/A</div>
</td>
<td>
<div v-if="result.llmAnalysisAnthropic">
<span class="badge badge-warning">
{{ result.llmAnalysisAnthropic.prediction }}
</span>
<span class="text-muted"> ⏳</span>
</div>
<div v-if="result.llmAnalysisAnthropic" class="text-muted" style="font-size: 0.75rem; margin-top: 0.25rem;">
{{ result.llmAnalysisAnthropic.reasoning.substring(0, 100) }}...
</div>
<div v-else class="text-muted">N/A</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Delete Modal -->
<div v-if="showDeleteModal" class="modal-overlay" @click.self="showDeleteModal = false">
<div class="modal-content glass-card">
<h3 class="mb-2" style="color: var(--text-primary);">Delete Records by Date Range</h3>
<div class="alert alert-warning mb-2">
⚠️ This action cannot be undone.
</div>
<div class="grid grid-cols-2 gap-2 mb-3">
<div>
<label class="text-secondary" style="display: block; margin-bottom: 0.5rem;">Start Date</label>
<input type="date" v-model="startDate" class="input" />
</div>
<div>
<label class="text-secondary" style="display: block; margin-bottom: 0.5rem;">End Date</label>
<input type="date" v-model="endDate" class="input" />
</div>
</div>
<div class="flex gap-2">
<button @click="handleDeleteByDateRange" class="btn btn-danger" style="flex: 1;">
Delete Records
</button>
<button @click="showDeleteModal = false" class="btn btn-secondary" style="flex: 1;">
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.dashboard-layout {
display: grid;
grid-template-columns: 320px 1fr;
gap: 2rem;
align-items: start;
}
.history-view {
width: 100%;
}
.clickable-row {
cursor: pointer;
transition: background-color 0.2s;
}
.clickable-row:hover {
background-color: rgba(255, 255, 255, 0.05);
}
.history-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.accuracy-badges {
display: flex;
gap: 0.5rem;
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
backdrop-filter: blur(5px);
}
.modal-content {
max-width: 500px;
width: 90%;
padding: 2rem;
}
@media (max-width: 1024px) {
.dashboard-layout {
grid-template-columns: 1fr;
}
.history-header {
flex-direction: column;
align-items: flex-start;
gap: 1rem;
}
}
</style>
+7
View File
@@ -0,0 +1,7 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
+43
View File
@@ -0,0 +1,43 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
/* Path mapping */
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
+15
View File
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"types": [
"node"
]
},
"include": [
"vite.config.ts"
]
}
+21
View File
@@ -0,0 +1,21 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true
}
}
}
})