mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-16 21:41:02 +00:00
Feat: Add live state API endpoint
This commit is contained in:
29
app/api/live-state/route.js
Normal file
29
app/api/live-state/route.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import fs from 'fs';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
const STATE_FILE = '/tmp/kalbot-live-state.json';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const raw = fs.readFileSync(STATE_FILE, 'utf-8');
|
||||
const data = JSON.parse(raw);
|
||||
return NextResponse.json(data);
|
||||
} catch (e) {
|
||||
return NextResponse.json({
|
||||
market: null,
|
||||
live: {
|
||||
balance: null, portfolioValue: null, totalPnL: 0,
|
||||
wins: 0, losses: 0, winRate: 0, totalTrades: 0,
|
||||
openOrders: [], paused: true, dailyLoss: 0,
|
||||
maxDailyLoss: 20, maxPerTrade: 5,
|
||||
enabledStrategies: [], positions: []
|
||||
},
|
||||
strategies: [],
|
||||
workerUptime: 0,
|
||||
lastUpdate: null,
|
||||
error: 'Worker not running or no data yet'
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user