feat: add USD/BRL and XAU/USD pipeline agents (Brief+Decio) with /api/usd/brief and /api/xau/brief routes
This commit is contained in:
@@ -29,12 +29,61 @@ function switchAsset(asset, btnEl) {
|
||||
if (titleEl) titleEl.textContent = asset.toUpperCase();
|
||||
|
||||
// Reload data for new asset
|
||||
loadAssetBrief();
|
||||
loadConfig();
|
||||
loadPortfolio();
|
||||
loadMultiStratChart('live');
|
||||
addLog('SYS', `Ativo alterado para ${ASSET_LABELS[asset]} (${ASSET_PAIRS[asset]})`);
|
||||
}
|
||||
|
||||
// ── Asset Brief Loader ───────────────────────────────────────────────────────
|
||||
function loadAssetBrief() {
|
||||
if (currentAsset === 'btc') {
|
||||
// BTC uses the existing pipeline via pollState
|
||||
pollState();
|
||||
return;
|
||||
}
|
||||
|
||||
const apiMap = {
|
||||
usd: '/api/usd/brief',
|
||||
xau: '/api/xau/brief'
|
||||
};
|
||||
|
||||
const api = apiMap[currentAsset];
|
||||
if (!api) return;
|
||||
|
||||
fetch(api)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
addLog('SYS', `Erro ao carregar ${ASSET_LABELS[currentAsset]}: ${data.error}`);
|
||||
return;
|
||||
}
|
||||
const brief = data.brief;
|
||||
const decio = data.decio;
|
||||
|
||||
// Update brief agent card
|
||||
const priceStr = brief.price
|
||||
? (brief.price > 1000 ? brief.price.toLocaleString('pt-BR', {minimumFractionDigits: 2}) : brief.price.toFixed(4))
|
||||
: '-';
|
||||
updateAgentUI('brief', {
|
||||
status: 'done',
|
||||
message: `${ASSET_PAIRS[currentAsset]}: ${priceStr}`
|
||||
});
|
||||
|
||||
// Update decio agent card
|
||||
updateAgentUI('decio', {
|
||||
status: 'done',
|
||||
message: `Decisão: ${decio.decision} (${decio.confidence}%)`
|
||||
});
|
||||
|
||||
addLog('SYS', `${ASSET_LABELS[currentAsset]} | ${decio.decision} | Conf: ${decio.confidence}%`);
|
||||
})
|
||||
.catch(err => {
|
||||
addLog('SYS', `Erro API ${currentAsset}: ${err.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
// ── Init ─────────────────────────────────────────────────────────────────────
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
updateClock();
|
||||
@@ -56,6 +105,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
loadPortfolio();
|
||||
loadActivityLog();
|
||||
updateStatus('Sistema operacional', 'online');
|
||||
// Load asset-specific data
|
||||
if (currentAsset === 'btc') {
|
||||
pollState();
|
||||
} else {
|
||||
loadAssetBrief();
|
||||
}
|
||||
});
|
||||
|
||||
// ── Clock ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user