From 8f58caee016cc0da43b0b6d72a1a3361e670eae1 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Sat, 16 May 2026 21:11:37 +0200 Subject: [PATCH] feat: add SystemSettings component with Alpaca mode and raw settings --- app/components/SystemSettings.tsx | 91 +++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 app/components/SystemSettings.tsx diff --git a/app/components/SystemSettings.tsx b/app/components/SystemSettings.tsx new file mode 100644 index 0000000..cae46ba --- /dev/null +++ b/app/components/SystemSettings.tsx @@ -0,0 +1,91 @@ +import React, { useState, useEffect } from "react"; + +interface SystemSettingsProps { + settings: Record; + alpacaMode: string | null; + onSave: (key: string, value: any) => Promise; + saveError: string | null; +} + +const KNOWN_KEYS = new Set([ + "llm.model", "llm.temperature", "llm.maxDebateRounds", + "trading.maxLossPercent", "trading.positionSizePercent", + "trading.takeProfitPercent", "trading.stopLossPercent", "trading.riskMethod", +]); + +export default function SystemSettings({ settings, alpacaMode, onSave, saveError }: SystemSettingsProps) { + const [rawSettings, setRawSettings] = useState>([]); + + useEffect(() => { + const others = Object.entries(settings) + .filter(([key]) => !KNOWN_KEYS.has(key)) + .map(([key, value]) => ({ + key, + value: typeof value === "string" ? value : JSON.stringify(value, null, 2), + })); + setRawSettings(others); + }, [settings]); + + const handleRawSave = async (key: string, newValue: string) => { + try { + const parsed = JSON.parse(newValue); + await onSave(key, parsed); + } catch { + await onSave(key, newValue); + } + }; + + return ( +
+
+

System

+

System configuration and environment info.

+
+ + {saveError && ( +
{saveError}
+ )} + +
+
+

Alpaca Trading API

+
+ Mode: + + {alpacaMode === "live" ? "Live Trading" : "Paper Trading"} + +
+
+ + {rawSettings.length > 0 && ( +
+

Additional Settings

+
+ {rawSettings.map((setting) => ( +
+
{setting.key}
+