- FastAPI backend with PostgreSQL database connection - Frontend dashboard with lightweight-charts - Technical indicators (SMA, EMA, RSI, MACD, Bollinger Bands, etc.) - Trading strategy simulation and backtesting - Database connection to NAS at 20.20.20.20:5433 - Development server setup and documentation
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
export const SimulationStorage = {
|
|
STORAGE_KEY: 'btc_bot_simulations',
|
|
|
|
getAll() {
|
|
try {
|
|
const data = localStorage.getItem(this.STORAGE_KEY);
|
|
return data ? JSON.parse(data) : [];
|
|
} catch (e) {
|
|
console.error('Error reading simulations:', e);
|
|
return [];
|
|
}
|
|
},
|
|
|
|
save(simulation) {
|
|
try {
|
|
const simulations = this.getAll();
|
|
simulation.id = simulation.id || 'sim_' + Date.now();
|
|
simulation.createdAt = new Date().toISOString();
|
|
simulations.push(simulation);
|
|
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(simulations));
|
|
return simulation.id;
|
|
} catch (e) {
|
|
console.error('Error saving simulation:', e);
|
|
return null;
|
|
}
|
|
},
|
|
|
|
delete(id) {
|
|
try {
|
|
let simulations = this.getAll();
|
|
simulations = simulations.filter(s => s.id !== id);
|
|
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(simulations));
|
|
return true;
|
|
} catch (e) {
|
|
console.error('Error deleting simulation:', e);
|
|
return false;
|
|
}
|
|
},
|
|
|
|
get(id) {
|
|
return this.getAll().find(s => s.id === id);
|
|
},
|
|
|
|
clear() {
|
|
localStorage.removeItem(this.STORAGE_KEY);
|
|
}
|
|
};
|