Add configurable tick interval (time between trades)

- Seed tick_interval_seconds setting (default 60s)
- Expose tick_interval_seconds via GET/PATCH /api/settings
- startScheduler reads the setting at start time; enforces 5s minimum
- getSchedulerStatus returns intervalSeconds for the UI
- Main page: "Every [__] s" input in idle bar — saves on blur, persists across
  restarts; running state displays "every Ns" next to symbol/action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Senofy
2026-03-12 03:42:54 -05:00
co-authored by Claude Sonnet 4.6
parent 39d7c5761c
commit 245a15666e
4 changed files with 39 additions and 5 deletions
+4 -2
View File
@@ -336,8 +336,9 @@ export function startScheduler(action: 'Buy' | 'Sell' | 'Random', symbol: string
}
};
state.intervalId = setInterval(tick, 60_000);
console.log(`[scheduler] started — ${action} ${symbol} every 60s`);
const intervalSecs = Math.max(5, parseInt(getSetting('tick_interval_seconds') ?? '60', 10));
state.intervalId = setInterval(tick, intervalSecs * 1_000);
console.log(`[scheduler] started — ${action} ${symbol} every ${intervalSecs}s`);
}
export function stopScheduler() {
@@ -357,5 +358,6 @@ export function getSchedulerStatus() {
action: state.action,
symbol: state.symbol,
lastRun: state.lastRun,
intervalSeconds: parseInt(getSetting('tick_interval_seconds') ?? '60', 10),
};
}
+1
View File
@@ -161,6 +161,7 @@ db.exec(`
// Seed defaults if missing
const seedSetting = db.prepare(`INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)`);
seedSetting.run('max_concurrent_accounts', '5');
seedSetting.run('tick_interval_seconds', '60');
export function getSetting(key: string): string | null {
const row = db.prepare('SELECT value FROM settings WHERE key = ?').get(key) as { value: string } | undefined;