fix: 定投队列触发判断周末和交易日

This commit is contained in:
hzm
2026-03-02 08:28:46 +08:00
parent 20e101bb65
commit 6a53479bd7

View File

@@ -1636,6 +1636,7 @@ export default function HomePage() {
}; };
const scheduleDcaTrades = useCallback(() => { const scheduleDcaTrades = useCallback(() => {
if (!isTradingDay) return;
if (!isPlainObject(dcaPlans)) return; if (!isPlainObject(dcaPlans)) return;
const codesSet = new Set(funds.map((f) => f.code)); const codesSet = new Set(funds.map((f) => f.code));
if (codesSet.size === 0) return; if (codesSet.size === 0) return;
@@ -1680,6 +1681,11 @@ export default function HomePage() {
if (current.isBefore(first, 'day')) continue; if (current.isBefore(first, 'day')) continue;
const dateStr = current.format('YYYY-MM-DD'); const dateStr = current.format('YYYY-MM-DD');
// 每日定投:跳过周末(周六、周日),只生成交易日
if (cycle === 'daily') {
const dayOfWeek = current.day(); // 0=周日, 6=周六
if (dayOfWeek === 0 || dayOfWeek === 6) continue;
}
const pending = { const pending = {
id: `dca_${code}_${dateStr}_${Date.now()}`, id: `dca_${code}_${dateStr}_${Date.now()}`,
@@ -1726,7 +1732,7 @@ export default function HomePage() {
}); });
showToast(`已生成 ${newPending.length} 笔定投买入`, 'success'); showToast(`已生成 ${newPending.length} 笔定投买入`, 'success');
}, [dcaPlans, funds, todayStr, storageHelper]); }, [isTradingDay, dcaPlans, funds, todayStr, storageHelper]);
useEffect(() => { useEffect(() => {
if (!isTradingDay) return; if (!isTradingDay) return;