yeonghoon.kim

  • 게시판
  • 갤러리

비트코인 자동매매 봇 대시보드

김영훈 2026.02.21 18:34 조회 수 : 144

잠시 욕망에 빠져서 비트코인 자동매매 봇을 만들었다.

업비트 API 붙이고 RSI / 볼린저밴드 기반으로 자동매매.

프로젝트.

0027-bitcoin-trading-bot

구조.

src/core/config.py
src/core/exchange.py
src/core/logger.py
src/strategies/rsi_bb.py
src/strategies/ma_cross.py
src/backtesting/backtest.py
src/trading/bot.py
src/trading/order.py
src/trading/risk.py
src/trading/limit_enforcer.py
src/core/prometheus_exporter.py

전략.

RSI + 볼린저밴드.

매수 조건.

RSI(14) < 30
현재가 < 볼린저밴드 하단
보유 비트코인 없음
일일 손실 < 3,000원

매도 조건.

수익률 >= +1.0%
손실률 <= -0.5%

실행.

pip install -r requirements.txt

python src/main.py --mode backtest --days 90

python src/main.py --mode live

Docker 실행.

cd docker
docker-compose up -d

Prometheus exporter 추가.

src/core/prometheus_exporter.py

from prometheus_client import Gauge, start_http_server, CollectorRegistry

realized_profit_gauge = Gauge('bitcoin_realized_profit_krw', 'Realized Profit KRW (거래 수익)', registry=global_registry)
unrealized_profit_gauge = Gauge('bitcoin_unrealized_profit_krw', 'Unrealized Profit KRW (보유 평가손익)', registry=global_registry)
profit_gauge = Gauge('bitcoin_profit_krw', 'Total Profit KRW (실현+미실현)', registry=global_registry)

profit_pct_gauge = Gauge('bitcoin_profit_pct', 'Total Profit Percentage', registry=global_registry)
realized_profit_pct_gauge = Gauge('bitcoin_realized_profit_pct', 'Realized Profit Percentage', registry=global_registry)
unrealized_profit_pct_gauge = Gauge('bitcoin_unrealized_profit_pct', 'Unrealized Profit Percentage', registry=global_registry)

win_rate_gauge = Gauge('bitcoin_win_rate', 'Win Rate Percentage', registry=global_registry)
rsi_btc = Gauge('bitcoin_rsi_btc', 'BTC Current RSI', registry=global_registry)
rsi_eth = Gauge('bitcoin_rsi_eth', 'ETH Current RSI', registry=global_registry)
price_btc = Gauge('bitcoin_price_btc', 'BTC Current Price', registry=global_registry)
price_eth = Gauge('bitcoin_price_eth', 'ETH Current Price', registry=global_registry)

balance_krw = Gauge('bitcoin_balance_krw', 'Current KRW Balance', registry=global_registry)
balance_btc = Gauge('bitcoin_balance_btc', 'Current BTC Balance', registry=global_registry)
balance_eth = Gauge('bitcoin_balance_eth', 'Current ETH Balance', registry=global_registry)
total_asset = Gauge('bitcoin_total_asset', 'Total Asset Value (KRW)', registry=global_registry)
asset_value_btc = Gauge('bitcoin_asset_value_btc', 'BTC Asset Value (KRW)', registry=global_registry)
asset_value_eth = Gauge('bitcoin_asset_value_eth', 'ETH Asset Value (KRW)', registry=global_registry)
invested_btc = Gauge('bitcoin_invested_btc', 'BTC Invested Amount (KRW)', registry=global_registry)
invested_eth = Gauge('bitcoin_invested_eth', 'ETH Invested Amount (KRW)', registry=global_registry)

initial_capital = Gauge('bitcoin_initial_capital', 'Initial Capital (KRW)', registry=global_registry)

last_update = Gauge('bitcoin_last_update_timestamp', 'Last Update Unix Timestamp', registry=global_registry)

main.py에서 exporter 실행.

