josesalazar2025 commited on
Commit ·
0ef022d
0
Parent(s):
Maqueta de proyecto con archivos comentados
Browse files- .env.example +13 -0
- .gitignore +50 -0
- Dockerfile +35 -0
- README.md +139 -0
- backend/package.json +26 -0
- backend/prisma/schema.prisma +112 -0
- backend/src/config.js +9 -0
- backend/src/index.js +9 -0
- backend/src/routes/alerts.js +9 -0
- backend/src/routes/markets.js +9 -0
- backend/src/routes/positions.js +10 -0
- backend/src/routes/signals.js +9 -0
- backend/src/routes/watchlist.js +10 -0
- backend/src/scheduler.js +9 -0
- backend/src/services/aiPipeline.js +12 -0
- backend/src/services/finnhub.js +11 -0
- backend/src/services/kelly.js +15 -0
- backend/src/services/polymarket.js +11 -0
- backend/src/services/telegramBot.js +12 -0
- backend/src/socket/broadcaster.js +10 -0
- docker-compose.yml +14 -0
- frontend/dist/assets/index-CHfdQIIe.js +0 -0
- frontend/dist/assets/index-CIGW-MKW.css +1 -0
- frontend/dist/index.html +18 -0
- frontend/index.html +17 -0
- frontend/package.json +19 -0
- frontend/src/api.js +11 -0
- frontend/src/app.js +37 -0
- frontend/src/charts.js +14 -0
- frontend/src/main.js +2 -0
- frontend/src/map.js +17 -0
- frontend/src/simulator.js +11 -0
- frontend/src/style.css +12 -0
- frontend/vite.config.js +22 -0
- package.json +35 -0
.env.example
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Variables de entorno — PolySignal
|
| 2 |
+
#
|
| 3 |
+
# Copiar este archivo a .env y rellenar con tus claves.
|
| 4 |
+
# Nunca commitear el archivo .env real (debe estar en .gitignore).
|
| 5 |
+
# Ubicacion recomendada: en la raiz del proyecto (al lado de docker-compose.yml).
|
| 6 |
+
|
| 7 |
+
HF_TOKEN= # HuggingFace Pro API key (Inference API)
|
| 8 |
+
OPENROUTER_API_KEY= # Fallback LLM si HF esta saturado
|
| 9 |
+
FINNHUB_API_KEY= # Noticias financieras (finnhub.io)
|
| 10 |
+
TELEGRAM_BOT_TOKEN= # Bot de alertas (@BotFather)
|
| 11 |
+
DATABASE_URL=file:./backend/prisma/polysignal.db # SQLite local (relativo a backend/)
|
| 12 |
+
PORT=7860 # HuggingFace Spaces requiere 7860
|
| 13 |
+
NODE_ENV=production
|
.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Node.js
|
| 2 |
+
node_modules/
|
| 3 |
+
npm-debug.log*
|
| 4 |
+
yarn-debug.log*
|
| 5 |
+
yarn-error.log*
|
| 6 |
+
package-lock.json
|
| 7 |
+
yarn.lock
|
| 8 |
+
|
| 9 |
+
# Entorno
|
| 10 |
+
.env
|
| 11 |
+
.env.local
|
| 12 |
+
.env.*.local
|
| 13 |
+
|
| 14 |
+
# Base de datos SQLite
|
| 15 |
+
*.db
|
| 16 |
+
*.db-journal
|
| 17 |
+
backend/prisma/dev.db
|
| 18 |
+
backend/prisma/dev.db-journal
|
| 19 |
+
|
| 20 |
+
# Logs
|
| 21 |
+
logs/
|
| 22 |
+
*.log
|
| 23 |
+
|
| 24 |
+
# macOS
|
| 25 |
+
.DS_Store
|
| 26 |
+
.AppleDouble
|
| 27 |
+
.LSOverride
|
| 28 |
+
._*
|
| 29 |
+
|
| 30 |
+
# Windows
|
| 31 |
+
Thumbs.db
|
| 32 |
+
ehthumbs.db
|
| 33 |
+
Desktop.ini
|
| 34 |
+
|
| 35 |
+
# IDEs y editores
|
| 36 |
+
.idea/
|
| 37 |
+
.vscode/
|
| 38 |
+
*.swp
|
| 39 |
+
*.swo
|
| 40 |
+
*~
|
| 41 |
+
|
| 42 |
+
# Coverage y testing
|
| 43 |
+
coverage/
|
| 44 |
+
.nyc_output/
|
| 45 |
+
|
| 46 |
+
# Docker
|
| 47 |
+
.dockerignore
|
| 48 |
+
|
| 49 |
+
# HuggingFace Spaces (si genera cache)
|
| 50 |
+
.cache/
|
Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dockerfile — PolySignal
|
| 2 |
+
#
|
| 3 |
+
# Estructura multicontexto:
|
| 4 |
+
# - backend/ : API Node.js + Express + Socket.io + Prisma
|
| 5 |
+
# - frontend/ : SPA Vanilla JS (servida como estaticos)
|
| 6 |
+
#
|
| 7 |
+
# Pasos:
|
| 8 |
+
# 1. Establecer WORKDIR en /app/backend
|
| 9 |
+
# 2. Copiar backend/package.json e instalar dependencias
|
| 10 |
+
# 3. Copiar todo el codigo fuente (backend/ + frontend/)
|
| 11 |
+
# 4. Generar cliente Prisma para SQLite
|
| 12 |
+
# 5. Exponer puerto 7860 (requerido por HuggingFace Spaces)
|
| 13 |
+
# 6. Iniciar aplicacion con: node backend/src/index.js
|
| 14 |
+
#
|
| 15 |
+
# Build local: docker build -t polysignal .
|
| 16 |
+
# Run local: docker run -p 7860:7860 --env-file .env polysignal
|
| 17 |
+
|
| 18 |
+
FROM node:22-slim
|
| 19 |
+
WORKDIR /app
|
| 20 |
+
|
| 21 |
+
# Instalar dependencias del backend
|
| 22 |
+
COPY backend/package*.json ./backend/
|
| 23 |
+
RUN cd backend && npm ci --only=production
|
| 24 |
+
|
| 25 |
+
# Copiar codigo fuente completo
|
| 26 |
+
COPY backend/ ./backend/
|
| 27 |
+
COPY frontend/ ./frontend/
|
| 28 |
+
|
| 29 |
+
# Generar cliente Prisma
|
| 30 |
+
RUN cd backend && npx prisma generate
|
| 31 |
+
|
| 32 |
+
# Puerto obligatorio de HuggingFace Spaces
|
| 33 |
+
EXPOSE 7860
|
| 34 |
+
|
| 35 |
+
CMD ["node", "backend/src/index.js"]
|
README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PolySignal
|
| 2 |
+
|
| 3 |
+
Dashboard web de inteligencia de mercados de prediccion en tiempo real.
|
| 4 |
+
|
| 5 |
+
## Que es
|
| 6 |
+
|
| 7 |
+
PolySignal analiza mercados de Polymarket cruzando noticias de Finnhub con modelos de IA (ModernFinBERT + Qwen3-8B) para generar senales de trading (bullish, bearish, neutral). Incluye simulador de posiciones con capital virtual, watchlist y alertas por Telegram.
|
| 8 |
+
|
| 9 |
+
**No ejecuta ordenes reales.** Es una herramienta de analisis e inteligencia.
|
| 10 |
+
|
| 11 |
+
## Stack
|
| 12 |
+
|
| 13 |
+
- **Backend:** Node.js 22 + Express.js + Socket.io + node-cron
|
| 14 |
+
- **ORM:** Prisma + SQLite
|
| 15 |
+
- **Frontend:** Vanilla JS + Vite (bundler & dev server) + Leaflet.js + Chart.js
|
| 16 |
+
- **IA:** HuggingFace Inference API (ModernFinBERT, Qwen3-8B) + OpenRouter fallback
|
| 17 |
+
- **Datos:** Polymarket Gamma API + Finnhub REST
|
| 18 |
+
- **Deploy:** HuggingFace Spaces (Docker, puerto 7860)
|
| 19 |
+
|
| 20 |
+
## Estructura
|
| 21 |
+
|
| 22 |
+
```
|
| 23 |
+
polysignal/
|
| 24 |
+
├── backend/ # API REST + Servicios + Scheduler
|
| 25 |
+
│ ├── package.json # Dependencias del backend
|
| 26 |
+
│ ├── prisma/
|
| 27 |
+
│ │ └── schema.prisma # Schema SQLite (Prisma)
|
| 28 |
+
│ └── src/
|
| 29 |
+
│ ├── index.js # Entry point Express
|
| 30 |
+
│ ├── config.js # Variables de entorno
|
| 31 |
+
│ ├── scheduler.js # Jobs periodicos (cron)
|
| 32 |
+
│ ├── routes/ # Endpoints REST (/api/v1)
|
| 33 |
+
│ ├── services/ # Logica de negocio + integraciones
|
| 34 |
+
│ └── socket/ # Eventos Socket.io
|
| 35 |
+
│
|
| 36 |
+
├── frontend/ # SPA Vanilla JS con Vite
|
| 37 |
+
│ ├── index.html # Punto de entrada HTML
|
| 38 |
+
│ ├── package.json # Dependencias del frontend
|
| 39 |
+
│ ├── vite.config.js # Configuracion de Vite (proxy + build)
|
| 40 |
+
│ └── src/
|
| 41 |
+
│ ├── main.js # Entry point de Vite
|
| 42 |
+
│ ├── app.js # Logica principal + Socket.io
|
| 43 |
+
│ ├── api.js # Cliente REST
|
| 44 |
+
│ ├── charts.js # Chart.js
|
| 45 |
+
│ ├── map.js # Leaflet
|
| 46 |
+
│ ├── simulator.js # Simulador de posiciones
|
| 47 |
+
│ └── style.css # Estilos
|
| 48 |
+
│
|
| 49 |
+
├── package.json # Root con workspaces + scripts conjuntos
|
| 50 |
+
├── docker-compose.yml # Orquestacion local
|
| 51 |
+
├── Dockerfile # Build para HuggingFace Spaces
|
| 52 |
+
├── .env.example # Variables de entorno de ejemplo
|
| 53 |
+
└── README.md
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Instalacion rapida
|
| 57 |
+
|
| 58 |
+
```bash
|
| 59 |
+
# 1. Instalar dependencias (root + todos los workspaces)
|
| 60 |
+
npm install
|
| 61 |
+
|
| 62 |
+
# 2. Configurar variables de entorno
|
| 63 |
+
cp .env.example .env
|
| 64 |
+
# Editar .env con tus claves
|
| 65 |
+
|
| 66 |
+
# 3. Generar base de datos y cliente Prisma
|
| 67 |
+
npm run db:migrate
|
| 68 |
+
npm run db:generate
|
| 69 |
+
|
| 70 |
+
# 4. Iniciar en desarrollo
|
| 71 |
+
npm run dev:all # Backend + Frontend Vite simultaneamente
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## Arquitectura del Frontend
|
| 75 |
+
|
| 76 |
+
El frontend es una SPA (Single Page Application) construida con **Vite** como bundler y dev server. Las librerias (Chart.js, Leaflet, Socket.io client) se gestionan como dependencias npm en lugar de CDN, lo que permite tree-shaking y un build optimizado para produccion.
|
| 77 |
+
|
| 78 |
+
### Flujo de desarrollo
|
| 79 |
+
|
| 80 |
+
| Servicio | Comando | URL local |
|
| 81 |
+
|----------|---------|-----------|
|
| 82 |
+
| Backend (Express + Socket.io) | `npm run dev` | `http://localhost:7860` |
|
| 83 |
+
| Frontend (Vite + HMR) | `npm run dev:frontend` | `http://localhost:5173` |
|
| 84 |
+
| **Ambos a la vez** | **`npm run dev:all`** | — |
|
| 85 |
+
|
| 86 |
+
Vite esta configurado con un proxy que redirige automaticamente las peticiones a `/api` y `/socket.io` hacia el backend en el puerto `7860`, eliminando problemas de CORS durante el desarrollo local.
|
| 87 |
+
|
| 88 |
+
### Scripts disponibles
|
| 89 |
+
|
| 90 |
+
```bash
|
| 91 |
+
# Levantar solo el backend
|
| 92 |
+
npm run dev
|
| 93 |
+
|
| 94 |
+
# Levantar solo el frontend (Vite con hot reload)
|
| 95 |
+
npm run dev:frontend
|
| 96 |
+
|
| 97 |
+
# Levantar backend y frontend simultaneamente en una sola terminal
|
| 98 |
+
npm run dev:all
|
| 99 |
+
|
| 100 |
+
# Build de produccion del frontend (genera frontend/dist/)
|
| 101 |
+
npm run build:frontend
|
| 102 |
+
|
| 103 |
+
# Preview del build de produccion
|
| 104 |
+
npm run preview:frontend
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
### Build de produccion
|
| 108 |
+
|
| 109 |
+
```bash
|
| 110 |
+
npm run build:frontend
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
Esto genera los assets optimizados en `frontend/dist/`. En produccion (HuggingFace Spaces), el backend Express sirve directamente esa carpeta como archivos estaticos.
|
| 114 |
+
|
| 115 |
+
## Deploy en HuggingFace Spaces
|
| 116 |
+
|
| 117 |
+
1. Crear Space tipo "Docker"
|
| 118 |
+
2. Subir codigo (`git push`)
|
| 119 |
+
3. Configurar Secrets en la interfaz de HF con las variables de `.env`
|
| 120 |
+
4. El contenedor expone el puerto 7860 automaticamente
|
| 121 |
+
|
| 122 |
+
### Docker local (opcional)
|
| 123 |
+
|
| 124 |
+
```bash
|
| 125 |
+
# Build y run con docker-compose
|
| 126 |
+
docker-compose up --build
|
| 127 |
+
|
| 128 |
+
# O solo docker build
|
| 129 |
+
docker build -t polysignal .
|
| 130 |
+
docker run -p 7860:7860 --env-file .env polysignal
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
## Equipo
|
| 134 |
+
|
| 135 |
+
Hackathon CIFO Barcelona La Violeta — 13-18 mayo 2026
|
| 136 |
+
|
| 137 |
+
## Licencia
|
| 138 |
+
|
| 139 |
+
MIT
|
backend/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "polysignal-backend",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "Backend API de PolySignal — Hackathon CIFO Barcelona La Violeta",
|
| 5 |
+
"main": "src/index.js",
|
| 6 |
+
"prisma": {
|
| 7 |
+
"schema": "prisma/schema.prisma"
|
| 8 |
+
},
|
| 9 |
+
"scripts": {
|
| 10 |
+
"start": "node src/index.js",
|
| 11 |
+
"dev": "node --watch src/index.js",
|
| 12 |
+
"db:migrate": "prisma migrate dev",
|
| 13 |
+
"db:generate": "prisma generate",
|
| 14 |
+
"db:studio": "prisma studio"
|
| 15 |
+
},
|
| 16 |
+
"dependencies": {
|
| 17 |
+
"express": "^4.21.0",
|
| 18 |
+
"socket.io": "^4.8.0",
|
| 19 |
+
"node-cron": "^3.0.3",
|
| 20 |
+
"@prisma/client": "^6.0.0",
|
| 21 |
+
"prisma": "^6.0.0"
|
| 22 |
+
},
|
| 23 |
+
"engines": {
|
| 24 |
+
"node": ">=22.0.0"
|
| 25 |
+
}
|
| 26 |
+
}
|
backend/prisma/schema.prisma
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Schema de Prisma ORM para base de datos SQLite.
|
| 3 |
+
*
|
| 4 |
+
* Define 6 modelos: User, Market, AISignal, Position, Watchlist, Alert.
|
| 5 |
+
* Relaciones:
|
| 6 |
+
* - Market 1:N AISignal, Position, Watchlist, Alert
|
| 7 |
+
* - User 1:N Position, Watchlist, Alert
|
| 8 |
+
*
|
| 9 |
+
* No modificar sin consenso del equipo. Generar migraciones con:
|
| 10 |
+
* npx prisma migrate dev
|
| 11 |
+
* npx prisma generate
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
generator client {
|
| 15 |
+
provider = "prisma-client-js"
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
datasource db {
|
| 19 |
+
provider = "sqlite"
|
| 20 |
+
url = env("DATABASE_URL")
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
model User {
|
| 24 |
+
id Int @id @default(autoincrement())
|
| 25 |
+
telegramChatId String? // Configurado manualmente para demo
|
| 26 |
+
createdAt DateTime @default(now())
|
| 27 |
+
|
| 28 |
+
positions Position[]
|
| 29 |
+
watchlist Watchlist[]
|
| 30 |
+
alerts Alert[]
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
model Market {
|
| 34 |
+
id String @id // ID nativo de Polymarket
|
| 35 |
+
question String // Texto de la pregunta del mercado
|
| 36 |
+
category String? // politics | crypto | economics | sports
|
| 37 |
+
countryCode String? // ISO2 — usado por Leaflet para burbujas
|
| 38 |
+
yesPrice Float? // Precio YES: 0.0 a 1.0
|
| 39 |
+
noPrice Float? // Precio NO: 0.0 a 1.0
|
| 40 |
+
volumeEur Float? // Volumen en Eur
|
| 41 |
+
liquidityEur Float? // Liquidez en Eur
|
| 42 |
+
status String @default("active") // active | closed | resolved
|
| 43 |
+
closesAt DateTime? // Fecha de cierre del mercado
|
| 44 |
+
lastSynced DateTime @default(now()) // Ultima sincronizacion de precios
|
| 45 |
+
|
| 46 |
+
signals AISignal[]
|
| 47 |
+
positions Position[]
|
| 48 |
+
watchlist Watchlist[]
|
| 49 |
+
alerts Alert[]
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
model AISignal {
|
| 53 |
+
id Int @id @default(autoincrement())
|
| 54 |
+
marketId String
|
| 55 |
+
market Market @relation(fields: [marketId], references: [id], onDelete: Cascade)
|
| 56 |
+
signal String // bullish | bearish | neutral
|
| 57 |
+
confidence Float // 0.0 a 1.0
|
| 58 |
+
summary String? // 2 frases generadas por Qwen3
|
| 59 |
+
keyRisk String? // 1 frase de riesgo principal
|
| 60 |
+
newsCount Int @default(0) // Titulares relevantes usados
|
| 61 |
+
modelVersion String @default("Qwen3-8B") // Modelo LLM que genero la senal
|
| 62 |
+
generatedAt DateTime @default(now())
|
| 63 |
+
|
| 64 |
+
@@index([marketId, generatedAt])
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
model Position {
|
| 68 |
+
id Int @id @default(autoincrement())
|
| 69 |
+
userId Int
|
| 70 |
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
| 71 |
+
marketId String
|
| 72 |
+
market Market @relation(fields: [marketId], references: [id], onDelete: Cascade)
|
| 73 |
+
outcome String // YES | NO
|
| 74 |
+
amountEur Float // Capital virtual apostado
|
| 75 |
+
entryPrice Float // Precio al abrir la posicion
|
| 76 |
+
currentPrice Float? // Precio actual (actualizado por scheduler)
|
| 77 |
+
pnl Float @default(0) // Profit and Loss calculado
|
| 78 |
+
kellyFraction Float? // Fraccion de Kelly al abrir
|
| 79 |
+
status String @default("open") // open | closed
|
| 80 |
+
openedAt DateTime @default(now())
|
| 81 |
+
closedAt DateTime?
|
| 82 |
+
|
| 83 |
+
@@index([userId, status])
|
| 84 |
+
@@index([marketId])
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
model Watchlist {
|
| 88 |
+
id Int @id @default(autoincrement())
|
| 89 |
+
userId Int
|
| 90 |
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
| 91 |
+
marketId String
|
| 92 |
+
market Market @relation(fields: [marketId], references: [id], onDelete: Cascade)
|
| 93 |
+
alertThreshold Float? // Umbral de precio para alerta Telegram
|
| 94 |
+
createdAt DateTime @default(now())
|
| 95 |
+
|
| 96 |
+
@@unique([userId, marketId])
|
| 97 |
+
@@index([userId])
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
model Alert {
|
| 101 |
+
id Int @id @default(autoincrement())
|
| 102 |
+
userId Int
|
| 103 |
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
| 104 |
+
marketId String
|
| 105 |
+
market Market @relation(fields: [marketId], references: [id], onDelete: Cascade)
|
| 106 |
+
type String // price_threshold | signal_change
|
| 107 |
+
message String // Texto enviado por Telegram
|
| 108 |
+
sentAt DateTime @default(now())
|
| 109 |
+
|
| 110 |
+
@@index([userId, sentAt])
|
| 111 |
+
@@index([marketId])
|
| 112 |
+
}
|
backend/src/config.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Configuración centralizada de variables de entorno.
|
| 3 |
+
*
|
| 4 |
+
* Carga los valores de process.env con defaults seguros para desarrollo.
|
| 5 |
+
* Expone constantes como: PORT, DATABASE_URL, HF_TOKEN, FINNHUB_API_KEY,
|
| 6 |
+
* OPENROUTER_API_KEY, TELEGRAM_BOT_TOKEN, NODE_ENV.
|
| 7 |
+
*
|
| 8 |
+
* Evita dispersar process.env por todo el código.
|
| 9 |
+
*/
|
backend/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Entry point de la aplicacion PolySignal.
|
| 3 |
+
*
|
| 4 |
+
* Inicializa el servidor Express, configura Socket.io para comunicacion en tiempo real,
|
| 5 |
+
* sirve los archivos estaticos del frontend desde ../frontend/, monta las rutas REST
|
| 6 |
+
* bajo /api/v1/* y arranca el scheduler de node-cron.
|
| 7 |
+
*
|
| 8 |
+
* Puerto por defecto: 7860 (requerido por HuggingFace Spaces).
|
| 9 |
+
*/
|
backend/src/routes/alerts.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Rutas REST para alertas y notificaciones.
|
| 3 |
+
*
|
| 4 |
+
* Endpoints:
|
| 5 |
+
* GET /api/v1/alerts — historial de alertas enviadas (price_threshold, signal_change)
|
| 6 |
+
*
|
| 7 |
+
* Las alertas se generan automáticamente por el scheduler cada 60 segundos
|
| 8 |
+
* y se envían vía Telegram Bot API.
|
| 9 |
+
*/
|
backend/src/routes/markets.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Rutas REST para mercados de predicción.
|
| 3 |
+
*
|
| 4 |
+
* Endpoints:
|
| 5 |
+
* GET /api/v1/markets — lista mercados activos (filtrables por category, country, limit)
|
| 6 |
+
* GET /api/v1/markets/:id — detalle de un mercado + última señal IA
|
| 7 |
+
*
|
| 8 |
+
* Delega la obtención de datos al servicio services/polymarket.js.
|
| 9 |
+
*/
|
backend/src/routes/positions.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Rutas REST para el simulador de posiciones con capital virtual.
|
| 3 |
+
*
|
| 4 |
+
* Endpoints:
|
| 5 |
+
* POST /api/v1/positions — abrir posición simulada (calcula fracción de Kelly)
|
| 6 |
+
* GET /api/v1/positions — listar posiciones del usuario con P&L actualizado
|
| 7 |
+
* DELETE /api/v1/positions/:id — cerrar posición y calcular resultado final
|
| 8 |
+
*
|
| 9 |
+
* Usa userId=1 fijo para la demo.
|
| 10 |
+
*/
|
backend/src/routes/signals.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Rutas REST para señales de inteligencia artificial.
|
| 3 |
+
*
|
| 4 |
+
* Endpoints:
|
| 5 |
+
* GET /api/v1/markets/:id/signal — devuelve la señal IA más reciente del mercado.
|
| 6 |
+
*
|
| 7 |
+
* Las señales incluyen: signal (bullish|bearish|neutral), confidence (0-1),
|
| 8 |
+
* summary, keyRisk y timestamp.
|
| 9 |
+
*/
|
backend/src/routes/watchlist.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Rutas REST para la watchlist (mercados favoritos).
|
| 3 |
+
*
|
| 4 |
+
* Endpoints:
|
| 5 |
+
* POST /api/v1/watchlist — añadir mercado a favoritos
|
| 6 |
+
* DELETE /api/v1/watchlist/:marketId — eliminar mercado de favoritos
|
| 7 |
+
* GET /api/v1/watchlist — listar favoritos con precios en vivo
|
| 8 |
+
*
|
| 9 |
+
* El usuario demo (userId=1) puede gestionar su lista personal.
|
| 10 |
+
*/
|
backend/src/scheduler.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Scheduler de tareas periódicas usando node-cron.
|
| 3 |
+
*
|
| 4 |
+
* Define y ejecuta los 4 jobs principales:
|
| 5 |
+
* 1. syncMarkets — cada 30s, sincroniza precios desde Polymarket Gamma API.
|
| 6 |
+
* 2. generateSignals — cada 5 min, genera señales IA para el top 20 mercados.
|
| 7 |
+
* 3. updatePositionsPnL— cada 30s, recalcula P&L de posiciones abiertas.
|
| 8 |
+
* 4. processAlerts — cada 60s, revisa watchlist y envía alertas Telegram.
|
| 9 |
+
*/
|
backend/src/services/aiPipeline.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Pipeline de inteligencia artificial para generación de señales.
|
| 3 |
+
*
|
| 4 |
+
* Flujo de dos fases:
|
| 5 |
+
* 1. ModernFinBERT (HF Inference API) → filtra noticias con label=neutral o score<0.65
|
| 6 |
+
* 2. Qwen3-8B (HF Inference API) → analiza mercado + noticias filtradas y genera:
|
| 7 |
+
* { signal, confidence, summary, keyRisk }
|
| 8 |
+
*
|
| 9 |
+
* Fallback: si HF está saturado, usa OpenRouter con deepseek/deepseek-v4-flash.
|
| 10 |
+
*
|
| 11 |
+
* Persiste el resultado en la tabla AISignal y emite evento 'ai_signal' por Socket.io.
|
| 12 |
+
*/
|
backend/src/services/finnhub.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Servicio de integración con Finnhub REST API.
|
| 3 |
+
*
|
| 4 |
+
* Responsabilidades:
|
| 5 |
+
* - Obtener titulares de noticias financieras relevantes.
|
| 6 |
+
* - Proporcionar noticias crudas al pipeline de IA para análisis de sentimiento.
|
| 7 |
+
*
|
| 8 |
+
* Restricciones:
|
| 9 |
+
* - Free tier: máximo 60 llamadas/minuto.
|
| 10 |
+
* - Solo se invoca durante la generación de señales (cada 5 min), no en cada sync de precios.
|
| 11 |
+
*/
|
backend/src/services/kelly.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Servicio de cálculo del Criterio de Kelly.
|
| 3 |
+
*
|
| 4 |
+
* Fórmula:
|
| 5 |
+
* k = (odds * pWin - pLose) / odds
|
| 6 |
+
* odds = (1 / yesPrice) - 1
|
| 7 |
+
* pLose = 1 - pWin
|
| 8 |
+
*
|
| 9 |
+
* Donde:
|
| 10 |
+
* - pWin = confidence de la señal IA (0.0 a 1.0)
|
| 11 |
+
* - yesPrice = precio actual del outcome YES en Polymarket
|
| 12 |
+
*
|
| 13 |
+
* El resultado se capa en 25% (máximo) y nunca es negativo.
|
| 14 |
+
* Se almacena en Position.kellyFraction al abrir una posición.
|
| 15 |
+
*/
|
backend/src/services/polymarket.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Servicio de integración con Polymarket Gamma API.
|
| 3 |
+
*
|
| 4 |
+
* Responsabilidades:
|
| 5 |
+
* - Fetch de mercados activos desde https://gamma-api.polymarket.com
|
| 6 |
+
* - Parseo y normalización de campos: id, question, outcomePrices, volume, liquidity, category, endDate
|
| 7 |
+
* - Persistencia en la tabla Market vía Prisma
|
| 8 |
+
* - Asignación de countryCode por geo-inferencia (delegado al pipeline de IA)
|
| 9 |
+
*
|
| 10 |
+
* No usa autenticación. No usa CLOB API.
|
| 11 |
+
*/
|
backend/src/services/telegramBot.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Servicio de envío de alertas por Telegram Bot API.
|
| 3 |
+
*
|
| 4 |
+
* Implementación sin librerías externas: llamada HTTP directa a:
|
| 5 |
+
* POST https://api.telegram.org/bot<TOKEN>/sendMessage
|
| 6 |
+
*
|
| 7 |
+
* Tipos de alerta soportados:
|
| 8 |
+
* - price_threshold: un precio de watchlist cruzó el umbral definido.
|
| 9 |
+
* - signal_change: la señal IA de un mercado cambió de estado.
|
| 10 |
+
*
|
| 11 |
+
* El chat_id se obtiene del campo telegramChatId del usuario demo.
|
| 12 |
+
*/
|
backend/src/socket/broadcaster.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Módulo de difusión de eventos en tiempo real vía Socket.io.
|
| 3 |
+
*
|
| 4 |
+
* Emite desde el servidor hacia todos los clientes conectados:
|
| 5 |
+
* - 'market_update' → precios actualizados de mercados (cada 30s)
|
| 6 |
+
* - 'ai_signal' → nueva señal IA generada (cada 5 min)
|
| 7 |
+
* - 'price_alert' → alerta de umbral activada (cada 60s)
|
| 8 |
+
*
|
| 9 |
+
* Se importa y usa en index.js (servidor) y en scheduler.js (jobs).
|
| 10 |
+
*/
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
backend:
|
| 5 |
+
build:
|
| 6 |
+
context: .
|
| 7 |
+
dockerfile: Dockerfile
|
| 8 |
+
ports:
|
| 9 |
+
- "7860:7860"
|
| 10 |
+
env_file:
|
| 11 |
+
- .env
|
| 12 |
+
volumes:
|
| 13 |
+
- ./backend/prisma:/app/backend/prisma
|
| 14 |
+
restart: unless-stopped
|
frontend/dist/assets/index-CHfdQIIe.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/dist/assets/index-CIGW-MKW.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none!important;max-height:none!important;width:auto;padding:0}.leaflet-container img.leaflet-tile{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:rgba(51,181,229,.4)}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:visiblePainted;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;-webkit-transition:opacity .2s linear;-moz-transition:opacity .2s linear;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{-webkit-transition:none;-moz-transition:none;transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078a8}.leaflet-zoom-box{border:2px dotted #38f;background:#ffffff80}.leaflet-container{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:12px;font-size:.75rem;line-height:1.5}.leaflet-bar{box-shadow:0 1px 5px #000000a6;border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:700 18px Lucida Console,Monaco,monospace;text-indent:1px}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{box-shadow:0 1px 5px #0006;background:#fff;border-radius:5px}.leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{padding:6px 10px 6px 6px;color:#333;background:#fff}.leaflet-control-layers-scrollbar{overflow-y:scroll;overflow-x:hidden;padding-right:5px}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{display:block;font-size:13px;font-size:1.08333em}.leaflet-control-layers-separator{height:0;border-top:1px solid #ddd;margin:5px -10px 5px -6px}.leaflet-default-icon-path{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution{background:#fff;background:#fffc;margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{padding:0 5px;color:#333;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{display:inline!important;vertical-align:baseline!important;width:1em;height:.6669em}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;white-space:nowrap;-moz-box-sizing:border-box;box-sizing:border-box;background:#fffc;text-shadow:1px 1px #fff}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{border:2px solid rgba(0,0,0,.2);background-clip:padding-box}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;font-size:1.08333em;min-height:1px}.leaflet-popup-content p{margin:1.3em 0}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:#fff;color:#333;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{width:24px;margin:0 auto;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";filter:progid:DXImageTransform.Microsoft.Matrix(M11=.70710678,M12=.70710678,M21=-.70710678,M22=.70710678)}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{position:absolute;pointer-events:none;border:6px solid transparent;background:transparent;content:""}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{left:50%;margin-left:-6px}.leaflet-tooltip-top:before{bottom:0;margin-bottom:-12px;border-top-color:#fff}.leaflet-tooltip-bottom:before{top:0;margin-top:-12px;margin-left:-6px;border-bottom-color:#fff}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{top:50%;margin-top:-6px}.leaflet-tooltip-left:before{right:0;margin-right:-12px;border-left-color:#fff}.leaflet-tooltip-right:before{left:0;margin-left:-12px;border-right-color:#fff}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}}
|
frontend/dist/index.html
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="es">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>PolySignal — Dashboard de Inteligencia de Mercados</title>
|
| 7 |
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 8 |
+
<script type="module" crossorigin src="/assets/index-CHfdQIIe.js"></script>
|
| 9 |
+
<link rel="stylesheet" crossorigin href="/assets/index-CIGW-MKW.css">
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<div id="app">
|
| 13 |
+
<h1>PolySignal Dashboard</h1>
|
| 14 |
+
<p>Carga el entorno de desarrollo con <code>npm run dev</code> en la carpeta <code>frontend</code>.</p>
|
| 15 |
+
</div>
|
| 16 |
+
|
| 17 |
+
</body>
|
| 18 |
+
</html>
|
frontend/index.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="es">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>PolySignal — Dashboard de Inteligencia de Mercados</title>
|
| 7 |
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div id="app">
|
| 11 |
+
<h1>PolySignal Dashboard</h1>
|
| 12 |
+
<p>Carga el entorno de desarrollo con <code>npm run dev</code> en la carpeta <code>frontend</code>.</p>
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<script type="module" src="/src/main.js"></script>
|
| 16 |
+
</body>
|
| 17 |
+
</html>
|
frontend/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "frontend",
|
| 3 |
+
"private": true,
|
| 4 |
+
"version": "1.0.0",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "vite",
|
| 8 |
+
"build": "vite build",
|
| 9 |
+
"preview": "vite preview"
|
| 10 |
+
},
|
| 11 |
+
"devDependencies": {
|
| 12 |
+
"vite": "^6.0.0"
|
| 13 |
+
},
|
| 14 |
+
"dependencies": {
|
| 15 |
+
"chart.js": "^4.4.8",
|
| 16 |
+
"leaflet": "^1.9.4",
|
| 17 |
+
"socket.io-client": "^4.8.1"
|
| 18 |
+
}
|
| 19 |
+
}
|
frontend/src/api.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Cliente HTTP para consumir la API REST del backend.
|
| 3 |
+
*
|
| 4 |
+
* Funciones fetch encapsuladas para cada endpoint:
|
| 5 |
+
* - getMarkets(), getMarket(id), getSignal(id)
|
| 6 |
+
* - createPosition(data), getPositions(), closePosition(id)
|
| 7 |
+
* - addToWatchlist(marketId), removeFromWatchlist(marketId), getWatchlist()
|
| 8 |
+
* - getAlerts(), getStats()
|
| 9 |
+
*
|
| 10 |
+
* Base URL: /api/v1 (mismo dominio, sin CORS en producción HF Spaces).
|
| 11 |
+
*/
|
frontend/src/app.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Punto de entrada del frontend (Vanilla JS).
|
| 3 |
+
*
|
| 4 |
+
* Responsabilidades:
|
| 5 |
+
* - Inicializar conexion Socket.io y escuchar eventos:
|
| 6 |
+
* 'market_update', 'ai_signal', 'price_alert'
|
| 7 |
+
* - Orchestrar la carga inicial de datos (mercados, posiciones, watchlist)
|
| 8 |
+
* - Conectar los modulos: map.js, charts.js, simulator.js, api.js
|
| 9 |
+
*
|
| 10 |
+
* Se ejecuta al cargar index.html.
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
import { io } from 'socket.io-client'
|
| 14 |
+
import * as api from './api.js'
|
| 15 |
+
import * as charts from './charts.js'
|
| 16 |
+
import * as map from './map.js'
|
| 17 |
+
import * as simulator from './simulator.js'
|
| 18 |
+
|
| 19 |
+
const socket = io()
|
| 20 |
+
|
| 21 |
+
socket.on('connect', () => {
|
| 22 |
+
console.log('Socket.io conectado')
|
| 23 |
+
})
|
| 24 |
+
|
| 25 |
+
socket.on('market_update', (data) => {
|
| 26 |
+
console.log('market_update', data)
|
| 27 |
+
})
|
| 28 |
+
|
| 29 |
+
socket.on('ai_signal', (data) => {
|
| 30 |
+
console.log('ai_signal', data)
|
| 31 |
+
})
|
| 32 |
+
|
| 33 |
+
socket.on('price_alert', (data) => {
|
| 34 |
+
console.log('price_alert', data)
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
// TODO: inicializar modulos y cargar datos iniciales
|
frontend/src/charts.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Módulo de gráficos de historial de precios.
|
| 3 |
+
*
|
| 4 |
+
* Tecnología: Chart.js
|
| 5 |
+
*
|
| 6 |
+
* Funciones:
|
| 7 |
+
* - Renderizar línea de precios YES/NO de un mercado seleccionado
|
| 8 |
+
* - Actualizar datos en tiempo real cuando llega 'market_update'
|
| 9 |
+
* - Opcional: mostrar punto de entrada de posiciones abiertas
|
| 10 |
+
*
|
| 11 |
+
* Se vincula al panel de detalle de mercado.
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
import { Chart } from 'chart.js/auto'
|
frontend/src/main.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import './style.css'
|
| 2 |
+
import './app.js'
|
frontend/src/map.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Módulo de visualización del mapa mundial interactivo.
|
| 3 |
+
*
|
| 4 |
+
* Tecnología: Leaflet.js
|
| 5 |
+
*
|
| 6 |
+
* Funciones:
|
| 7 |
+
* - Renderizar mapa base centrado en coordenadas por defecto
|
| 8 |
+
* - Dibujar burbujas (circle markers) por país usando countryCode (ISO2)
|
| 9 |
+
* - Color de burbuja según señal IA dominante (verde/amarillo/rojo)
|
| 10 |
+
* - Tamaño proporcional al volumen o liquidez del mercado
|
| 11 |
+
* - Popup al hacer click con detalle del mercado
|
| 12 |
+
*
|
| 13 |
+
* Recibe actualizaciones en tiempo real vía Socket.io desde app.js.
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
import L from 'leaflet'
|
| 17 |
+
import 'leaflet/dist/leaflet.css'
|
frontend/src/simulator.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Módulo de interfaz del simulador de posiciones.
|
| 3 |
+
*
|
| 4 |
+
* Funciones:
|
| 5 |
+
* - Mostrar formulario para abrir posición virtual (YES/NO, capital)
|
| 6 |
+
* - Solicitar fracción de Kelly desde services/kelly.js vía API
|
| 7 |
+
* - Renderizar lista de posiciones abiertas con P&L en vivo
|
| 8 |
+
* - Botón de cierre de posición y cálculo de resultado final
|
| 9 |
+
*
|
| 10 |
+
* Usa userId=1 fijo para la demo.
|
| 11 |
+
*/
|
frontend/src/style.css
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Estilos visuales del dashboard PolySignal.
|
| 3 |
+
*
|
| 4 |
+
* Incluye:
|
| 5 |
+
* - Layout principal y grid del dashboard
|
| 6 |
+
* - Estilos del mapa Leaflet y burbujas de mercado por país
|
| 7 |
+
* - Paneles de señales IA (bullish / bearish / neutral)
|
| 8 |
+
* - Componentes del simulador de posiciones y watchlist
|
| 9 |
+
* - Diseño responsive básico para hackathon
|
| 10 |
+
*
|
| 11 |
+
* Puro CSS vanilla, sin preprocesadores.
|
| 12 |
+
*/
|
frontend/vite.config.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { defineConfig } from 'vite'
|
| 2 |
+
|
| 3 |
+
export default defineConfig({
|
| 4 |
+
server: {
|
| 5 |
+
port: 5173,
|
| 6 |
+
proxy: {
|
| 7 |
+
'/api': {
|
| 8 |
+
target: 'http://localhost:7860',
|
| 9 |
+
changeOrigin: true,
|
| 10 |
+
},
|
| 11 |
+
'/socket.io': {
|
| 12 |
+
target: 'http://localhost:7860',
|
| 13 |
+
changeOrigin: true,
|
| 14 |
+
ws: true,
|
| 15 |
+
},
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
build: {
|
| 19 |
+
outDir: 'dist',
|
| 20 |
+
emptyOutDir: true,
|
| 21 |
+
},
|
| 22 |
+
})
|
package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "polysignal",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "Dashboard web de inteligencia de mercados de prediccion en tiempo real — Hackathon CIFO Barcelona La Violeta",
|
| 5 |
+
"private": true,
|
| 6 |
+
"workspaces": [
|
| 7 |
+
"backend",
|
| 8 |
+
"frontend"
|
| 9 |
+
],
|
| 10 |
+
"scripts": {
|
| 11 |
+
"start": "npm run start --workspace=backend",
|
| 12 |
+
"dev": "npm run dev --workspace=backend",
|
| 13 |
+
"dev:frontend": "npm run dev --workspace=frontend",
|
| 14 |
+
"dev:all": "concurrently \"npm run dev --workspace=backend\" \"npm run dev --workspace=frontend\"",
|
| 15 |
+
"build:frontend": "npm run build --workspace=frontend",
|
| 16 |
+
"preview:frontend": "npm run preview --workspace=frontend",
|
| 17 |
+
"db:migrate": "npm run db:migrate --workspace=backend",
|
| 18 |
+
"db:generate": "npm run db:generate --workspace=backend",
|
| 19 |
+
"db:studio": "npm run db:studio --workspace=backend"
|
| 20 |
+
},
|
| 21 |
+
"engines": {
|
| 22 |
+
"node": ">=22.0.0"
|
| 23 |
+
},
|
| 24 |
+
"keywords": [
|
| 25 |
+
"polymarket",
|
| 26 |
+
"prediction-markets",
|
| 27 |
+
"ai",
|
| 28 |
+
"hackathon"
|
| 29 |
+
],
|
| 30 |
+
"author": "Equipo PolySignal",
|
| 31 |
+
"license": "MIT",
|
| 32 |
+
"devDependencies": {
|
| 33 |
+
"concurrently": "^9.2.1"
|
| 34 |
+
}
|
| 35 |
+
}
|