trading-platform-database-v2/seeds/004_agent_configs.sql
rckrdmrd e520268348 Migración desde trading-platform/apps/database - Estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:32:52 -06:00

141 lines
6.1 KiB
PL/PgSQL

-- ============================================================================
-- SEED: Agent Configurations
-- DESCRIPTION: Configuracion inicial de Money Manager Agents por tenant
-- VERSION: 1.0.0
-- CREATED: 2026-01-10
-- NOTE: Este seed debe ejecutarse por tenant o con tenant_id especifico
-- ============================================================================
-- Funcion helper para crear configs de agentes para un tenant
CREATE OR REPLACE FUNCTION investment.seed_agent_configs(p_tenant_id UUID)
RETURNS VOID AS $$
BEGIN
-- Atlas - Conservador
INSERT INTO investment.agent_configs (
tenant_id, agent_type,
name, -- NUEVO
min_allocation, max_allocation_per_user, max_total_allocation,
platform_fee_rate, performance_fee_rate,
target_return_percent, max_drawdown_percent, -- NUEVOS
is_active, accepting_new_allocations,
description, risk_disclosure
) VALUES (
p_tenant_id,
'ATLAS',
'Atlas', -- NUEVO
100.00, -- Min $100
5000.00, -- Max $5,000 por usuario
500000.00, -- Max $500,000 total
0.05, -- 5% platform fee
0.15, -- 15% performance fee
8.00, -- NUEVO: 8% target return
10.00, -- NUEVO: 10% max drawdown
TRUE,
TRUE,
'Atlas es nuestro agente conservador diseñado para preservación de capital con crecimiento estable. ' ||
'Utiliza estrategias de bajo riesgo con drawdown máximo del 10%. Ideal para inversores que priorizan ' ||
'la seguridad sobre altos retornos.',
'ADVERTENCIA: El trading conlleva riesgos. Aunque Atlas utiliza estrategias conservadoras, ' ||
'existe la posibilidad de pérdidas. Los rendimientos pasados no garantizan resultados futuros. ' ||
'Solo invierta capital que pueda permitirse perder. Max drawdown esperado: 10%.'
)
ON CONFLICT (tenant_id, agent_type) DO UPDATE SET
name = EXCLUDED.name,
min_allocation = EXCLUDED.min_allocation,
max_allocation_per_user = EXCLUDED.max_allocation_per_user,
target_return_percent = EXCLUDED.target_return_percent,
max_drawdown_percent = EXCLUDED.max_drawdown_percent,
description = EXCLUDED.description,
updated_at = NOW();
-- Orion - Moderado
INSERT INTO investment.agent_configs (
tenant_id, agent_type,
name,
min_allocation, max_allocation_per_user, max_total_allocation,
platform_fee_rate, performance_fee_rate,
target_return_percent, max_drawdown_percent,
is_active, accepting_new_allocations,
description, risk_disclosure
) VALUES (
p_tenant_id,
'ORION',
'Orion',
250.00, -- Min $250
10000.00, -- Max $10,000 por usuario
1000000.00, -- Max $1,000,000 total
0.08, -- 8% platform fee
0.20, -- 20% performance fee
15.00, -- 15% target return
20.00, -- 20% max drawdown
TRUE,
TRUE,
'Orion es nuestro agente de riesgo moderado que balancea preservación de capital con oportunidades ' ||
'de crecimiento. Combina múltiples estrategias ML para optimizar el ratio riesgo/retorno. ' ||
'Recomendado para traders con experiencia intermedia.',
'ADVERTENCIA: Orion opera con riesgo moderado. Drawdown máximo esperado: 20%. ' ||
'Los resultados pueden variar significativamente según condiciones de mercado. ' ||
'Se recomienda un horizonte de inversión de al menos 3 meses.'
)
ON CONFLICT (tenant_id, agent_type) DO UPDATE SET
name = EXCLUDED.name,
min_allocation = EXCLUDED.min_allocation,
max_allocation_per_user = EXCLUDED.max_allocation_per_user,
target_return_percent = EXCLUDED.target_return_percent,
max_drawdown_percent = EXCLUDED.max_drawdown_percent,
description = EXCLUDED.description,
updated_at = NOW();
-- Nova - Agresivo
INSERT INTO investment.agent_configs (
tenant_id, agent_type,
name,
min_allocation, max_allocation_per_user, max_total_allocation,
platform_fee_rate, performance_fee_rate,
target_return_percent, max_drawdown_percent,
is_active, accepting_new_allocations,
description, risk_disclosure
) VALUES (
p_tenant_id,
'NOVA',
'Nova',
500.00, -- Min $500
25000.00, -- Max $25,000 por usuario
2000000.00, -- Max $2,000,000 total
0.10, -- 10% platform fee
0.25, -- 25% performance fee
25.00, -- 25% target return
35.00, -- 35% max drawdown
TRUE,
TRUE,
'Nova es nuestro agente de alto rendimiento diseñado para traders experimentados que buscan ' ||
'maximizar retornos. Utiliza estrategias agresivas incluyendo Strategy Ensemble y posiciones ' ||
'de mayor tamaño. Solo para inversores que comprenden y aceptan alto riesgo.',
'ALTO RIESGO: Nova opera con estrategias agresivas. Drawdown máximo esperado: 35%. ' ||
'Este agente puede experimentar pérdidas significativas en cortos periodos. ' ||
'SOLO PARA INVERSORES EXPERIMENTADOS que pueden tolerar alta volatilidad. ' ||
'No invierta más del 10% de su capital total en este agente.'
)
ON CONFLICT (tenant_id, agent_type) DO UPDATE SET
name = EXCLUDED.name,
min_allocation = EXCLUDED.min_allocation,
max_allocation_per_user = EXCLUDED.max_allocation_per_user,
target_return_percent = EXCLUDED.target_return_percent,
max_drawdown_percent = EXCLUDED.max_drawdown_percent,
description = EXCLUDED.description,
updated_at = NOW();
END;
$$ LANGUAGE plpgsql;
-- Comentario sobre uso
COMMENT ON FUNCTION investment.seed_agent_configs IS
'Ejecutar con: SELECT investment.seed_agent_configs(''your-tenant-uuid'');';
-- Para desarrollo/demo, crear config para tenant demo si existe
-- DO $$
-- DECLARE
-- v_demo_tenant_id UUID := '00000000-0000-0000-0000-000000000001';
-- BEGIN
-- PERFORM investment.seed_agent_configs(v_demo_tenant_id);
-- END $$;