버튼 눌러서 띄우기
This commit is contained in:
parent
95f43e105d
commit
81ce68e07b
@ -103,6 +103,32 @@ object LocalReportGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun generateAndOpenAsyncDirectly(
|
||||||
|
summary: RawSummaryData,
|
||||||
|
rawHoldings: List<RawHoldingData>,
|
||||||
|
rawTrades: List<RawTradeData>
|
||||||
|
) {
|
||||||
|
reportScope.launch {
|
||||||
|
try {
|
||||||
|
// 1. [핵심] 대시보드 통계 지표 추출 (Generator가 직접 계산)
|
||||||
|
val stats = calculateDashboardStats(rawHoldings, rawTrades)
|
||||||
|
|
||||||
|
// 2. 탭 2 & 3 HTML 가공
|
||||||
|
val holdingsHtml = processHoldings(rawHoldings)
|
||||||
|
val tradesHtml = processTrades(rawTrades)
|
||||||
|
|
||||||
|
// 3. 전체 HTML 조립
|
||||||
|
val htmlContent = buildHtml(summary, stats, holdingsHtml, tradesHtml)
|
||||||
|
if (summary.type.equals("END", true) || summary.type.equals("MIDDLE", true)) {
|
||||||
|
saveAndOpen(summary.type, htmlContent)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("❌ [Report] 리포트 비동기 생성 중 오류 발생: ${e.message}")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- [새로운 통계 계산 로직] ---
|
// --- [새로운 통계 계산 로직] ---
|
||||||
private fun calculateDashboardStats(holdings: List<RawHoldingData>, trades: List<RawTradeData>): DashboardStats {
|
private fun calculateDashboardStats(holdings: List<RawHoldingData>, trades: List<RawTradeData>): DashboardStats {
|
||||||
val tradesByStock = trades.groupBy { it.stockCode }
|
val tradesByStock = trades.groupBy { it.stockCode }
|
||||||
|
|||||||
@ -60,6 +60,7 @@ object TradingReportManager : TradingReportService {
|
|||||||
|
|
||||||
override fun recordAssetSnapshot(type: SnapshotType, balance: UnifiedBalance, remark: String?) {
|
override fun recordAssetSnapshot(type: SnapshotType, balance: UnifiedBalance, remark: String?) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
println("❌ [Report] 리포트 비동기 생성 중 오류 발생: gggg")
|
||||||
val todayDate = LocalDate.now().toString()
|
val todayDate = LocalDate.now().toString()
|
||||||
|
|
||||||
// 1. 중복 없는 전체 종목 코드 리스트 추출
|
// 1. 중복 없는 전체 종목 코드 리스트 추출
|
||||||
@ -229,7 +230,7 @@ object TradingReportManager : TradingReportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 6. 코루틴 기반 제너레이터 호출
|
// 6. 코루틴 기반 제너레이터 호출
|
||||||
LocalReportGenerator.generateAndOpenAsync(summaryData, holdingLogs, tradeLogs)
|
LocalReportGenerator.generateAndOpenAsyncDirectly(summaryData, holdingLogs, tradeLogs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,9 +50,13 @@ import model.KisSession
|
|||||||
import network.KisTradeService
|
import network.KisTradeService
|
||||||
import network.NewsService
|
import network.NewsService
|
||||||
import network.StockUniverseLoader
|
import network.StockUniverseLoader
|
||||||
|
import report.SnapshotType
|
||||||
|
import report.TradingReportManager
|
||||||
import service.AutoTradingManager
|
import service.AutoTradingManager
|
||||||
|
import service.AutoTradingManager.currentBalance
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import java.time.LocalTime
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterialApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@ -105,6 +109,9 @@ fun TradingDecisionLog() {
|
|||||||
|
|
||||||
Row(modifier = Modifier.fillMaxSize().background(Color(0xFFF2F2F2))) {
|
Row(modifier = Modifier.fillMaxSize().background(Color(0xFFF2F2F2))) {
|
||||||
Column(modifier = Modifier.weight(1f).padding(8.dp).fillMaxHeight().background(Color.White)) {
|
Column(modifier = Modifier.weight(1f).padding(8.dp).fillMaxHeight().background(Color.White)) {
|
||||||
|
Row(modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||||
|
) {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
@ -114,6 +121,23 @@ fun TradingDecisionLog() {
|
|||||||
}
|
}
|
||||||
) { Text("AI 자동매매 실시간 로그", style = MaterialTheme.typography.h6) }
|
) { Text("AI 자동매매 실시간 로그", style = MaterialTheme.typography.h6) }
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
coroutineScope.launch {
|
||||||
|
currentBalance = KisTradeService.fetchIntegratedBalance().getOrNull()
|
||||||
|
currentBalance?.let { currentBalance ->
|
||||||
|
if (LocalTime.now().isBefore(LocalTime.of(18,1))) {
|
||||||
|
TradingReportManager.recordAssetSnapshot(
|
||||||
|
if (LocalTime.now().isAfter(LocalTime.of(18, 0))
|
||||||
|
) SnapshotType.END else SnapshotType.MIDDLE, currentBalance, ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) { Text("Open the report", style = MaterialTheme.typography.body2) }
|
||||||
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
|
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
|
||||||
horizontalArrangement = Arrangement.Start
|
horizontalArrangement = Arrangement.Start
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user