Spaces:
Running
Running
atualizacao automatica dos dados da CVM
Browse files- app.js +232 -271
- styles.css +4 -0
app.js
CHANGED
|
@@ -290,22 +290,15 @@ benchmark_diario: `select null::date dt, null::double cdi_dia,
|
|
| 290 |
cota_eventos: `select null::varchar cnpj, null::date dt,
|
| 291 |
null::float var_cota, null::float var_pl`,
|
| 292 |
};
|
| 293 |
-
function
|
| 294 |
-
const
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
+ (b.includes('cdi') ? ' O CDI é acumulado dia a dia desde 2000.' : '');
|
| 303 |
-
if (escopo === 'fundo') {
|
| 304 |
-
return 'Cota rebaseada a 100 no início do período para dividir o eixo com o ' +
|
| 305 |
-
'patrimônio: o que se lê é a variação, não o valor da cota.' + link + ref;
|
| 306 |
-
}
|
| 307 |
-
return 'Cota média ponderada pelo patrimônio de cada fundo, encadeada dia a dia: ' +
|
| 308 |
-
'não é a média das cotas.' + link + ref;
|
| 309 |
}
|
| 310 |
function telaEstreita() {
|
| 311 |
return window.innerWidth <= 560;
|
|
@@ -4990,18 +4983,21 @@ app.innerHTML = `
|
|
| 4990 |
cls(retJan[j]))).join('')}
|
| 4991 |
</div>` : ''}
|
| 4992 |
|
| 4993 |
-
<div class="
|
| 4994 |
-
|
| 4995 |
-
<
|
| 4996 |
-
|
| 4997 |
-
|
| 4998 |
-
|
| 4999 |
-
|
| 5000 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5001 |
</div>
|
| 5002 |
-
<div class="chart" id="chartGest"></div>
|
| 5003 |
-
<div class="nota-rodape">* ${notaCota('gestora')}</div>
|
| 5004 |
</div>
|
|
|
|
| 5005 |
|
| 5006 |
<div class="abas" id="abasG">
|
| 5007 |
<button data-p="pFundos" class="on">Fundos</button>
|
|
@@ -5033,10 +5029,8 @@ app.innerHTML = `
|
|
| 5033 |
${nVotos ? '<div class="painel" id="pVotos"></div>' : ''}
|
| 5034 |
${nProc ? '<div class="painel" id="pProc"></div>' : ''}
|
| 5035 |
${nCancel ? '<div class="painel" id="pCancel"></div>' : ''}`;
|
| 5036 |
-
ligarSeg('segSerie', v =>
|
| 5037 |
-
|
| 5038 |
-
document.querySelector('#segSerie button.on')?.dataset.v || faixa0));
|
| 5039 |
-
desenharSerieGestora(gid, faixa0);
|
| 5040 |
await (vida ? tabelaFundosDaVida(gid) : tabelaFundosDaGestora(gid));
|
| 5041 |
ligarAbas('abasG', {
|
| 5042 |
pLiq: () => blocoLiquidez('pLiq', null,
|
|
@@ -7871,135 +7865,6 @@ desenhar(Math.max(0, fim - n + 1), fim);
|
|
| 7871 |
aplicar(JANELAS_GRAF.at(-1)[0]);
|
| 7872 |
ligarSeg(`${elId}Seg`, aplicar);
|
| 7873 |
}
|
| 7874 |
-
function opcoesSerie({ eixo, usaMensal, principal, secundarias, porPeriodo,
|
| 7875 |
-
refs = [], apagadas = new Set() }) {
|
| 7876 |
-
const positivo = principal.dados.at(-1) >= 0;
|
| 7877 |
-
const corSec = ['#9b8fd1', '#d8a84a'];
|
| 7878 |
-
const nomeP = `${principal.nome} (esq.)`;
|
| 7879 |
-
const nomeS = secundarias.map(s => `${s.nome}${s.bruto ? ' (dir.)' : ''}`);
|
| 7880 |
-
const off = n => apagadas.has(n);
|
| 7881 |
-
const OP_OFF = .14, OP_OFF_AREA = .04;
|
| 7882 |
-
const corOff = '#63645c';
|
| 7883 |
-
const itemLegenda = n => (off(n)
|
| 7884 |
-
? { name: n, textStyle: { color: corOff },
|
| 7885 |
-
itemStyle: { opacity: .3 }, lineStyle: { opacity: .3 } }
|
| 7886 |
-
: { name: n });
|
| 7887 |
-
return {
|
| 7888 |
-
backgroundColor: 'transparent',
|
| 7889 |
-
grid: { left: 70, right: 74, top: 26, bottom: 34 },
|
| 7890 |
-
legend: {
|
| 7891 |
-
show: true, top: 0, right: 0, itemWidth: 18, itemHeight: 2, itemGap: 14,
|
| 7892 |
-
textStyle: { color: TEMA.tinta3, fontSize: 11 }, icon: 'rect',
|
| 7893 |
-
data: [nomeP, ...nomeS, ...refs.map(r => r.nome)].map(itemLegenda),
|
| 7894 |
-
selected: Object.fromEntries(
|
| 7895 |
-
[nomeP, ...nomeS, ...refs.map(r => r.nome)].map(n => [n, true])),
|
| 7896 |
-
},
|
| 7897 |
-
tooltip: {
|
| 7898 |
-
trigger: 'axis',
|
| 7899 |
-
backgroundColor: TEMA.branco, borderColor: TEMA.regua, borderWidth: 1,
|
| 7900 |
-
textStyle: { color: TEMA.tinta, fontSize: 12, fontFamily: TEMA.mono },
|
| 7901 |
-
extraCssText: 'box-shadow:0 6px 18px rgba(51,48,46,.14);border-radius:0',
|
| 7902 |
-
confine: true,
|
| 7903 |
-
formatter: p => {
|
| 7904 |
-
const i = p[0].dataIndex;
|
| 7905 |
-
const bola = c => `<span style="display:inline-block;width:8px;height:8px;`
|
| 7906 |
-
+ `border-radius:50%;background:${c};margin-right:6px;vertical-align:1px"></span>`;
|
| 7907 |
-
const corP = principal.dados.at(-1) >= 0 ? TEMA.teal : TEMA.claret;
|
| 7908 |
-
const estreito = telaEstreita();
|
| 7909 |
-
const lado = t => estreito ? '' : ` <span style="color:${TEMA.tinta3}">(${t})</span>`;
|
| 7910 |
-
const l = [`<b>${dataBR(eixo[i])}</b>`];
|
| 7911 |
-
if (!off(nomeP)) {
|
| 7912 |
-
l.push(`${bola(corP)}${principal.nome.replace(/ \(esq\.\)$/, '')}${lado('esq.')}: `
|
| 7913 |
-
+ `${brl(principal.dados[i])}`);
|
| 7914 |
-
if (porPeriodo) l.push(`${bola('transparent')}${usaMensal ? 'No mês' : 'No dia'}: ${brl(porPeriodo[i])}`);
|
| 7915 |
-
}
|
| 7916 |
-
secundarias.forEach((s, k) => {
|
| 7917 |
-
if (s.dados[i] == null || off(nomeS[k])) return;
|
| 7918 |
-
l.push(`${bola(corSec[k % corSec.length])}${s.nome}`
|
| 7919 |
-
+ (s.bruto
|
| 7920 |
-
? `${lado('dir.')}: ` + brl(s.bruto[i], { sinal: false })
|
| 7921 |
-
: `: ${nf(s.dados[i], 1)}`
|
| 7922 |
-
+ (estreito ? '' : ` <span style="color:${TEMA.tinta3}">(base 100)</span>`)));
|
| 7923 |
-
});
|
| 7924 |
-
(refs || []).forEach(r => {
|
| 7925 |
-
if (r.dados[i] == null || off(r.nome)) return;
|
| 7926 |
-
l.push(`${bola(r.cor)}${r.nome}: ${nf(r.dados[i], 1)}`);
|
| 7927 |
-
});
|
| 7928 |
-
return l.length > 1 ? l.join('<br>') : '';
|
| 7929 |
-
},
|
| 7930 |
-
},
|
| 7931 |
-
xAxis: {
|
| 7932 |
-
type: 'category', data: eixo, boundaryGap: false,
|
| 7933 |
-
axisLine: { lineStyle: { color: TEMA.regua } }, axisTick: { show: false },
|
| 7934 |
-
axisLabel: {
|
| 7935 |
-
color: TEMA.tinta3, fontSize: 11, fontFamily: TEMA.mono,
|
| 7936 |
-
formatter: v => (usaMensal ? v.slice(0, 7) : v.slice(8) + '/' + v.slice(5, 7)),
|
| 7937 |
-
},
|
| 7938 |
-
},
|
| 7939 |
-
yAxis: [
|
| 7940 |
-
{
|
| 7941 |
-
type: 'value', splitLine: { lineStyle: { color: TEMA.reguaFina } },
|
| 7942 |
-
axisLabel: {
|
| 7943 |
-
color: TEMA.tinta3, fontSize: 11, fontFamily: TEMA.mono,
|
| 7944 |
-
formatter: brlEixo,
|
| 7945 |
-
},
|
| 7946 |
-
},
|
| 7947 |
-
{
|
| 7948 |
-
type: 'value', position: 'right', scale: true, splitLine: { show: false },
|
| 7949 |
-
axisLabel: {
|
| 7950 |
-
color: TEMA.tinta3, fontSize: 10, fontFamily: TEMA.mono,
|
| 7951 |
-
formatter: brlEixo,
|
| 7952 |
-
},
|
| 7953 |
-
axisLine: { show: false }, axisTick: { show: false },
|
| 7954 |
-
},
|
| 7955 |
-
{
|
| 7956 |
-
type: 'value', scale: true, show: false, splitLine: { show: false },
|
| 7957 |
-
},
|
| 7958 |
-
],
|
| 7959 |
-
series: [
|
| 7960 |
-
{
|
| 7961 |
-
name: nomeP, type: 'line', data: principal.dados,
|
| 7962 |
-
color: positivo ? TEMA.teal : TEMA.claret,
|
| 7963 |
-
showSymbol: false, yAxisIndex: 0, z: off(nomeP) ? 0 : 3,
|
| 7964 |
-
lineStyle: { width: 1.8, opacity: off(nomeP) ? OP_OFF : 1 },
|
| 7965 |
-
areaStyle: { opacity: off(nomeP) ? OP_OFF_AREA : .16, origin: 0 },
|
| 7966 |
-
emphasis: { disabled: off(nomeP) },
|
| 7967 |
-
},
|
| 7968 |
-
...secundarias.map((s, i) => ({
|
| 7969 |
-
name: nomeS[i], type: 'line',
|
| 7970 |
-
data: s.bruto ?? s.dados,
|
| 7971 |
-
color: corSec[i % corSec.length],
|
| 7972 |
-
showSymbol: false, yAxisIndex: s.bruto ? 1 : 2, z: off(nomeS[i]) ? 0 : 2,
|
| 7973 |
-
lineStyle: { width: 1.6, opacity: off(nomeS[i]) ? OP_OFF : .7,
|
| 7974 |
-
type: i ? 'dashed' : 'solid' },
|
| 7975 |
-
itemStyle: { opacity: off(nomeS[i]) ? OP_OFF : .7 },
|
| 7976 |
-
emphasis: { disabled: true },
|
| 7977 |
-
})),
|
| 7978 |
-
...refs.map(r => ({
|
| 7979 |
-
name: r.nome, type: 'line', data: r.dados,
|
| 7980 |
-
color: r.cor, showSymbol: false, yAxisIndex: 2, z: off(r.nome) ? 0 : 1,
|
| 7981 |
-
lineStyle: { width: 1.2, type: 'dashed', opacity: off(r.nome) ? OP_OFF : .85 },
|
| 7982 |
-
itemStyle: { opacity: off(r.nome) ? OP_OFF : .85 },
|
| 7983 |
-
emphasis: { disabled: true },
|
| 7984 |
-
connectNulls: false,
|
| 7985 |
-
})),
|
| 7986 |
-
],
|
| 7987 |
-
};
|
| 7988 |
-
}
|
| 7989 |
-
function desenharSerie(ch, args) {
|
| 7990 |
-
ch.__serie = args;
|
| 7991 |
-
ch.__apagadas = ch.__apagadas || new Set();
|
| 7992 |
-
const pintar = () => ch.setOption(
|
| 7993 |
-
opcoesSerie({ ...ch.__serie, apagadas: ch.__apagadas }), { replaceMerge: ['series'] });
|
| 7994 |
-
pintar();
|
| 7995 |
-
if (ch.__legendaLigada) return;
|
| 7996 |
-
ch.__legendaLigada = true;
|
| 7997 |
-
ch.on('legendselectchanged', ev => {
|
| 7998 |
-
if (ch.__apagadas.has(ev.name)) ch.__apagadas.delete(ev.name);
|
| 7999 |
-
else ch.__apagadas.add(ev.name);
|
| 8000 |
-
pintar();
|
| 8001 |
-
});
|
| 8002 |
-
}
|
| 8003 |
const BENCH = {
|
| 8004 |
cdi: { rot: 'CDI', col: 'cdi_idx', cor: '#8d8c83' },
|
| 8005 |
ibov: { rot: 'Ibovespa', col: 'ibov', cor: '#4a6fa5' },
|
|
@@ -8008,8 +7873,7 @@ function benchLigados() {
|
|
| 8008 |
estado.bench = estado.bench || {};
|
| 8009 |
return Object.keys(BENCH).filter(k => estado.bench[k]);
|
| 8010 |
}
|
| 8011 |
-
async function referencias(eixo, usaMensal) {
|
| 8012 |
-
const quais = benchLigados();
|
| 8013 |
if (!quais.length || !eixo.length) return [];
|
| 8014 |
if (!(await colunas('benchmark_diario')).has('cdi_idx')) return [];
|
| 8015 |
const de = eixo[0].slice(0, 10), ate = eixo.at(-1).slice(0, 10);
|
|
@@ -8036,32 +7900,122 @@ dados: base ? brutos.map(v => (v == null ? null : (v / base) * 100)) : brutos,
|
|
| 8036 |
};
|
| 8037 |
}).filter(r => r.dados.some(v => v != null));
|
| 8038 |
}
|
| 8039 |
-
|
| 8040 |
-
|
| 8041 |
-
|
| 8042 |
-
|
| 8043 |
-
|
| 8044 |
-
|
| 8045 |
-
|
| 8046 |
-
|
| 8047 |
-
|
| 8048 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8049 |
}
|
| 8050 |
-
function
|
| 8051 |
-
|
| 8052 |
-
const
|
| 8053 |
-
|
| 8054 |
-
|
| 8055 |
-
|
| 8056 |
-
|
| 8057 |
-
|
| 8058 |
-
|
| 8059 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8060 |
}
|
| 8061 |
-
|
| 8062 |
-
|
| 8063 |
-
|
| 8064 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8065 |
const usaMensal = faixa === 'max';
|
| 8066 |
const serie = usaMensal ? 'serie_gestora_mensal' : 'serie_gestora_diaria';
|
| 8067 |
const corte = usaMensal
|
|
@@ -8084,29 +8038,21 @@ const dados = await q(`
|
|
| 8084 |
left join fx on fx.t = s.dt
|
| 8085 |
where s.grupo_id = ${gid} and s.dt >= ${corte}
|
| 8086 |
order by s.dt`);
|
| 8087 |
-
|
|
|
|
| 8088 |
if (!dados.length) {
|
| 8089 |
-
|
|
|
|
| 8090 |
return;
|
| 8091 |
}
|
| 8092 |
let acc = 0;
|
| 8093 |
const eixo = dados.map(r => r.d);
|
| 8094 |
-
const
|
| 8095 |
-
|
| 8096 |
-
|
| 8097 |
-
|
| 8098 |
-
|
| 8099 |
-
|
| 8100 |
-
eixo, usaMensal,
|
| 8101 |
-
principal: { nome: 'Captação líquida acumulada', dados: acumulado },
|
| 8102 |
-
secundarias: [
|
| 8103 |
-
{ nome: 'PL total', dados: plIdx, bruto: pl },
|
| 8104 |
-
{ nome: 'Cota média ponderada*', dados: cotaIdx },
|
| 8105 |
-
],
|
| 8106 |
-
porPeriodo: dados.map(r => r.net),
|
| 8107 |
-
refs,
|
| 8108 |
-
});
|
| 8109 |
-
new ResizeObserver(() => ch.resize()).observe(el);
|
| 8110 |
}
|
| 8111 |
async function tabelaFundosDaGestora(gid) {
|
| 8112 |
const linhas = await q(`
|
|
@@ -8292,25 +8238,36 @@ document.getElementById('app').innerHTML = `
|
|
| 8292 |
return card(JANELA_LABEL[j] || j, brl(r.net), 'captação líquida', cls(r.net));
|
| 8293 |
}).join('')}
|
| 8294 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8296 |
<div class="grid2">
|
| 8297 |
<div class="chart-box">
|
| 8298 |
-
<div class="chart-head">
|
| 8299 |
-
|
| 8300 |
-
${controleBench('benchFundo')}
|
| 8301 |
-
<div class="seg" id="segSerieF">
|
| 8302 |
-
${JANELAS_SERIE.map(([v, rot]) =>
|
| 8303 |
-
`<button data-v="${v}" class="${v === '24m' ? 'on' : ''}">${rot}</button>`).join('')}
|
| 8304 |
-
</div>
|
| 8305 |
-
</div>
|
| 8306 |
-
<div class="chart" id="chartFluxo"></div>
|
| 8307 |
</div>
|
| 8308 |
<div class="chart-box">
|
| 8309 |
-
<div class="chart-head"><span class="chart-title">
|
| 8310 |
-
<div class="chart" id="
|
| 8311 |
</div>
|
| 8312 |
</div>
|
| 8313 |
-
<div class="nota-rodape">
|
| 8314 |
<div id="fFechado"></div>
|
| 8315 |
|
| 8316 |
<div class="abas" id="abasF">
|
|
@@ -8370,23 +8327,36 @@ for (const r of await q(`select strftime(dt,'%Y-%m-%d') d, cota
|
|
| 8370 |
if (r.cota != null) cotaDia.set(r.d, Number(r.cota));
|
| 8371 |
}
|
| 8372 |
}
|
| 8373 |
-
const
|
| 8374 |
-
|
| 8375 |
-
async function
|
| 8376 |
-
if (!
|
| 8377 |
const usaMensal = faixa === 'max';
|
| 8378 |
-
const fonte = usaMensal ? mensal.filter(r => r.net != null) : diario;
|
| 8379 |
-
const vazio = msg => {
|
| 8380 |
-
if (gFluxo && !gFluxo.isDisposed()) gFluxo.dispose();
|
| 8381 |
-
gFluxo = null;
|
| 8382 |
-
elFluxo.innerHTML = `<div class="empty">${msg}</div>`;
|
| 8383 |
-
};
|
| 8384 |
const meses = { '3m': 3, '12m': 12, '24m': 24 }[faixa];
|
| 8385 |
const corte = meses == null ? null : (() => {
|
| 8386 |
const t = new Date(estado.meta.dt_referencia);
|
| 8387 |
t.setMonth(t.getMonth() - meses);
|
| 8388 |
return t.toISOString().slice(0, 10);
|
| 8389 |
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8390 |
let jan = corte ? fonte.filter(r => r.d >= corte) : fonte;
|
| 8391 |
let plMensal = null;
|
| 8392 |
if (!usaMensal && jan.length < 20 && cotaDia.size) {
|
|
@@ -8398,42 +8368,15 @@ jan = todos.map(dt => porDia.get(dt) || { d: dt, net: 0, pl: null });
|
|
| 8398 |
plMensal = alinhaMensal(todos, mensal, 'pl');
|
| 8399 |
}
|
| 8400 |
}
|
| 8401 |
-
if (!jan.length) {
|
| 8402 |
let acc = 0;
|
| 8403 |
-
const eixo = jan.map(r => r.d);
|
| 8404 |
const plD = usaMensal ? jan.map(r => r.pl)
|
| 8405 |
: jan.map((r, i) => r.pl ?? (plMensal ? plMensal[i] : null));
|
| 8406 |
-
|
| 8407 |
-
|
| 8408 |
-
: (cotaDia.size ? eixo.map(dt => cotaDia.get(dt) ?? null)
|
| 8409 |
-
: alinhaMensal(eixo, mensal, 'cota'));
|
| 8410 |
-
if (!gFluxo || gFluxo.isDisposed()) { elFluxo.innerHTML = ''; gFluxo = echarts.init(elFluxo); }
|
| 8411 |
-
const refs = await referencias(eixo, usaMensal);
|
| 8412 |
-
desenharSerie(gFluxo, {
|
| 8413 |
-
eixo, usaMensal,
|
| 8414 |
-
principal: { nome: 'Captação líquida acumulada', dados: jan.map(r => (acc += r.net)) },
|
| 8415 |
-
secundarias: [
|
| 8416 |
-
{ nome: 'PL', dados: base100(plD), bruto: plD },
|
| 8417 |
-
{ nome: 'Cota*', dados: base100(cotaD) },
|
| 8418 |
-
],
|
| 8419 |
-
porPeriodo: jan.map(r => r.net),
|
| 8420 |
-
refs,
|
| 8421 |
-
});
|
| 8422 |
-
}
|
| 8423 |
-
desenharFluxoFundo('24m');
|
| 8424 |
-
ligarSeg('segSerieF', desenharFluxoFundo);
|
| 8425 |
-
ligarBench('benchFundo', () => desenharFluxoFundo(
|
| 8426 |
-
document.querySelector('#segSerieF button.on')?.dataset.v || '24m'));
|
| 8427 |
-
const comPl = mensal.filter(r => r.pl != null);
|
| 8428 |
-
if (comPl.length) {
|
| 8429 |
-
desenharSerie(echarts.init(document.getElementById('chartPl')), {
|
| 8430 |
-
eixo: comPl.map(r => r.d), usaMensal: true,
|
| 8431 |
-
principal: { nome: 'Patrimônio líquido', dados: comPl.map(r => r.pl) },
|
| 8432 |
-
secundarias: [{ nome: 'Cota*', dados: base100(comPl.map(r => r.cota)) }],
|
| 8433 |
-
});
|
| 8434 |
-
} else {
|
| 8435 |
-
document.getElementById('chartPl').innerHTML = '<div class="empty">Sem dados.</div>';
|
| 8436 |
}
|
|
|
|
|
|
|
| 8437 |
const elFechado = document.getElementById('fFechado');
|
| 8438 |
if (elFechado && /^fechado/i.test(d.condominio || '')) {
|
| 8439 |
const ev = await q(`select strftime(dt, '%d/%m/%Y') d, var_cota, var_pl
|
|
@@ -11013,7 +10956,9 @@ series,
|
|
| 11013 |
function visualCartao(b) {
|
| 11014 |
const t = b._graf?.tipo;
|
| 11015 |
if (t === 'venn') return vennInsight(b, true);
|
| 11016 |
-
if (b._trancado) return
|
|
|
|
|
|
|
| 11017 |
if (t === 'halteres') return halteresInsight(b, { agg: true });
|
| 11018 |
if (t === 'iceberg') return icebergInsight(b, true, 0);
|
| 11019 |
if (t === 'regua') return reguaInsight(b, true);
|
|
@@ -11168,7 +11113,7 @@ if (b._trancado) {
|
|
| 11168 |
el.innerHTML = `
|
| 11169 |
<div class="painel-portao">
|
| 11170 |
<p><strong>${nf(b.n_total, 0)} ${Number(b.n_total) === 1 ? 'caso' : 'casos'}</strong>,
|
| 11171 |
-
com o nome
|
| 11172 |
<p class="conta-sub">Entre para ver. Os outros insights continuam abertos.</p>
|
| 11173 |
<a class="btn-conta" href="#/conta/insights">Entrar ou criar conta</a>
|
| 11174 |
</div>`;
|
|
@@ -11183,13 +11128,16 @@ tabelaInsight(el, b._cols, b._linhas);
|
|
| 11183 |
async function ligaSeries(b, id) {
|
| 11184 |
const ep = _epoca;
|
| 11185 |
let rows = [];
|
|
|
|
| 11186 |
try {
|
| 11187 |
rows = await q(`select pos, serie from insights_series where id = '${String(id).replace(/'/g, "''")}' order by pos`);
|
| 11188 |
} catch (e) { console.warn('insights_series:', e.message); }
|
|
|
|
| 11189 |
const sec = document.getElementById('insSerie');
|
| 11190 |
if (ep !== _epoca || !sec) return;
|
| 11191 |
const porSid = new Map();
|
| 11192 |
for (const r of rows) { try { porSid.set(String(r.pos), JSON.parse(r.serie)); } catch { } }
|
|
|
|
| 11193 |
const casos = b._linhas.filter(r => r.sid != null && porSid.has(String(r.sid)));
|
| 11194 |
if (!casos.length) { sec.remove(); return; }
|
| 11195 |
const cfg = b._graf.serie;
|
|
@@ -12407,12 +12355,15 @@ const HOME_PORTAS = [
|
|
| 12407 |
['conteudo', 'Conteúdo', 'Entrevistas e lives de gestores, transcritas e separadas por assunto e por ativo.', 'M5 5h14v10H9l-4 4z'],
|
| 12408 |
];
|
| 12409 |
const HOME_ACHADOS = [
|
| 12410 |
-
['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12411 |
['taxa_sem_cdi', 'cobram 1,5% ao ano ou mais e renderam menos de 80% do CDI em cinco anos.'],
|
| 12412 |
-
['
|
| 12413 |
-
['bom_e_resgatado', 'ficaram entre os 25% melhores da classe em três anos e mesmo assim perderam 30% do patrimônio em resgates.'],
|
| 12414 |
-
['mesmo_master_banco', 'chegam ao cliente por mais de um feeder do mesmo banco, e um deles cobra pelo menos 0,5 p.p. a menos.'],
|
| 12415 |
-
['auditoria', 'vivos tiveram ressalva, abstenção ou opinião adversa do auditor na última demonstração contábil.'],
|
| 12416 |
];
|
| 12417 |
async function pageInicio() {
|
| 12418 |
const app = document.getElementById('app');
|
|
@@ -12442,11 +12393,12 @@ homeDepois(ep);
|
|
| 12442 |
}
|
| 12443 |
async function homeDepois(ep) {
|
| 12444 |
const talvez = pr => pr.catch(e => { console.warn('pagina inicial:', e); return null; });
|
| 12445 |
-
const blocos = await talvez(q(`select id, tema, n_total, unidade
|
|
|
|
| 12446 |
if (!epocaAtual(ep)) return;
|
| 12447 |
const porId = new Map((blocos || []).map(b => [b.id, b]));
|
| 12448 |
const achados = HOME_ACHADOS.filter(([id]) => Number(porId.get(id)?.n_total) > 0)
|
| 12449 |
-
.map(([id, txt]) => ({ ...porId.get(id), txt }));
|
| 12450 |
homePoe('homeAchadosLugar', achados.length ? homeAchadosHtml(achados) : '', ep);
|
| 12451 |
const [conv, nConv, nCartas] = await Promise.all([
|
| 12452 |
talvez(q(`select v.video_id, v.titulo, v.publicado, v.n_temas, v.pessoa,
|
|
@@ -12585,19 +12537,27 @@ return `<div class="home-cartas"><div class="home-rail-rot">CARTAS RECENTES <a h
|
|
| 12585 |
${homeTrilhoHtml(cartas, homeCartaCard, true)}</div>`;
|
| 12586 |
}
|
| 12587 |
function homeAchadosHtml(achados) {
|
| 12588 |
-
const achado = (a, i) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12589 |
<span class="home-porta-luz" aria-hidden="true"></span>
|
| 12590 |
-
<span class="home-achado-tema">${esc(a.tema || '')}</span>
|
| 12591 |
-
<span class="home-achado-n">
|
| 12592 |
<span class="home-porta-d">${a.txt}</span>
|
| 12593 |
<span class="home-porta-ir">ver os casos <span aria-hidden="true">→</span></span></a>`;
|
|
|
|
| 12594 |
return `<section class="home-sec home-portas">
|
| 12595 |
<div class="home-camada home-camada-1" data-vel="0.25" aria-hidden="true"></div>
|
| 12596 |
<div class="home-camada home-camada-2" data-vel="0.5" aria-hidden="true"></div>
|
| 12597 |
<div class="home-sec-cab home-rev"><span class="home-num"></span><h2>O que a lâmina não mostra</h2>
|
| 12598 |
<p>Contas feitas sobre a carteira, a cota, a taxa e os documentos de todos os fundos.
|
| 12599 |
-
Cada cartão abre a lista de casos.</p></div>
|
| 12600 |
<div class="home-grade">${achados.map(achado).join('')}</div>
|
|
|
|
| 12601 |
</section>`;
|
| 12602 |
}
|
| 12603 |
function homeHtml(c) {
|
|
@@ -12700,7 +12660,8 @@ const contou = new WeakSet();
|
|
| 12700 |
const ioN = new IntersectionObserver(es => es.forEach(e => {
|
| 12701 |
if (e.isIntersecting && !contou.has(e.target)) { contou.add(e.target); homeConta(e.target); }
|
| 12702 |
}), { threshold: 0.4 });
|
| 12703 |
-
raiz.querySelectorAll('.home-stat b, .home-achado-n b, .home-vozes-nums b')
|
|
|
|
| 12704 |
const io = new IntersectionObserver(es => es.forEach(e => {
|
| 12705 |
if (e.isIntersecting) { e.target.classList.add('home-vis'); io.unobserve(e.target); }
|
| 12706 |
}), { threshold: 0.12 });
|
|
|
|
| 290 |
cota_eventos: `select null::varchar cnpj, null::date dt,
|
| 291 |
null::float var_cota, null::float var_pl`,
|
| 292 |
};
|
| 293 |
+
function notaGraficos(escopo) {
|
| 294 |
+
const cota = escopo === 'fundo'
|
| 295 |
+
? 'Retorno da cota do fundo, líquido de taxas e bruto de imposto'
|
| 296 |
+
: 'Retorno da cota média da casa, ponderada pelo patrimônio de cada fundo e encadeada dia a dia (não é a média das cotas)';
|
| 297 |
+
return `${cota}, contra o CDI e o <b>índice Ibovespa</b> (IPEADATA), todos a partir do início da janela.
|
| 298 |
+
No gráfico de dinheiro, as duas linhas partem de zero: o que coincide é dinheiro novo, e a
|
| 299 |
+
distância entre elas é o que o mercado fez com o patrimônio no período${escopo === 'fundo' ? ''
|
| 300 |
+
: ' — mais o patrimônio de fundos que chegaram de outras casas ou saíram para elas'}.
|
| 301 |
+
<a href="#/metodo">Como é calculado</a>.`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
}
|
| 303 |
function telaEstreita() {
|
| 304 |
return window.innerWidth <= 560;
|
|
|
|
| 4983 |
cls(retJan[j]))).join('')}
|
| 4984 |
</div>` : ''}
|
| 4985 |
|
| 4986 |
+
<div class="seg seg-graf" id="segSerie" aria-label="Janela dos gráficos">
|
| 4987 |
+
${JANELAS_SERIE.map(([v, rot]) =>
|
| 4988 |
+
`<button data-v="${v}" class="${v === faixa0 ? 'on' : ''}">${rot}</button>`).join('')}
|
| 4989 |
+
</div>
|
| 4990 |
+
<div class="grid2">
|
| 4991 |
+
<div class="chart-box">
|
| 4992 |
+
<div class="chart-head"><span class="chart-title">Retorno acumulado</span></div>
|
| 4993 |
+
<div class="chart" id="chartRetG"></div>
|
| 4994 |
+
</div>
|
| 4995 |
+
<div class="chart-box">
|
| 4996 |
+
<div class="chart-head"><span class="chart-title">Dinheiro novo × variação do patrimônio</span></div>
|
| 4997 |
+
<div class="chart" id="chartDinG"></div>
|
| 4998 |
</div>
|
|
|
|
|
|
|
| 4999 |
</div>
|
| 5000 |
+
<div class="nota-rodape">${notaGraficos('gestora')}</div>
|
| 5001 |
|
| 5002 |
<div class="abas" id="abasG">
|
| 5003 |
<button data-p="pFundos" class="on">Fundos</button>
|
|
|
|
| 5029 |
${nVotos ? '<div class="painel" id="pVotos"></div>' : ''}
|
| 5030 |
${nProc ? '<div class="painel" id="pProc"></div>' : ''}
|
| 5031 |
${nCancel ? '<div class="painel" id="pCancel"></div>' : ''}`;
|
| 5032 |
+
ligarSeg('segSerie', v => desenharGraficosGestora(gid, v));
|
| 5033 |
+
desenharGraficosGestora(gid, faixa0);
|
|
|
|
|
|
|
| 5034 |
await (vida ? tabelaFundosDaVida(gid) : tabelaFundosDaGestora(gid));
|
| 5035 |
ligarAbas('abasG', {
|
| 5036 |
pLiq: () => blocoLiquidez('pLiq', null,
|
|
|
|
| 7865 |
aplicar(JANELAS_GRAF.at(-1)[0]);
|
| 7866 |
ligarSeg(`${elId}Seg`, aplicar);
|
| 7867 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7868 |
const BENCH = {
|
| 7869 |
cdi: { rot: 'CDI', col: 'cdi_idx', cor: '#8d8c83' },
|
| 7870 |
ibov: { rot: 'Ibovespa', col: 'ibov', cor: '#4a6fa5' },
|
|
|
|
| 7873 |
estado.bench = estado.bench || {};
|
| 7874 |
return Object.keys(BENCH).filter(k => estado.bench[k]);
|
| 7875 |
}
|
| 7876 |
+
async function referencias(eixo, usaMensal, quais = benchLigados()) {
|
|
|
|
| 7877 |
if (!quais.length || !eixo.length) return [];
|
| 7878 |
if (!(await colunas('benchmark_diario')).has('cdi_idx')) return [];
|
| 7879 |
const de = eixo[0].slice(0, 10), ate = eixo.at(-1).slice(0, 10);
|
|
|
|
| 7900 |
};
|
| 7901 |
}).filter(r => r.dados.some(v => v != null));
|
| 7902 |
}
|
| 7903 |
+
const COR_RET = { fundo: TEMA.teal, cdi: '#8d8c83', ibov: '#6f93c9' };
|
| 7904 |
+
const rotuloData = (d, mensal) => (mensal ? mesAno(d) : dataBR(d));
|
| 7905 |
+
function opcoesRetorno({ eixo, usaMensal, cota, refs, nome }) {
|
| 7906 |
+
const pcs = v => (v == null ? '—'
|
| 7907 |
+
: `${v > 0 ? '+' : v < 0 ? '−' : ''}${nf(Math.abs(v) * 100, Math.abs(v) >= 1 ? 0 : 1)}%`);
|
| 7908 |
+
const linha = (n, dados, cor, extra = {}) => ({
|
| 7909 |
+
name: n, type: 'line', data: dados, showSymbol: false, connectNulls: true, color: cor,
|
| 7910 |
+
lineStyle: { width: extra.grossa ? 2.4 : 1.4, type: extra.grossa ? 'solid' : 'dashed', color: cor },
|
| 7911 |
+
endLabel: { show: true, formatter: p => pcs(p.value), color: cor, fontSize: 11, fontFamily: TEMA.mono },
|
| 7912 |
+
labelLayout: { moveOverlap: 'shiftY' },
|
| 7913 |
+
emphasis: { disabled: true }, z: extra.grossa ? 3 : 2,
|
| 7914 |
+
});
|
| 7915 |
+
const cdi = refs.find(r => r.nome === 'CDI');
|
| 7916 |
+
return {
|
| 7917 |
+
backgroundColor: 'transparent',
|
| 7918 |
+
grid: { left: 52, right: 76, top: 30, bottom: 30 },
|
| 7919 |
+
legend: { show: true, top: 0, left: 0, itemWidth: 16, itemHeight: 3, itemGap: 14, icon: 'rect',
|
| 7920 |
+
textStyle: { color: TEMA.tinta3, fontSize: 11 } },
|
| 7921 |
+
tooltip: {
|
| 7922 |
+
trigger: 'axis', confine: true, backgroundColor: TEMA.branco, borderColor: TEMA.regua,
|
| 7923 |
+
textStyle: { color: TEMA.tinta, fontSize: 12, fontFamily: TEMA.mono },
|
| 7924 |
+
formatter: ps => {
|
| 7925 |
+
const i = ps[0]?.dataIndex;
|
| 7926 |
+
if (i == null) return '';
|
| 7927 |
+
const l = [`<b>${rotuloData(eixo[i], usaMensal)}</b>`];
|
| 7928 |
+
for (const p of ps) l.push(`<span style="color:${p.color}">●</span> ${esc(p.seriesName)}: <b>${pcs(p.value)}</b>`);
|
| 7929 |
+
const c = cota[i], b = cdi?.dados[i];
|
| 7930 |
+
if (c != null && b != null) l.push(`<span style="color:${TEMA.tinta3}">contra o CDI:</span> ${c - b >= 0 ? '+' : '−'}${nf(Math.abs(c - b) * 100, 1)} p.p.`);
|
| 7931 |
+
return l.join('<br>');
|
| 7932 |
+
},
|
| 7933 |
+
},
|
| 7934 |
+
xAxis: { type: 'category', data: eixo, boundaryGap: false, axisTick: { show: false },
|
| 7935 |
+
axisLine: { lineStyle: { color: TEMA.regua } },
|
| 7936 |
+
axisLabel: { color: TEMA.tinta3, fontSize: 10, fontFamily: TEMA.mono,
|
| 7937 |
+
formatter: v => rotuloData(v, usaMensal) } },
|
| 7938 |
+
yAxis: { type: 'value', scale: true, splitLine: { lineStyle: { color: TEMA.reguaFina } },
|
| 7939 |
+
axisLabel: { color: TEMA.tinta3, fontSize: 10, fontFamily: TEMA.mono,
|
| 7940 |
+
formatter: v => `${nf(v * 100, 0)}%` } },
|
| 7941 |
+
series: [
|
| 7942 |
+
...refs.map(r => linha(r.nome, r.dados, r.nome === 'CDI' ? COR_RET.cdi : COR_RET.ibov)),
|
| 7943 |
+
linha(nome, cota, COR_RET.fundo, { grossa: true }),
|
| 7944 |
+
],
|
| 7945 |
+
};
|
| 7946 |
}
|
| 7947 |
+
function opcoesDinheiro({ eixo, usaMensal, pl, acc, nomePl,
|
| 7948 |
+
rotDif = 'diferença (rendimento)' }) {
|
| 7949 |
+
const p0 = pl.find(v => v != null);
|
| 7950 |
+
const dpl = pl.map(v => (v == null || p0 == null ? null : v - p0));
|
| 7951 |
+
const corAcc = (acc.at(-1) ?? 0) >= 0 ? TEMA.teal : TEMA.claret;
|
| 7952 |
+
return {
|
| 7953 |
+
backgroundColor: 'transparent',
|
| 7954 |
+
grid: { left: 64, right: 18, top: 30, bottom: 30 },
|
| 7955 |
+
legend: { show: true, top: 0, left: 0, itemWidth: 16, itemHeight: 3, itemGap: 14, icon: 'rect',
|
| 7956 |
+
textStyle: { color: TEMA.tinta3, fontSize: 11 } },
|
| 7957 |
+
tooltip: {
|
| 7958 |
+
trigger: 'axis', confine: true, backgroundColor: TEMA.branco, borderColor: TEMA.regua,
|
| 7959 |
+
textStyle: { color: TEMA.tinta, fontSize: 12, fontFamily: TEMA.mono },
|
| 7960 |
+
formatter: ps => {
|
| 7961 |
+
const i = ps[0]?.dataIndex;
|
| 7962 |
+
if (i == null) return '';
|
| 7963 |
+
const l = [`<b>${rotuloData(eixo[i], usaMensal)}</b>`];
|
| 7964 |
+
if (pl[i] != null) l.push(`<span style="color:${TEMA.tinta3}">${esc(nomePl)}:</span> ${brl(pl[i], { sinal: false })}`);
|
| 7965 |
+
l.push(`<span style="color:${TEMA.tinta}">●</span> Variação do patrimônio: <b>${brl(dpl[i])}</b>`);
|
| 7966 |
+
l.push(`<span style="color:${corAcc}">●</span> Captação líquida acumulada: <b>${brl(acc[i])}</b>`);
|
| 7967 |
+
if (dpl[i] != null && acc[i] != null) {
|
| 7968 |
+
l.push(`<span style="color:${TEMA.tinta3}">${esc(rotDif)}:</span> ${brl(dpl[i] - acc[i])}`);
|
| 7969 |
+
}
|
| 7970 |
+
return l.join('<br>');
|
| 7971 |
+
},
|
| 7972 |
+
},
|
| 7973 |
+
xAxis: { type: 'category', data: eixo, boundaryGap: false, axisTick: { show: false },
|
| 7974 |
+
axisLine: { lineStyle: { color: TEMA.regua } },
|
| 7975 |
+
axisLabel: { color: TEMA.tinta3, fontSize: 10, fontFamily: TEMA.mono,
|
| 7976 |
+
formatter: v => rotuloData(v, usaMensal) } },
|
| 7977 |
+
yAxis: { type: 'value', splitLine: { lineStyle: { color: TEMA.reguaFina } },
|
| 7978 |
+
axisLabel: { color: TEMA.tinta3, fontSize: 10, fontFamily: TEMA.mono,
|
| 7979 |
+
formatter: v => brlEixo(v) } },
|
| 7980 |
+
series: [
|
| 7981 |
+
{ name: 'Captação líquida acumulada', type: 'line', data: acc, showSymbol: false, color: corAcc,
|
| 7982 |
+
lineStyle: { width: 1.6, color: corAcc }, areaStyle: { opacity: .16, origin: 0, color: corAcc },
|
| 7983 |
+
emphasis: { disabled: true }, z: 2 },
|
| 7984 |
+
{ name: 'Variação do patrimônio', type: 'line', data: dpl, showSymbol: false, connectNulls: true,
|
| 7985 |
+
color: TEMA.tinta, lineStyle: { width: 2.2, color: TEMA.tinta }, emphasis: { disabled: true }, z: 3 },
|
| 7986 |
+
],
|
| 7987 |
+
};
|
| 7988 |
+
}
|
| 7989 |
+
function pintaGrafico(el, opcoes) {
|
| 7990 |
+
if (!el?.isConnected) return null;
|
| 7991 |
+
let g = echarts.getInstanceByDom(el);
|
| 7992 |
+
if (!g) {
|
| 7993 |
+
el.innerHTML = '';
|
| 7994 |
+
g = echarts.init(el, null, { renderer: 'canvas' });
|
| 7995 |
+
new ResizeObserver(() => g.resize()).observe(el);
|
| 7996 |
}
|
| 7997 |
+
g.setOption(opcoes, true);
|
| 7998 |
+
return g;
|
| 7999 |
+
}
|
| 8000 |
+
function graficoVazio(el, msg) {
|
| 8001 |
+
if (!el) return;
|
| 8002 |
+
echarts.getInstanceByDom(el)?.dispose();
|
| 8003 |
+
el.innerHTML = `<div class="empty">${msg}</div>`;
|
| 8004 |
+
}
|
| 8005 |
+
async function refsRetorno(eixo, usaMensal) {
|
| 8006 |
+
const rs = await referencias(eixo, usaMensal, ['cdi', 'ibov']);
|
| 8007 |
+
return rs.map(r => ({ ...r, dados: r.dados.map(v => (v == null ? null : v / 100 - 1)) }));
|
| 8008 |
+
}
|
| 8009 |
+
function retornoAcumulado(cotas) {
|
| 8010 |
+
const b = cotas.find(v => v != null && v > 0);
|
| 8011 |
+
return cotas.map(v => (v == null || !b || !(v > 0) ? null : v / b - 1));
|
| 8012 |
+
}
|
| 8013 |
+
async function desenharGraficosGestora(gid, faixa) {
|
| 8014 |
+
const elR = document.getElementById('chartRetG'), elD = document.getElementById('chartDinG');
|
| 8015 |
+
if (!elR || !elD) return;
|
| 8016 |
+
const vez = (desenharGraficosGestora.vez = (desenharGraficosGestora.vez || 0) + 1);
|
| 8017 |
+
const gs = [elR, elD].map(e => echarts.getInstanceByDom(e)).filter(Boolean);
|
| 8018 |
+
gs.forEach(g => g.showLoading('default', { text: '', maskColor: 'rgba(0,0,0,0)', color: '#4c9aff' }));
|
| 8019 |
const usaMensal = faixa === 'max';
|
| 8020 |
const serie = usaMensal ? 'serie_gestora_mensal' : 'serie_gestora_diaria';
|
| 8021 |
const corte = usaMensal
|
|
|
|
| 8038 |
left join fx on fx.t = s.dt
|
| 8039 |
where s.grupo_id = ${gid} and s.dt >= ${corte}
|
| 8040 |
order by s.dt`);
|
| 8041 |
+
if (!document.getElementById('chartRetG') || vez !== desenharGraficosGestora.vez) return;
|
| 8042 |
+
gs.forEach(g => g.hideLoading());
|
| 8043 |
if (!dados.length) {
|
| 8044 |
+
graficoVazio(elR, 'Sem dados no período.');
|
| 8045 |
+
graficoVazio(elD, 'Sem movimento no período.');
|
| 8046 |
return;
|
| 8047 |
}
|
| 8048 |
let acc = 0;
|
| 8049 |
const eixo = dados.map(r => r.d);
|
| 8050 |
+
const refs = await refsRetorno(eixo, usaMensal);
|
| 8051 |
+
pintaGrafico(elR, opcoesRetorno({ eixo, usaMensal, refs, nome: 'Cota média ponderada',
|
| 8052 |
+
cota: retornoAcumulado(dados.map(r => r.idx_cota)) }));
|
| 8053 |
+
pintaGrafico(elD, opcoesDinheiro({ eixo, usaMensal, nomePl: 'Patrimônio da casa',
|
| 8054 |
+
rotDif: 'diferença (rendimento e fundos que mudaram de casa)',
|
| 8055 |
+
pl: dados.map(r => r.pl_total), acc: dados.map(r => (acc += r.net)) }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8056 |
}
|
| 8057 |
async function tabelaFundosDaGestora(gid) {
|
| 8058 |
const linhas = await q(`
|
|
|
|
| 8238 |
return card(JANELA_LABEL[j] || j, brl(r.net), 'captação líquida', cls(r.net));
|
| 8239 |
}).join('')}
|
| 8240 |
</div>
|
| 8241 |
+
${(() => {
|
| 8242 |
+
|
| 8243 |
+
|
| 8244 |
+
|
| 8245 |
+
|
| 8246 |
+
const rs = estado.meta.janelas.map(j => {
|
| 8247 |
+
const r = porJ[j];
|
| 8248 |
+
return r && r.cota_ini > 0 && r.cota_fim > 0 && !r.amortizou ? r.cota_fim / r.cota_ini - 1 : null;
|
| 8249 |
+
});
|
| 8250 |
+
return rs.some(v => v != null) ? `<div class="cards cards-ret" title="Retorno da cota do fundo em cada janela, líquido de taxas e bruto de imposto.">
|
| 8251 |
+
${estado.meta.janelas.map((j, i) => card(JANELA_LABEL[j] || j, rs[i] == null ? '—' : pct(rs[i]),
|
| 8252 |
+
'retorno da cota', rs[i] == null ? '' : cls(rs[i]))).join('')}
|
| 8253 |
+
</div>` : '';
|
| 8254 |
+
})()}
|
| 8255 |
|
| 8256 |
+
<div class="seg seg-graf" id="segSerieF" aria-label="Janela dos gráficos">
|
| 8257 |
+
${JANELAS_SERIE.map(([v, rot]) =>
|
| 8258 |
+
`<button data-v="${v}" class="${v === '24m' ? 'on' : ''}">${rot}</button>`).join('')}
|
| 8259 |
+
</div>
|
| 8260 |
<div class="grid2">
|
| 8261 |
<div class="chart-box">
|
| 8262 |
+
<div class="chart-head"><span class="chart-title">Retorno acumulado</span></div>
|
| 8263 |
+
<div class="chart" id="chartRetF"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8264 |
</div>
|
| 8265 |
<div class="chart-box">
|
| 8266 |
+
<div class="chart-head"><span class="chart-title">Dinheiro novo × variação do patrimônio</span></div>
|
| 8267 |
+
<div class="chart" id="chartDinF"></div>
|
| 8268 |
</div>
|
| 8269 |
</div>
|
| 8270 |
+
<div class="nota-rodape">${notaGraficos('fundo')}</div>
|
| 8271 |
<div id="fFechado"></div>
|
| 8272 |
|
| 8273 |
<div class="abas" id="abasF">
|
|
|
|
| 8327 |
if (r.cota != null) cotaDia.set(r.d, Number(r.cota));
|
| 8328 |
}
|
| 8329 |
}
|
| 8330 |
+
const elRet = document.getElementById('chartRetF');
|
| 8331 |
+
const elDin = document.getElementById('chartDinF');
|
| 8332 |
+
async function desenharFundo(faixa) {
|
| 8333 |
+
if (!elRet?.isConnected) return;
|
| 8334 |
const usaMensal = faixa === 'max';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8335 |
const meses = { '3m': 3, '12m': 12, '24m': 24 }[faixa];
|
| 8336 |
const corte = meses == null ? null : (() => {
|
| 8337 |
const t = new Date(estado.meta.dt_referencia);
|
| 8338 |
t.setMonth(t.getMonth() - meses);
|
| 8339 |
return t.toISOString().slice(0, 10);
|
| 8340 |
})();
|
| 8341 |
+
let eixoR, cotaR;
|
| 8342 |
+
if (usaMensal || !cotaDia.size) {
|
| 8343 |
+
const m = mensal.filter(r => r.cota != null && (!corte || r.d >= corte));
|
| 8344 |
+
eixoR = m.map(r => r.d);
|
| 8345 |
+
cotaR = m.map(r => Number(r.cota));
|
| 8346 |
+
} else {
|
| 8347 |
+
eixoR = [...cotaDia.keys()].filter(dt => !corte || dt >= corte).sort();
|
| 8348 |
+
cotaR = eixoR.map(dt => cotaDia.get(dt));
|
| 8349 |
+
}
|
| 8350 |
+
const mensalR = usaMensal || !cotaDia.size;
|
| 8351 |
+
if (eixoR.length < 2) {
|
| 8352 |
+
graficoVazio(elRet, 'Sem cota no período.');
|
| 8353 |
+
} else {
|
| 8354 |
+
const refs = await refsRetorno(eixoR, mensalR);
|
| 8355 |
+
if (!elRet.isConnected) return;
|
| 8356 |
+
pintaGrafico(elRet, opcoesRetorno({ eixo: eixoR, usaMensal: mensalR, refs, nome: 'Fundo',
|
| 8357 |
+
cota: retornoAcumulado(cotaR) }));
|
| 8358 |
+
}
|
| 8359 |
+
const fonte = usaMensal ? mensal.filter(r => r.net != null) : diario;
|
| 8360 |
let jan = corte ? fonte.filter(r => r.d >= corte) : fonte;
|
| 8361 |
let plMensal = null;
|
| 8362 |
if (!usaMensal && jan.length < 20 && cotaDia.size) {
|
|
|
|
| 8368 |
plMensal = alinhaMensal(todos, mensal, 'pl');
|
| 8369 |
}
|
| 8370 |
}
|
| 8371 |
+
if (!jan.length) { graficoVazio(elDin, 'Sem movimento no período.'); return; }
|
| 8372 |
let acc = 0;
|
|
|
|
| 8373 |
const plD = usaMensal ? jan.map(r => r.pl)
|
| 8374 |
: jan.map((r, i) => r.pl ?? (plMensal ? plMensal[i] : null));
|
| 8375 |
+
pintaGrafico(elDin, opcoesDinheiro({ eixo: jan.map(r => r.d), usaMensal, nomePl: 'Patrimônio',
|
| 8376 |
+
pl: plD, acc: jan.map(r => (acc += r.net)) }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8377 |
}
|
| 8378 |
+
desenharFundo('24m');
|
| 8379 |
+
ligarSeg('segSerieF', desenharFundo);
|
| 8380 |
const elFechado = document.getElementById('fFechado');
|
| 8381 |
if (elFechado && /^fechado/i.test(d.condominio || '')) {
|
| 8382 |
const ev = await q(`select strftime(dt, '%d/%m/%Y') d, var_cota, var_pl
|
|
|
|
| 10956 |
function visualCartao(b) {
|
| 10957 |
const t = b._graf?.tipo;
|
| 10958 |
if (t === 'venn') return vennInsight(b, true);
|
| 10959 |
+
if (t === 'halteres' && b._trancado) return halteresInsight(b, { agg: true })
|
| 10960 |
+
+ '<div class="ins-card-trava"><span class="privada">Os casos ficam visíveis para quem tem conta</span></div>';
|
| 10961 |
+
if (b._trancado) return '<div class="ins-card-trava"><span class="privada">Os casos ficam visíveis para quem tem conta</span></div>';
|
| 10962 |
if (t === 'halteres') return halteresInsight(b, { agg: true });
|
| 10963 |
if (t === 'iceberg') return icebergInsight(b, true, 0);
|
| 10964 |
if (t === 'regua') return reguaInsight(b, true);
|
|
|
|
| 11113 |
el.innerHTML = `
|
| 11114 |
<div class="painel-portao">
|
| 11115 |
<p><strong>${nf(b.n_total, 0)} ${Number(b.n_total) === 1 ? 'caso' : 'casos'}</strong>,
|
| 11116 |
+
com o nome de cada fundo${b._graf?.serie ? ' e o gráfico de cada um' : ''}.</p>
|
| 11117 |
<p class="conta-sub">Entre para ver. Os outros insights continuam abertos.</p>
|
| 11118 |
<a class="btn-conta" href="#/conta/insights">Entrar ou criar conta</a>
|
| 11119 |
</div>`;
|
|
|
|
| 11128 |
async function ligaSeries(b, id) {
|
| 11129 |
const ep = _epoca;
|
| 11130 |
let rows = [];
|
| 11131 |
+
if (!b.privado) {
|
| 11132 |
try {
|
| 11133 |
rows = await q(`select pos, serie from insights_series where id = '${String(id).replace(/'/g, "''")}' order by pos`);
|
| 11134 |
} catch (e) { console.warn('insights_series:', e.message); }
|
| 11135 |
+
}
|
| 11136 |
const sec = document.getElementById('insSerie');
|
| 11137 |
if (ep !== _epoca || !sec) return;
|
| 11138 |
const porSid = new Map();
|
| 11139 |
for (const r of rows) { try { porSid.set(String(r.pos), JSON.parse(r.serie)); } catch { } }
|
| 11140 |
+
for (const r of b._linhas) if (b.privado && r.sid != null && r.serie) porSid.set(String(r.sid), r.serie);
|
| 11141 |
const casos = b._linhas.filter(r => r.sid != null && porSid.has(String(r.sid)));
|
| 11142 |
if (!casos.length) { sec.remove(); return; }
|
| 11143 |
const cfg = b._graf.serie;
|
|
|
|
| 12355 |
['conteudo', 'Conteúdo', 'Entrevistas e lives de gestores, transcritas e separadas por assunto e por ativo.', 'M5 5h14v10H9l-4 4z'],
|
| 12356 |
];
|
| 12357 |
const HOME_ACHADOS = [
|
| 12358 |
+
['rendeu_capital', 'na cota contra no capital dos cotistas: o dinheiro entrou no alto e saiu no baixo.'],
|
| 12359 |
+
['placar_acoes', 'fundos de ações bateu o Ibovespa em cinco anos, contando os que fecharam no caminho.'],
|
| 12360 |
+
['reserva', 'de cotistas em fundos DI que renderam menos de 90% do CDI em 12 meses.'],
|
| 12361 |
+
['cresceu_piorou', 'batiam o índice com folga enquanto pequenos e passaram ao médio depois que o dinheiro chegou.'],
|
| 12362 |
+
['esquecidos', 'de cotistas com saldo médio abaixo de R$ 500 e taxa de 1% ao ano ou mais.'],
|
| 12363 |
+
['pl_negativo', 'informam à CVM patrimônio abaixo de zero.'],
|
| 12364 |
+
['apuros_titulos', 'de crédito com sinal de problema passaram pelas carteiras em 12 meses.'],
|
| 12365 |
['taxa_sem_cdi', 'cobram 1,5% ao ano ou mais e renderam menos de 80% do CDI em cinco anos.'],
|
| 12366 |
+
['rf_negativa', 'de renda fixa perderam dinheiro em 12 meses: quando o juro sobe, o título longo cai.', 'fundos'],
|
|
|
|
|
|
|
|
|
|
| 12367 |
];
|
| 12368 |
async function pageInicio() {
|
| 12369 |
const app = document.getElementById('app');
|
|
|
|
| 12393 |
}
|
| 12394 |
async function homeDepois(ep) {
|
| 12395 |
const talvez = pr => pr.catch(e => { console.warn('pagina inicial:', e); return null; });
|
| 12396 |
+
const blocos = await talvez(q(`select id, tema, n_total, unidade, grafico, coalesce(privado, false) privado
|
| 12397 |
+
from insights_blocos`));
|
| 12398 |
if (!epocaAtual(ep)) return;
|
| 12399 |
const porId = new Map((blocos || []).map(b => [b.id, b]));
|
| 12400 |
const achados = HOME_ACHADOS.filter(([id]) => Number(porId.get(id)?.n_total) > 0)
|
| 12401 |
+
.map(([id, txt, u]) => ({ ...porId.get(id), txt, ...(u ? { unidade: u } : {}) }));
|
| 12402 |
homePoe('homeAchadosLugar', achados.length ? homeAchadosHtml(achados) : '', ep);
|
| 12403 |
const [conv, nConv, nCartas] = await Promise.all([
|
| 12404 |
talvez(q(`select v.video_id, v.titulo, v.publicado, v.n_temas, v.pessoa,
|
|
|
|
| 12537 |
${homeTrilhoHtml(cartas, homeCartaCard, true)}</div>`;
|
| 12538 |
}
|
| 12539 |
function homeAchadosHtml(achados) {
|
| 12540 |
+
const achado = (a, i) => {
|
| 12541 |
+
let g = null;
|
| 12542 |
+
try { g = a.grafico ? JSON.parse(a.grafico) : null; } catch { g = null; }
|
| 12543 |
+
const num = g?.heroi
|
| 12544 |
+
? `<b>${esc(g.heroi)}</b>`
|
| 12545 |
+
: `<b data-alvo="${Number(a.n_total) || 0}" data-fmt="n">0</b> ${esc(a.unidade || '')}`;
|
| 12546 |
+
return `<a class="home-porta home-achado home-rev" href="#/insights/${encodeURIComponent(a.id)}" style="--i:${i}">
|
| 12547 |
<span class="home-porta-luz" aria-hidden="true"></span>
|
| 12548 |
+
<span class="home-achado-tema${a.privado ? ' privada' : ''}"${a.privado ? ' title="a lista de casos exige conta"' : ''}>${esc(a.tema || '')}</span>
|
| 12549 |
+
<span class="home-achado-n">${num}</span>
|
| 12550 |
<span class="home-porta-d">${a.txt}</span>
|
| 12551 |
<span class="home-porta-ir">ver os casos <span aria-hidden="true">→</span></span></a>`;
|
| 12552 |
+
};
|
| 12553 |
return `<section class="home-sec home-portas">
|
| 12554 |
<div class="home-camada home-camada-1" data-vel="0.25" aria-hidden="true"></div>
|
| 12555 |
<div class="home-camada home-camada-2" data-vel="0.5" aria-hidden="true"></div>
|
| 12556 |
<div class="home-sec-cab home-rev"><span class="home-num"></span><h2>O que a lâmina não mostra</h2>
|
| 12557 |
<p>Contas feitas sobre a carteira, a cota, a taxa e os documentos de todos os fundos.
|
| 12558 |
+
Cada cartão abre a lista de casos; os do cadeado pedem conta.</p></div>
|
| 12559 |
<div class="home-grade">${achados.map(achado).join('')}</div>
|
| 12560 |
+
<p class="home-mais"><a href="#/insights">Todos os insights <span aria-hidden="true">→</span></a></p>
|
| 12561 |
</section>`;
|
| 12562 |
}
|
| 12563 |
function homeHtml(c) {
|
|
|
|
| 12660 |
const ioN = new IntersectionObserver(es => es.forEach(e => {
|
| 12661 |
if (e.isIntersecting && !contou.has(e.target)) { contou.add(e.target); homeConta(e.target); }
|
| 12662 |
}), { threshold: 0.4 });
|
| 12663 |
+
raiz.querySelectorAll('.home-stat b[data-alvo], .home-achado-n b[data-alvo], .home-vozes-nums b[data-alvo]')
|
| 12664 |
+
.forEach(el => ioN.observe(el));
|
| 12665 |
const io = new IntersectionObserver(es => es.forEach(e => {
|
| 12666 |
if (e.isIntersecting) { e.target.classList.add('home-vis'); io.unobserve(e.target); }
|
| 12667 |
}), { threshold: 0.12 });
|
styles.css
CHANGED
|
@@ -344,6 +344,7 @@ border-top: 1px solid var(--regua-forte); border-bottom: 1px solid var(--regua);
|
|
| 344 |
.card { padding: 12px 18px 13px; border-right: 1px solid var(--regua-fina); }
|
| 345 |
.cards.cards-par { margin-bottom: 0; border-bottom-color: var(--regua-fina); }
|
| 346 |
.cards.cards-ret { margin-top: 0; border-top: 0; }
|
|
|
|
| 347 |
@media (min-width: 1100px) {
|
| 348 |
.cards.cards-par, .cards.cards-ret { grid-template-columns: repeat(7, minmax(0, 1fr)); }
|
| 349 |
.cards-par .card, .cards-ret .card { padding-left: 12px; padding-right: 12px; }
|
|
@@ -2027,6 +2028,9 @@ border-top: 1px solid rgba(79,176,122,.18); border-bottom: 1px solid rgba(79,176
|
|
| 2027 |
.home-rev.home-vis { opacity: 1; animation: homeEntra .9s cubic-bezier(.2,.7,.2,1) backwards; animation-delay: calc(var(--i, 0) * 90ms); }
|
| 2028 |
@keyframes homeEntra { from { opacity: 0; transform: perspective(900px) translateY(46px) rotateX(22deg); } }
|
| 2029 |
.home-grade { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
|
|
|
|
|
|
|
|
|
|
| 2030 |
.home-porta {
|
| 2031 |
position: relative; display: grid; gap: 8px; padding: 26px 24px 22px; border-radius: 16px; overflow: hidden;
|
| 2032 |
color: var(--tinta); text-decoration: none; background: linear-gradient(160deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
|
|
|
|
| 344 |
.card { padding: 12px 18px 13px; border-right: 1px solid var(--regua-fina); }
|
| 345 |
.cards.cards-par { margin-bottom: 0; border-bottom-color: var(--regua-fina); }
|
| 346 |
.cards.cards-ret { margin-top: 0; border-top: 0; }
|
| 347 |
+
.seg.seg-graf { margin: 14px 0 6px; }
|
| 348 |
@media (min-width: 1100px) {
|
| 349 |
.cards.cards-par, .cards.cards-ret { grid-template-columns: repeat(7, minmax(0, 1fr)); }
|
| 350 |
.cards-par .card, .cards-ret .card { padding-left: 12px; padding-right: 12px; }
|
|
|
|
| 2028 |
.home-rev.home-vis { opacity: 1; animation: homeEntra .9s cubic-bezier(.2,.7,.2,1) backwards; animation-delay: calc(var(--i, 0) * 90ms); }
|
| 2029 |
@keyframes homeEntra { from { opacity: 0; transform: perspective(900px) translateY(46px) rotateX(22deg); } }
|
| 2030 |
.home-grade { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
|
| 2031 |
+
.home-mais { position: relative; z-index: 2; margin: 18px 0 0; font-size: 15px; }
|
| 2032 |
+
.home-mais a { color: var(--acento); text-decoration: none; }
|
| 2033 |
+
.home-mais a:hover { text-decoration: underline; }
|
| 2034 |
.home-porta {
|
| 2035 |
position: relative; display: grid; gap: 8px; padding: 26px 24px 22px; border-radius: 16px; overflow: hidden;
|
| 2036 |
color: var(--tinta); text-decoration: none; background: linear-gradient(160deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
|