가상수정2

This commit is contained in:
Macbook
2026-05-25 16:13:25 +09:00
parent 182b82e990
commit aac6454724
4 changed files with 76 additions and 47 deletions
@@ -11,6 +11,7 @@ import {
} from '../utils/backendApi';
import { formatIndicatorDisplayLabel } from '../utils/indicatorRegistry';
import {
coerceFiniteNumber,
extractVirtualConditions,
type VirtualConditionRow,
} from '../utils/virtualStrategyConditions';
@@ -42,13 +43,13 @@ function liveRowToVirtual(r: LiveConditionRowDto): VirtualConditionRow & { curre
displayName: formatIndicatorDisplayLabel(r.indicatorType),
conditionType: r.conditionType,
conditionLabel: r.conditionLabel,
targetValue: r.targetValue,
targetValue: coerceFiniteNumber(r.targetValue),
timeframe: r.timeframe,
side: r.side,
plotKey,
satisfied: r.satisfied,
thresholdLabel: r.thresholdLabel,
currentValue: r.currentValue,
currentValue: coerceFiniteNumber(r.currentValue),
};
}
@@ -76,8 +77,8 @@ function mergeRows(
...row,
satisfied: liveRow.satisfied,
thresholdLabel: liveRow.thresholdLabel,
currentValue: liveRow.currentValue,
targetValue: liveRow.targetValue ?? row.targetValue,
currentValue: coerceFiniteNumber(liveRow.currentValue),
targetValue: coerceFiniteNumber(liveRow.targetValue) ?? row.targetValue,
};
});
}
@@ -102,7 +103,12 @@ async function buildSnapshot(
};
}
const status = await fetchLiveConditionStatus(market, strategyId);
let status: Awaited<ReturnType<typeof fetchLiveConditionStatus>> = null;
try {
status = await fetchLiveConditionStatus(market, strategyId);
} catch {
status = null;
}
if (!status || status.market !== market || status.strategyId !== strategyId) {
if (baseRows.length === 0) return null;
return {
@@ -121,7 +127,7 @@ async function buildSnapshot(
timeframe: status.timeframe || [...new Set(baseRows.map(r => r.timeframe))].join(', '),
rows: mergeRows(baseRows, status.rows),
updatedAt: status.updatedAt || Date.now(),
matchRate: status.matchRate,
matchRate: coerceFiniteNumber(status.matchRate) ?? 0,
};
}