feat(ui): implement modern tabbed trading dashboard redesign

- Introduce GlobalStatusBar with 4 real-time engine badges (LLM, RAG, OAuth, WebSocket), market operation status chip, and single-stock budget badge
- Redesign Real-time Decision Stream (42% width) with search, filter chips, dropzone, and modern card view with quick-sell action
- Structure TradeConfigPanel (58% width) into 4 dedicated tabs (Risk & Trading, 5-Tier Grade Policies, Watering & Morning Sell, Schedule & Filters) with card-based layouts
- Verified build and compilation successfully
This commit is contained in:
2026-11-17 15:40:34 +09:00
parent 0b6b8da1a5
commit 4253d19d15
4 changed files with 1560 additions and 684 deletions
Vendored Executable
+251
View File
@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+94
View File
@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+513 -105
View File
@@ -1,5 +1,6 @@
package ui package ui
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
@@ -7,14 +8,19 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Search
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@@ -26,9 +32,12 @@ import network.NewsService
import service.AutoTradingManager import service.AutoTradingManager
import ui.component.CsvDropZone import ui.component.CsvDropZone
import ui.component.FilterChipWithRightClick import ui.component.FilterChipWithRightClick
import ui.component.StatusIndicator
import ui.panel.TradeConfigPanel import ui.panel.TradeConfigPanel
import ui.store.TradingLogStore import ui.store.TradingLogStore
import java.text.NumberFormat
import java.time.LocalTime
import java.time.ZoneId
import java.util.Locale
@OptIn(ExperimentalMaterialApi::class) @OptIn(ExperimentalMaterialApi::class)
@Composable @Composable
@@ -38,88 +47,192 @@ fun TradingDecisionLog() {
var searchQuery by remember { mutableStateOf("") } var searchQuery by remember { mutableStateOf("") }
var selectedFilters by remember { mutableStateOf(setOf("전체")) } var selectedFilters by remember { mutableStateOf(setOf("전체")) }
val filterOptions = listOf("전체", "BUY", "SELL", "SETTING", "ANALYZER", "WATCH", "AFTER", "NOTICE") val filterOptions = listOf("전체", "BUY", "SELL", "SETTING", "ANALYZER", "WATCH", "AFTER", "NOTICE")
var llmAnalyser by remember { mutableStateOf(AutoTradingManager.llmAnalyser) } var llmAnalyser by remember { mutableStateOf(AutoTradingManager.llmAnalyser) }
LaunchedEffect(AutoTradingManager.llmAnalyser) {
llmAnalyser = AutoTradingManager.llmAnalyser
}
var llmNews by remember { mutableStateOf(AutoTradingManager.llmNews) }
LaunchedEffect(AutoTradingManager.llmNews) {
llmNews = AutoTradingManager.llmNews
}
var tradeToken by remember { mutableStateOf(AutoTradingManager.tradeToken) }
LaunchedEffect(AutoTradingManager.tradeToken) {
tradeToken = AutoTradingManager.tradeToken
}
var webSocketConnect by remember { mutableStateOf(AutoTradingManager.webSocketConnect) }
LaunchedEffect(AutoTradingManager.webSocketConnect) {
webSocketConnect = AutoTradingManager.webSocketConnect
}
val tradeConfig by remember { val tradeConfig by remember {
CoroutineScope(Dispatchers.Default).launch { CoroutineScope(Dispatchers.Default).launch {
val now = java.time.LocalTime.now(java.time.ZoneId.of("Asia/Seoul")) val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
NewsService.sendTelegramMessage("⏰ 자동 실행 시간(${now.hour}:${now.minute})입니다. 시스템을 가동합니다.") NewsService.sendTelegramMessage("⏰ 자동 실행 시간(${now.hour}:${now.minute})입니다. 시스템을 가동합니다.")
} }
mutableStateOf(KisSession.tradeConfig) mutableStateOf(KisSession.tradeConfig)
} }
LaunchedEffect(AutoTradingManager.llmAnalyser) {
llmAnalyser = AutoTradingManager.llmAnalyser
}
var llmNews by remember { mutableStateOf(AutoTradingManager.llmNews) }
LaunchedEffect(AutoTradingManager.llmNews) {
llmNews = AutoTradingManager.llmNews
}
var tradeToken by remember { mutableStateOf(AutoTradingManager.tradeToken) }
LaunchedEffect(AutoTradingManager.tradeToken) {
tradeToken = AutoTradingManager.tradeToken
}
var webSocketConnect by remember { mutableStateOf(AutoTradingManager.webSocketConnect) }
LaunchedEffect(AutoTradingManager.webSocketConnect) {
webSocketConnect = AutoTradingManager.webSocketConnect
}
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
// [핵심] 원본 로그에서 필터 조건에 맞는 리스트만 산출 // 원본 로그에서 필터 조건에 맞는 리스트 산출
val filteredLogs = TradingLogStore.decisionLogs.filter { log -> val filteredLogs = TradingLogStore.decisionLogs.filter { log ->
val matchesType = if (selectedFilters.contains("전체")) { val matchesType = if (selectedFilters.contains("전체")) {
true true
} else { } else {
selectedFilters.contains(log.decision) selectedFilters.contains(log.decision)
} }
val matchesQuery = log.stockName.contains(searchQuery, ignoreCase = true) || val matchesQuery = searchQuery.isBlank() ||
log.stockName.contains(searchQuery, ignoreCase = true) ||
log.reason.contains(searchQuery, ignoreCase = true) log.reason.contains(searchQuery, ignoreCase = true)
matchesType && matchesQuery matchesType && matchesQuery
} }
Row(modifier = Modifier.fillMaxSize().background(Color(0xFFF2F2F2))) {
// --- 좌측: 실시간 AI 자동매매 의사결정 로그 뷰어 (가중치 1f) ---
Column( Column(
modifier = Modifier modifier = Modifier
.weight(1f) .fillMaxSize()
.padding(8.dp) .background(Color(0xFFF1F5F9))
.fillMaxHeight()
.background(Color.White)
) { ) {
Button( // ==========================================
// 1. 최상단: 모던 글로벌 헤더 & 시스템 상태 바
// ==========================================
GlobalStatusBar(
llmAnalyser = llmAnalyser,
llmNews = llmNews,
tradeToken = tradeToken,
webSocketConnect = webSocketConnect,
maxBudget = KisSession.config.MAX_BUDGET
)
Divider(color = Color(0xFFE2E8F0), thickness = 1.dp)
// ==========================================
// 2. 메인 워크스페이스 (좌: 의사결정 로그 42% | 우: 전략 설정 패널 58%)
// ==========================================
Row(
modifier = Modifier
.fillMaxSize()
.padding(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
// --- 좌측: 실시간 의사결정 로그 스트림 (42%) ---
Card(
modifier = Modifier
.weight(0.42f)
.fillMaxHeight(),
shape = RoundedCornerShape(10.dp),
elevation = 2.dp,
backgroundColor = Color.White
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(12.dp)
) {
// 좌측 패널 헤더
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
Text("📡", fontSize = 16.sp)
Text(
"실시간 의사결정 스트림",
fontWeight = FontWeight.Bold,
fontSize = 14.sp,
color = Color(0xFF1E293B)
)
Surface(
shape = RoundedCornerShape(10.dp),
color = Color(0xFFEEF2FF)
) {
Text(
"${filteredLogs.size}건",
fontSize = 11.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF4F46E5),
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
}
// 최신 로그 바로가기 버튼
OutlinedButton(
onClick = { onClick = {
coroutineScope.launch { coroutineScope.launch {
if (filteredLogs.isNotEmpty()) { if (filteredLogs.isNotEmpty()) {
listState.animateScrollToItem(filteredLogs.size - 1) listState.animateScrollToItem(filteredLogs.size - 1)
} }
} }
} },
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 4.dp),
modifier = Modifier.height(28.dp),
shape = RoundedCornerShape(6.dp),
border = BorderStroke(1.dp, Color(0xFFCBD5E1))
) { ) {
Text("AI 자동매매 실시간 로그", style = MaterialTheme.typography.h6) Icon(
} Icons.Default.ArrowDownward,
contentDescription = "Scroll to Bottom",
Row( modifier = Modifier.size(13.dp),
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp), tint = Color(0xFF64748B)
horizontalArrangement = Arrangement.Start
) {
StatusIndicator("주식 분석기", llmAnalyser)
StatusIndicator("뉴스 처리기", llmNews)
StatusIndicator("한투 인증서", tradeToken)
StatusIndicator("실시간 감시", webSocketConnect)
}
// 상단 검색 및 필터 UI
Column(modifier = Modifier.padding(vertical = 8.dp)) {
OutlinedTextField(
value = searchQuery,
onValueChange = { searchQuery = it },
label = { Text("종목명 또는 내용 검색") },
modifier = Modifier.fillMaxWidth(),
leadingIcon = { Icon(Icons.Default.Search, contentDescription = null) },
singleLine = true
) )
Spacer(Modifier.width(3.dp))
Text("최신순", fontSize = 11.sp, color = Color(0xFF64748B))
}
}
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
// 검색창
OutlinedTextField(
value = searchQuery,
onValueChange = { searchQuery = it },
placeholder = { Text("종목명 또는 사유 검색...", fontSize = 12.sp, color = Color(0xFF94A3B8)) },
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
leadingIcon = {
Icon(
Icons.Default.Search,
contentDescription = null,
modifier = Modifier.size(18.dp),
tint = Color(0xFF94A3B8)
)
},
trailingIcon = {
if (searchQuery.isNotEmpty()) {
IconButton(
onClick = { searchQuery = "" },
modifier = Modifier.size(24.dp)
) {
Icon(
Icons.Default.Close,
contentDescription = "Clear",
modifier = Modifier.size(16.dp),
tint = Color(0xFF94A3B8)
)
}
}
},
singleLine = true,
shape = RoundedCornerShape(8.dp),
colors = TextFieldDefaults.outlinedTextFieldColors(
backgroundColor = Color(0xFFF8FAFC),
focusedBorderColor = Color(0xFF4F46E5),
unfocusedBorderColor = Color(0xFFE2E8F0)
)
)
Spacer(modifier = Modifier.height(6.dp))
// 필터 칩 영역 (가로 스크롤)
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@@ -168,10 +281,10 @@ fun TradingDecisionLog() {
) )
} }
} }
}
Divider(Modifier.padding(bottom = 8.dp)) Spacer(modifier = Modifier.height(6.dp))
// CSV 유니버스 로더 드롭존
CsvDropZone( CsvDropZone(
onUniverseUpdated = { updatedList -> onUniverseUpdated = { updatedList ->
AutoTradingManager.loadedTops.clear() AutoTradingManager.loadedTops.clear()
@@ -180,56 +293,37 @@ fun TradingDecisionLog() {
} }
) )
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(6.dp))
Divider(color = Color(0xFFF1F5F9))
Spacer(modifier = Modifier.height(4.dp))
LazyColumn( // 로그 리스트 스트림
state = listState, if (filteredLogs.isEmpty()) {
reverseLayout = true Box(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
contentAlignment = Alignment.Center
) { ) {
items(filteredLogs) { log ->
Card(
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp),
elevation = 2.dp
) {
Column(modifier = Modifier.padding(12.dp)) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
) {
Text("${log.time} - ${log.stockName}", fontWeight = FontWeight.Bold)
Text( Text(
text = log.decision, "수신된 의사결정 로그가 없습니다.",
color = when (log.decision) { fontSize = 12.sp,
"BUY" -> Color.Red color = Color(0xFF94A3B8)
"SETTING" -> Color(0xFFFFA500)
"SELL" -> Color(0xFF800080)
"HOLD" -> Color.DarkGray
"ANALYZER" -> Color.Green
"PASS" -> Color.Yellow
"RETRY" -> Color(0xFF00BCD4)
"WATCH" -> Color(0xFF4CAF50)
"AFTER" -> Color.Red
"NOTICE" -> Color(0xFF1E88E5)
else -> Color.DarkGray
},
fontWeight = FontWeight.ExtraBold
) )
} }
when (log.decision) { } else {
"BUY", "SELL", "HOLD" -> Text("신뢰도: ${log.confidence}%", fontSize = 11.sp) LazyColumn(
} state = listState,
reverseLayout = true,
Text("이유: ${log.reason}", fontSize = 12.sp, color = Color.DarkGray) modifier = Modifier.fillMaxSize(),
if (log.decision.contains("NOTICE") && log.reason.contains("[손절 경고]")) { verticalArrangement = Arrangement.spacedBy(6.dp)
Button( ) {
onClick = { items(filteredLogs) { log ->
val stockCode = log.stockName.substringAfter("[").substringBefore("]") DecisionLogCard(log = log, onManualSell = { code, qty ->
if (stockCode.length == 6) {
log.stockCode?.let { code ->
coroutineScope.launch { coroutineScope.launch {
KisTradeService.postOrder( KisTradeService.postOrder(
stockCode = code, stockCode = code,
qty = log.qty.toString(), qty = qty.toString(),
price = "", price = "",
isBuy = false isBuy = false
).onSuccess { ).onSuccess {
@@ -241,26 +335,340 @@ fun TradingDecisionLog() {
) )
} }
} }
} })
}
},
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Red),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 4.dp),
modifier = Modifier.height(30.dp).padding(start = 8.dp)
) {
Text("즉시 매도", color = Color.White, fontSize = 11.sp, fontWeight = FontWeight.Bold)
}
}
} }
} }
} }
} }
} }
// --- 우측: 거래 전략 및 봇 설정 패널 (가중치 2f: Grid 1f + Settings 1f) --- // --- 우측: 4대 탭 기반 거래 전략 및 설정 패널 (58%) ---
Card(
modifier = Modifier
.weight(0.58f)
.fillMaxHeight(),
shape = RoundedCornerShape(10.dp),
elevation = 2.dp,
backgroundColor = Color.White
) {
TradeConfigPanel( TradeConfigPanel(
modifier = Modifier.weight(2f), modifier = Modifier.fillMaxSize(),
tradeConfig = tradeConfig tradeConfig = tradeConfig
) )
} }
}
}
}
/**
* 상단 글로벌 상태 바 컴포넌트
*/
@Composable
private fun GlobalStatusBar(
llmAnalyser: Boolean,
llmNews: Boolean,
tradeToken: Boolean,
webSocketConnect: Boolean,
maxBudget: Double
) {
val marketStatus = remember { getMarketStatus() }
val formattedMaxBudget = remember(maxBudget) {
NumberFormat.getNumberInstance(Locale.KOREA).format(maxBudget.toLong())
}
Row(
modifier = Modifier
.fillMaxWidth()
.background(Color.White)
.padding(horizontal = 14.dp, vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
// 좌측 브랜드 및 타이틀
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Surface(
shape = RoundedCornerShape(6.dp),
color = Color(0xFF4F46E5)
) {
Text(
"AT",
color = Color.White,
fontWeight = FontWeight.Black,
fontSize = 12.sp,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 3.dp)
)
}
Text(
"AutoTrade Pro",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF0F172A)
)
Text(
"AI 통제실",
fontSize = 11.sp,
color = Color(0xFF64748B)
)
}
// 중앙 실시간 4대 엔진 인디케이터 배지
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically
) {
ModernStatusBadge("주식 분석기", llmAnalyser)
ModernStatusBadge("뉴스 처리기", llmNews)
ModernStatusBadge("한투 인증서", tradeToken)
ModernStatusBadge("실시간 감시", webSocketConnect)
}
// 우측 장 상태 및 1종목 한도 요약
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
// 장 운영 상태 칩
Surface(
shape = RoundedCornerShape(6.dp),
color = Color(0xFFF1F5F9),
border = BorderStroke(1.dp, Color(0xFFE2E8F0))
) {
Row(
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Text("⏰", fontSize = 10.sp)
Text(
marketStatus,
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
color = Color(0xFF334155)
)
}
}
// 종목당 최대 예산 배지
Surface(
shape = RoundedCornerShape(6.dp),
color = Color(0xFFF8FAFC),
border = BorderStroke(1.dp, Color(0xFFCBD5E1))
) {
Row(
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Text(
"1종목 투자한도",
fontSize = 10.sp,
color = Color(0xFF64748B)
)
Text(
"₩$formattedMaxBudget",
fontSize = 11.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF0F172A)
)
}
}
}
}
}
/**
* 모던 상태 인디케이터 배지
*/
@Composable
private fun ModernStatusBadge(
label: String,
isActive: Boolean
) {
Surface(
shape = RoundedCornerShape(12.dp),
color = if (isActive) Color(0xFFECFDF5) else Color(0xFFFEF2F2),
border = BorderStroke(1.dp, if (isActive) Color(0xFFA7F3D0) else Color(0xFFFECACA))
) {
Row(
modifier = Modifier.padding(horizontal = 7.dp, vertical = 3.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Box(
modifier = Modifier
.size(6.dp)
.background(
color = if (isActive) Color(0xFF10B981) else Color(0xFFEF4444),
shape = CircleShape
)
)
Text(
text = label,
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
color = Color(0xFF334155)
)
Text(
text = if (isActive) "ON" else "OFF",
fontSize = 9.sp,
fontWeight = FontWeight.Bold,
color = if (isActive) Color(0xFF059669) else Color(0xFFDC2626)
)
}
}
}
/**
* 실시간 의사결정 단일 카드 컴포넌트
*/
@Composable
private fun DecisionLogCard(
log: TradingLogStore.LogEntry,
onManualSell: (code: String, qty: Int) -> Unit
) {
Surface(
shape = RoundedCornerShape(8.dp),
color = Color(0xFFF8FAFC),
border = BorderStroke(1.dp, Color(0xFFE2E8F0)),
modifier = Modifier.fillMaxWidth()
) {
Column(
modifier = Modifier.padding(10.dp),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
// 1행: 시간, 종목명, 결정 뱃지
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
modifier = Modifier.weight(1f)
) {
Text(
log.time,
fontSize = 11.sp,
color = Color(0xFF94A3B8)
)
Text(
log.stockName,
fontWeight = FontWeight.Bold,
fontSize = 13.sp,
color = Color(0xFF0F172A),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
DecisionTag(decision = log.decision)
}
// 2행: 신뢰도 수치 (존재 시)
when (log.decision) {
"BUY", "SELL", "HOLD" -> {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Text(
"신뢰도",
fontSize = 10.sp,
color = Color(0xFF64748B)
)
Text(
"${log.confidence.toInt()}%",
fontSize = 11.sp,
fontWeight = FontWeight.Bold,
color = if (log.confidence >= 70) Color(0xFF059669) else Color(0xFFD97706)
)
}
}
}
// 3행: 상세 사유 텍스트
Text(
text = log.reason,
fontSize = 11.sp,
color = Color(0xFF475569),
lineHeight = 15.sp
)
// 4행: 손절 경고 시 즉시 시장가 매도 액션 버튼
if (log.decision.contains("NOTICE") && log.reason.contains("[손절 경고]")) {
Spacer(modifier = Modifier.height(2.dp))
Button(
onClick = {
val stockCode = log.stockCode ?: log.stockName.substringAfter("[").substringBefore("]")
if (stockCode.length == 6) {
onManualSell(stockCode, log.qty ?: 0)
}
},
colors = ButtonDefaults.buttonColors(backgroundColor = Color(0xFFEF4444)),
contentPadding = PaddingValues(horizontal = 10.dp, vertical = 2.dp),
modifier = Modifier.height(28.dp),
shape = RoundedCornerShape(6.dp)
) {
Text(
"⚡ 즉시 시장가 매도",
color = Color.White,
fontSize = 11.sp,
fontWeight = FontWeight.Bold
)
}
}
}
}
}
/**
* 결정 타입별 맞춤형 태그 뱃지
*/
@Composable
private fun DecisionTag(decision: String) {
val (bg, fg) = when (decision) {
"BUY" -> Color(0xFFFEE2E2) to Color(0xFFDC2626)
"SELL" -> Color(0xFFEDE9FE) to Color(0xFF7C3AED)
"HOLD" -> Color(0xFFF1F5F9) to Color(0xFF64748B)
"ANALYZER" -> Color(0xFFD1FAE5) to Color(0xFF059669)
"WATCH" -> Color(0xFFDBEAFE) to Color(0xFF2563EB)
"NOTICE" -> Color(0xFFFEF3C7) to Color(0xFFD97706)
"SETTING" -> Color(0xFFF3F4F6) to Color(0xFF4B5563)
"AFTER" -> Color(0xFFFEE2E2) to Color(0xFFB91C1C)
"RETRY" -> Color(0xFFE0F2FE) to Color(0xFF0284C7)
"PASS" -> Color(0xFFFEF9C3) to Color(0xFFCA8A04)
else -> Color(0xFFF1F5F9) to Color(0xFF475569)
}
Surface(
shape = RoundedCornerShape(4.dp),
color = bg
) {
Text(
text = decision,
color = fg,
fontSize = 10.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
}
/**
* 현재 시간 기준 시장 운영 상태 계산 헬퍼
*/
private fun getMarketStatus(): String {
val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
return when {
now.isBefore(LocalTime.of(8, 30)) -> "장 시작 전"
now.isBefore(LocalTime.of(9, 0)) -> "장전 시간외 (08:30~09:00)"
now.isBefore(LocalTime.of(15, 30)) -> "정규장 (09:00~15:30)"
now.isBefore(LocalTime.of(16, 0)) -> "장후 시간외 (15:40~16:00)"
now.isBefore(LocalTime.of(18, 0)) -> "시간외 단일가 (16:00~18:00)"
else -> "장 마감"
}
} }
File diff suppressed because it is too large Load Diff