<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>주식그래프 보관 - 하우인포-IT·테크</title>
	<atom:link href="https://howinfo.kr/tag/%EC%A3%BC%EC%8B%9D%EA%B7%B8%EB%9E%98%ED%94%84/feed/" rel="self" type="application/rss+xml" />
	<link>https://howinfo.kr/tag/주식그래프/</link>
	<description>IT·AI 자동화 &#38; 인프라 전문 블로그 (하우인포)</description>
	<lastBuildDate>Wed, 04 Feb 2026 06:26:21 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://howinfo.kr/wp-content/uploads/2026/02/cropped-ChatGPT-Image-2026년-2월-12일-오후-05_39_40-32x32.png</url>
	<title>주식그래프 보관 - 하우인포-IT·테크</title>
	<link>https://howinfo.kr/tag/주식그래프/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>📈 파이썬 주식 봇 데이터를 DB에 저장하고 웹 대시보드로 보는 방법 (SQLite + Streamlit)</title>
		<link>https://howinfo.kr/%f0%9f%93%88-%ed%8c%8c%ec%9d%b4%ec%8d%ac-%ec%a3%bc%ec%8b%9d-%eb%b4%87-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a5%bc-db%ec%97%90-%ec%a0%80%ec%9e%a5%ed%95%98%ea%b3%a0-%ec%9b%b9-%eb%8c%80%ec%8b%9c%eb%b3%b4/</link>
					<comments>https://howinfo.kr/%f0%9f%93%88-%ed%8c%8c%ec%9d%b4%ec%8d%ac-%ec%a3%bc%ec%8b%9d-%eb%b4%87-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a5%bc-db%ec%97%90-%ec%a0%80%ec%9e%a5%ed%95%98%ea%b3%a0-%ec%9b%b9-%eb%8c%80%ec%8b%9c%eb%b3%b4/#respond</comments>
		
		<dc:creator><![CDATA[hong]]></dc:creator>
		<pubDate>Wed, 04 Feb 2026 06:26:21 +0000</pubDate>
				<category><![CDATA[자동화]]></category>
		<category><![CDATA[ai자동화]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[streamlit]]></category>
		<category><![CDATA[주식그래프]]></category>
		<category><![CDATA[주식자동화]]></category>
		<category><![CDATA[파이썬주식봇]]></category>
		<category><![CDATA[포토폴리오대시보드]]></category>
		<guid isPermaLink="false">https://howinfo.kr/?p=1257</guid>

					<description><![CDATA[<p>Python 주식 자동화 봇을 운영하고 있다면, 이제는 ‘기록’을 남겨야 할 때입니다.매일 계산되는 손익, 수익률, 자산 변화… Chat 알림으로만 보지 말고...</p>
<p>게시물 <a href="https://howinfo.kr/%f0%9f%93%88-%ed%8c%8c%ec%9d%b4%ec%8d%ac-%ec%a3%bc%ec%8b%9d-%eb%b4%87-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a5%bc-db%ec%97%90-%ec%a0%80%ec%9e%a5%ed%95%98%ea%b3%a0-%ec%9b%b9-%eb%8c%80%ec%8b%9c%eb%b3%b4/">📈 파이썬 주식 봇 데이터를 DB에 저장하고 웹 대시보드로 보는 방법 (SQLite + Streamlit)</a>이 <a href="https://howinfo.kr">하우인포-IT·테크</a>에 처음 등장했습니다.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>Python 주식 자동화 봇을 운영하고 있다면, 이제는 ‘기록’을 남겨야 할 때입니다.</strong><br>매일 계산되는 손익, 수익률, 자산 변화… Chat 알림으로만 보지 말고 <strong>그래프로 쌓아보세요.</strong></p>



<p></p>



<h2 class="wp-block-heading">✅ 왜 DB에 저장해야 할까?</h2>



<p>많은 분들이 이런 자동화 봇을 만듭니다.</p>



<ul class="wp-block-list">
<li>네이버/증권 API로 주가 조회</li>



<li>보유 종목 수익률 계산</li>



<li>Synology Chat, Slack, 텔레그램으로 알림 전송</li>
</ul>



<p>하지만 시간이 지나면 이런 생각이 들죠.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>“어제보다 오늘 얼마나 늘었지?”<br>“한 달 동안 수익률 추이가 어땠지?”<br>“어떤 종목이 실제로 수익에 가장 기여했지?”</p>
</blockquote>



<p>👉 <strong>알림 메시지로는 절대 알 수 없습니다.</strong><br>👉 <strong>시계열 데이터(History)가 필요합니다.</strong></p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">🧠 해결 방법 구조</h2>



<p>가장 간단하고 강력한 구조는 아래입니다.</p>



<pre class="wp-block-code"><code>&#91;파이썬 주식 봇]
        ↓
   SQLite DB 저장
        ↓
 Streamlit 웹 대시보드
</code></pre>



<p>이 방법의 장점은:</p>



<ul class="wp-block-list">
<li>별도 서버 불필요</li>



<li>DB는 파일 하나 (백업 쉬움)</li>



<li>오렌지파이 / 라즈베리파이에서도 충분히 동작</li>



<li>웹에서 그래프로 바로 확인 가능</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">🗄️ 1단계 — SQLite DB 설계</h2>



<p>봇이 실행될 때마다 2가지 정보를 저장합니다.</p>



<h3 class="wp-block-heading">① 포트폴리오 전체 요약 (1행)</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>항목</th><th>설명</th></tr></thead><tbody><tr><td>ts</td><td>실행 시각</td></tr><tr><td>total_value_krw</td><td>총 평가금액</td></tr><tr><td>total_invested_krw</td><td>총 매입금액</td></tr><tr><td>total_pl_krw</td><td>총 손익</td></tr><tr><td>total_roi_pct</td><td>총 수익률</td></tr></tbody></table></figure>



<h3 class="wp-block-heading">② 종목별 스냅샷 (종목 수 만큼)</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>항목</th><th>설명</th></tr></thead><tbody><tr><td>ts</td><td>실행 시각</td></tr><tr><td>name</td><td>종목명</td></tr><tr><td>qty</td><td>보유 수량</td></tr><tr><td>avg_buy</td><td>평균 매입가</td></tr><tr><td>price</td><td>현재가</td></tr><tr><td>market_value_krw</td><td>평가금액</td></tr><tr><td>pl_krw</td><td>손익</td></tr><tr><td>roi_pct</td><td>수익률</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">💾 SQLite 저장 코드 (봇에 추가)</h2>



<pre class="wp-block-code"><code>import sqlite3
from datetime import datetime

DB_PATH = "/home/orangepi/python/data/portfolio.db"

def init_db():
    con = sqlite3.connect(DB_PATH)
    cur = con.cursor()

    cur.execute("""
    CREATE TABLE IF NOT EXISTS portfolio_snapshot (
      ts TEXT PRIMARY KEY,
      total_value_krw REAL,
      total_invested_krw REAL,
      total_pl_krw REAL,
      total_roi_pct REAL
    )
    """)

    cur.execute("""
    CREATE TABLE IF NOT EXISTS holding_snapshot (
      ts TEXT,
      name TEXT,
      qty REAL,
      avg_buy REAL,
      price REAL,
      market_value_krw REAL,
      pl_krw REAL,
      roi_pct REAL,
      PRIMARY KEY (ts, name)
    )
    """)
    con.commit()
    con.close()
</code></pre>



<p>봇이 계산을 마친 시점에 다음 함수 호출만 추가하면 됩니다.</p>



<pre class="wp-block-code"><code>def save_snapshot(summary, holdings):
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    con = sqlite3.connect(DB_PATH)
    cur = con.cursor()

    cur.execute("""
    INSERT OR REPLACE INTO portfolio_snapshot VALUES (?,?,?,?,?)
    """, (ts,
          summary&#91;"total_value_krw"],
          summary&#91;"total_invested_krw"],
          summary&#91;"total_pl_krw"],
          summary&#91;"total_roi_pct"]))

    for h in holdings:
        cur.execute("""
        INSERT OR REPLACE INTO holding_snapshot VALUES (?,?,?,?,?,?,?,?)
        """, (ts, h&#91;"name"], h&#91;"qty"], h&#91;"avg_buy"],
              h&#91;"price"], h&#91;"market_value_krw"],
              h&#91;"pl_krw"], h&#91;"roi_pct"]))

    con.commit()
    con.close()
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">🌐 2단계 — Streamlit 웹 대시보드 만들기</h2>



<p>Streamlit은 파이썬으로 웹을 만드는 가장 쉬운 도구입니다.</p>



<p>설치:</p>



<pre class="wp-block-code"><code>pip install streamlit pandas
</code></pre>



<p><code>dashboard.py</code> 생성:</p>



<pre class="wp-block-code"><code>import sqlite3, pandas as pd
import streamlit as st

DB_PATH = "/home/orangepi/python/data/portfolio.db"

st.title("📈 포트폴리오 대시보드")

con = sqlite3.connect(DB_PATH)
snap = pd.read_sql_query("SELECT * FROM portfolio_snapshot ORDER BY ts", con)
hold = pd.read_sql_query("SELECT * FROM holding_snapshot ORDER BY ts", con)
con.close()

st.subheader("총 평가금액 추이")
st.line_chart(snap.set_index("ts")&#91;"total_value_krw"])

st.subheader("총 손익 추이")
st.line_chart(snap.set_index("ts")&#91;"total_pl_krw"])

st.subheader("최근 종목별 손익")
latest = hold&#91;"ts"].max()
st.dataframe(
    hold&#91;hold&#91;"ts"] == latest].sort_values("pl_krw", ascending=False)
)
</code></pre>



<p>실행:</p>



<pre class="wp-block-code"><code>streamlit run dashboard.py --server.port 8501
</code></pre>



<p>이제 브라우저에서 접속하면 <strong>주식 손익 그래프 웹페이지</strong>가 열립니다.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">📊 이렇게 보입니다</h2>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/1%2AtpZuypCypENZw1eq8ijWCA.png" alt="https://miro.medium.com/1%2AtpZuypCypENZw1eq8ijWCA.png"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://images.prismic.io/turing/65a53cdf7a5e8b1120d5887f_image1_11zon_c0821d08b2.webp?auto=format%2Ccompress" alt="https://images.prismic.io/turing/65a53cdf7a5e8b1120d5887f_image1_11zon_c0821d08b2.webp?auto=format%2Ccompress"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/v2/resize%3Afit%3A1400/1%2A63VrsZO18fBTDmCdnbiNiw.gif" alt="https://miro.medium.com/v2/resize%3Afit%3A1400/1%2A63VrsZO18fBTDmCdnbiNiw.gif"/></figure>



<p>4</p>



<ul class="wp-block-list">
<li>총 자산 증가 추이</li>



<li>손익 변동 그래프</li>



<li>종목별 수익 기여도</li>



<li>자산 비중 파이차트 (추가 가능)</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">🚀 이 방식의 진짜 장점</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>기존</th><th>개선 후</th></tr></thead><tbody><tr><td>Chat 알림으로 그때그때 확인</td><td>시간 흐름에 따른 데이터 축적</td></tr><tr><td>오늘 수익만 확인</td><td>한 달/세 달/1년 추이 분석</td></tr><tr><td>감으로 투자 판단</td><td>데이터 기반 판단</td></tr><tr><td>로그 파일</td><td>웹 대시보드</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">✨ 확장 아이디어</h2>



<ul class="wp-block-list">
<li>주간/월간 리포트를 자동으로 PNG 그래프로 생성 후 Chat 전송</li>



<li>Grafana/Metabase 연결</li>



<li>종목별 ROI 히스토리 그래프</li>



<li>자산군(ETF/주식/금) 비중 변화 추이</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">✅ 마무리</h2>



<p>주식 자동화 봇을 만들었다면, 이제는 <strong>데이터를 쌓아야 할 단계</strong>입니다.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>기록되지 않는 수익률은, 결국 기억에만 남습니다.</p>
</blockquote>



<p>SQLite + Streamlit 조합은<br><strong>가볍고, 쉽고, 강력한 개인 투자자용 대시보드</strong>를 만드는 최고의 방법입니다.</p>



<p>지금 사용 중인 주식 봇에 단 50줄만 추가해보세요.<br>당신의 투자가 ‘데이터’로 보이기 시작합니다.</p>



<p>다음시간에 실시간 기록을 남기는 소스를 보겠습니다. </p>



<p></p>
<p>게시물 <a href="https://howinfo.kr/%f0%9f%93%88-%ed%8c%8c%ec%9d%b4%ec%8d%ac-%ec%a3%bc%ec%8b%9d-%eb%b4%87-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a5%bc-db%ec%97%90-%ec%a0%80%ec%9e%a5%ed%95%98%ea%b3%a0-%ec%9b%b9-%eb%8c%80%ec%8b%9c%eb%b3%b4/">📈 파이썬 주식 봇 데이터를 DB에 저장하고 웹 대시보드로 보는 방법 (SQLite + Streamlit)</a>이 <a href="https://howinfo.kr">하우인포-IT·테크</a>에 처음 등장했습니다.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://howinfo.kr/%f0%9f%93%88-%ed%8c%8c%ec%9d%b4%ec%8d%ac-%ec%a3%bc%ec%8b%9d-%eb%b4%87-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a5%bc-db%ec%97%90-%ec%a0%80%ec%9e%a5%ed%95%98%ea%b3%a0-%ec%9b%b9-%eb%8c%80%ec%8b%9c%eb%b3%b4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
