feat: klines-based simulation instead of polling

- Fetch historical klines once from AVE API (10 CU per request)
- Process each candle as a time step
- Limit to 500 candles max per simulation
- No continuous polling - processes all data in seconds
- Frontend now selects kline interval (1m, 5m, 15m, 1h)
- Much more efficient API usage
This commit is contained in:
shokollm
2026-04-12 01:34:20 +00:00
parent d4400f5dcd
commit f425ae08d7
5 changed files with 135 additions and 66 deletions

View File

@@ -189,7 +189,7 @@ export const api = {
},
simulate: {
async start(botId: string, config: { token: string; chain?: string; check_interval: number }): Promise<Simulation> {
async start(botId: string, config: { token: string; chain?: string; kline_interval: string }): Promise<Simulation> {
const response = await fetch(`${API_URL}/bots/${botId}/simulate`, {
method: 'POST',
headers: getAuthHeaders(),

View File

@@ -9,7 +9,7 @@
let botId = $derived($page.params.id);
let tokenName = $state('');
let tokenAddress = $state('');
let intervalSeconds = $state(60);
let klineInterval = $state('1m');
let isRunning = $state(false);
onMount(async () => {
@@ -70,7 +70,7 @@
const simulation = await api.simulate.start(botId, {
token: tokenAddress,
chain: 'bsc',
check_interval: intervalSeconds
kline_interval: klineInterval
});
setCurrentSimulation(simulation);
clearSignals();
@@ -132,11 +132,12 @@
</div>
</div>
<div class="field">
<label for="interval">Check Interval</label>
<select id="interval" bind:value={intervalSeconds} disabled={isRunning}>
<option value={10}>Every 10 seconds</option>
<option value={30}>Every 30 seconds</option>
<option value={60}>Every minute</option>
<label for="klineInterval">Kline Interval</label>
<select id="klineInterval" bind:value={klineInterval} disabled={isRunning}>
<option value="1m">1 minute</option>
<option value="5m">5 minutes</option>
<option value="15m">15 minutes</option>
<option value="1h">1 hour</option>
</select>
</div>
</div>