initial commit
This commit is contained in:
188
frontend/settings.html
Normal file
188
frontend/settings.html
Normal file
@@ -0,0 +1,188 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>설정 - KisStock AI</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<div class="logo">KisStock AI</div>
|
||||
<div class="nav-links">
|
||||
<a href="/">대시보드</a>
|
||||
<a href="/trade">매매</a>
|
||||
<a href="/settings" class="active">설정</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<h2>⚙️ 시스템 설정</h2>
|
||||
<div id="settings-form">
|
||||
<!-- KIS Settings -->
|
||||
<div class="form-group">
|
||||
<label>App Key (실전/모의)</label>
|
||||
<input type="text" id="app_key" placeholder="KIS App Key">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>App Secret</label>
|
||||
<input type="password" id="app_secret" placeholder="KIS App Secret">
|
||||
</div>
|
||||
<div class="grid">
|
||||
<div class="form-group">
|
||||
<label>계좌번호 (8자리)</label>
|
||||
<input type="text" id="account_no" placeholder="12345678">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>계좌식별코드 (2자리)</label>
|
||||
<input type="text" id="account_prod" placeholder="01">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>HTS ID</label>
|
||||
<input type="text" id="htsid" placeholder="HTS ID">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>투자 환경</label>
|
||||
<select id="is_paper">
|
||||
<option value="true">모의투자 (Mock)</option>
|
||||
<option value="false">실전투자 (Real)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>
|
||||
<input type="checkbox" id="enable_news" style="width:auto;"> 뉴스 수집 및 AI 분석 활성화
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<hr style="border-color: rgba(255,255,255,0.1); margin: 2rem 0;">
|
||||
|
||||
<!-- External APIs -->
|
||||
<div class="form-group">
|
||||
<label>Naver Client ID</label>
|
||||
<input type="text" id="naver_id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Naver Client Secret</label>
|
||||
<input type="password" id="naver_secret">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Google Gemini API Key</label>
|
||||
<input type="password" id="google_key">
|
||||
</div>
|
||||
|
||||
<hr style="border-color: rgba(255,255,255,0.1); margin: 2rem 0;">
|
||||
|
||||
<div class="form-group">
|
||||
<label>
|
||||
<input type="checkbox" id="enable_telegram" style="width:auto;"> 텔레그램 알림 활성화
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Telegram Bot Token</label>
|
||||
<input type="password" id="bot_token" placeholder="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Telegram Chat ID</label>
|
||||
<input type="text" id="chat_id" placeholder="123456789">
|
||||
</div>
|
||||
|
||||
|
||||
<div style="text-align: right; margin-top: 2rem;">
|
||||
<button class="btn btn-primary" onclick="saveSettings()">저장하기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>🤖 자동매매 설정 (DB)</h2>
|
||||
<div class="form-group">
|
||||
<p class="text-muted">종목별 자동매매 감시 조건은 매매 페이지에서 설정할 수 있습니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let currentConfig = {};
|
||||
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const res = await fetch('/api/settings');
|
||||
const data = await res.json();
|
||||
currentConfig = data;
|
||||
|
||||
// Bind to UI
|
||||
if (data.kis) {
|
||||
document.getElementById('app_key').value = data.kis.app_key || '';
|
||||
document.getElementById('app_secret').value = data.kis.app_secret || '';
|
||||
document.getElementById('account_no').value = data.kis.account_no || '';
|
||||
document.getElementById('account_prod').value = data.kis.account_prod || '';
|
||||
document.getElementById('htsid').value = data.kis.htsid || '';
|
||||
document.getElementById('is_paper').value = data.kis.is_paper ? "true" : "false";
|
||||
}
|
||||
if (data.preferences) {
|
||||
document.getElementById('enable_news').checked = data.preferences.enable_news || false;
|
||||
document.getElementById('enable_telegram').checked = data.preferences.enable_telegram !== false; // Default true
|
||||
}
|
||||
|
||||
if (data.naver) {
|
||||
document.getElementById('naver_id').value = data.naver.client_id || '';
|
||||
document.getElementById('naver_secret').value = data.naver.client_secret || '';
|
||||
}
|
||||
if (data.google) {
|
||||
document.getElementById('google_key').value = data.google.api_key || '';
|
||||
}
|
||||
if (data.telegram) {
|
||||
document.getElementById('bot_token').value = data.telegram.bot_token || '';
|
||||
document.getElementById('chat_id').value = data.telegram.chat_id || '';
|
||||
}
|
||||
|
||||
} catch(e) { console.error(e); alert('Load failed'); }
|
||||
}
|
||||
|
||||
async function saveSettings() {
|
||||
const newConfig = { ...currentConfig };
|
||||
|
||||
if (!newConfig.kis) newConfig.kis = {};
|
||||
newConfig.kis.app_key = document.getElementById('app_key').value;
|
||||
newConfig.kis.app_secret = document.getElementById('app_secret').value;
|
||||
newConfig.kis.account_no = document.getElementById('account_no').value;
|
||||
newConfig.kis.account_prod = document.getElementById('account_prod').value;
|
||||
newConfig.kis.htsid = document.getElementById('htsid').value;
|
||||
newConfig.kis.is_paper = document.getElementById('is_paper').value === "true";
|
||||
|
||||
if (!newConfig.preferences) newConfig.preferences = {};
|
||||
newConfig.preferences.enable_news = document.getElementById('enable_news').checked;
|
||||
newConfig.preferences.enable_telegram = document.getElementById('enable_telegram').checked;
|
||||
|
||||
|
||||
if (!newConfig.naver) newConfig.naver = {};
|
||||
newConfig.naver.client_id = document.getElementById('naver_id').value;
|
||||
newConfig.naver.client_secret = document.getElementById('naver_secret').value;
|
||||
|
||||
if (!newConfig.google) newConfig.google = {};
|
||||
newConfig.google.api_key = document.getElementById('google_key').value;
|
||||
|
||||
if (!newConfig.telegram) newConfig.telegram = {};
|
||||
newConfig.telegram.bot_token = document.getElementById('bot_token').value;
|
||||
newConfig.telegram.chat_id = document.getElementById('chat_id').value;
|
||||
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/settings', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(newConfig)
|
||||
});
|
||||
if (res.ok) alert('설정이 저장되었습니다. 서버를 재시작해야 적용될 수 있습니다.');
|
||||
else alert('저장 실패');
|
||||
} catch(e) { console.error(e); alert('Error'); }
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user