from src.core.prometheus_exporter import start_exporter, refresh_metrics

Grafana 대시보드 구성.

총자산
원 잔액
비트코인 평가금액
이더리움 평가금액
총손익
승률
BTC RSI
ETH RSI
자산 구성 추이
RSI 추이
누적 손익 추이
수익률 추이

갱신 주기.

30초.

당시 상태.

총자산:
49.84만원

원 잔액:
29.60만원

비트코인:
0.00만원

이더리움:
20.24만원

손익:
+0.05만원

수익률:
+0.22%

승률:
50%

현재 보유:
이더리움

RSI 예시.

BTC:
47.3 -> 29.9 -> 25.7 -> 38.9 -> 35.3

ETH:
43.3 -> 35.1 -> 33.3 -> 41.5 -> 37.1

Git 기록.

2026-02-21 13:13
손익 추적 및 일일/월간 리포트 시스템 추가

2026-02-21 13:21
BTC/ETH 코인별 통계 추가

2026-02-21 14:05
Prometheus 메트릭 익스포터 추가

2026-02-21 14:25
현재 자산 정보 Prometheus 메트릭 추가

나중에 운영 중단.

2026-02-28
비트코인 봇 운영 중단

최종 결과는 별로였음.

그래도 Prometheus / Grafana 붙여서 봇 상태를 보는 구조는 만들었다.

  • 추천 0

  • 비추천 0
이 게시물을
목록

댓글 0

번호 제목 글쓴이 날짜 조회 수
공지 2025 일본 여행 계획 김영훈 2024.10.10 4119
공지 현금, 저축, 투자, 지출, 예산, 보험 내역(2024-05-30) 김영훈 2024.03.10 3752
317 OpenClaw 복원과 GLM-5.1 전환 김영훈 2026.04.07 145
316 교토 4박 5일 여행 일정: Google Calendar로 관리하는 일정짜기 김영훈 2026.04.05 124
315 7일간의 일본 여행 일정 짜기: 신칸센 + JR 패스 + Google Calendar 활용 프로젝트 김영훈 2026.03.28 128
314 JSON-LD 학습 - 메일과 Calendar 자동 인식 김영훈 2026.03.28 151
313 WAF 운영 6주 분석 김영훈 2026.03.13 199
312 Tech Support 플랫폼 김영훈 2026.03.04 80
311 ChloeToken 테스트넷 배포 김영훈 2026.03.02 232
310 Redis 대기열 시스템 김영훈 2026.03.01 212
309 Apache RewriteRule 쿼리스트링 처리 김영훈 2026.02.28 258
» 비트코인 자동매매 봇 대시보드 김영훈 2026.02.21 144
307 ARM Kubernetes 구축 6 - 무중단 업그레이드 김영훈 2026.02.20 208
306 ARM Kubernetes 구축 8 - 실전 보안 RBAC 네트워크 정책 Pod 보안 김영훈 2026.02.20 194
305 ARM Kubernetes 구축 7 - 클러스터 무중단 업그레이드 v1.29→v1.35 김영훈 2026.02.20 252
304 ARM Kubernetes 구축 4 - 외부 접근 환경 VPN MetalLB Ingress 김영훈 2026.02.18 246
303 ARM Kubernetes 구축 5 - 실전 업그레이드 경험기 v1.29→v1.35 김영훈 2026.02.18 238
302 ARM Kubernetes 구축 3 - 모니터링 스택 Prometheus Grafana 김영훈 2026.02.16 179
301 ARM Kubernetes 구축 1 - VNC & KVM 설치 김영훈 2026.02.14 70
300 ARM Kubernetes 구축 2 - VM 생성과 클러스터 설치 김영훈 2026.02.14 138
299 OpenClaw 모델 삭제 사고 김영훈 2026.02.13 114
298 LLM 모델 선정 김영훈 2026.02.12 141
쓰기 태그
 첫 페이지 1 2 3 4 5 6 7 8 9 10 끝 페이지