Compare commits
2 Commits
5ae27df0d6
...
cdca361d4c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdca361d4c | ||
|
|
234e872273 |
11
habit_bot.py
11
habit_bot.py
@@ -1,4 +1,15 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Habit #!/usr/bin/env python3 Diet Telegram Bot with URL Summarization
|
||||||
|
# URL 요약을 포함한 습관 및 식단 Telegram 봇
|
||||||
|
#
|
||||||
|
# 기능 / Features:
|
||||||
|
# - 습관 추적 (/habit add, log, list) / Habit tracking
|
||||||
|
# - 음식 기록 및 영양 분석 / Food logging with nutrition analysis
|
||||||
|
# - 아침 브리핑 및 밤 디브리프 / Morning briefings and night debrief
|
||||||
|
# - URL 요약 (YouTube/Blog/News) / URL summarization
|
||||||
|
# - 케토 다이어트 가이드라인 / Keto diet guidelines
|
||||||
"""
|
"""
|
||||||
Unified Telegram Bot - Habit, Diet, URL Summarizer
|
Unified Telegram Bot - Habit, Diet, URL Summarizer
|
||||||
Features:
|
Features:
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Stock #!/usr/bin/env python3 Crypto Portfolio Tracker / 주식 및 암호화폐 포트폴리오 트래커
|
||||||
|
# 기능:
|
||||||
|
# - 주식 및 암호화폐 가격 추적 / Track stocks and crypto prices
|
||||||
|
# - 포트폴리오 P#!/usr/bin/env python3L 계산 / Calculate portfolio P#!/usr/bin/env python3L
|
||||||
|
# - 시장 지수 비교 / Compare against market indices
|
||||||
|
# - 투자 권고사항 생성 / Generate investment recommendations
|
||||||
|
# - 일일/주간 리포트 / Daily/weekly reports
|
||||||
"""
|
"""
|
||||||
Stock & Crypto Portfolio Tracker
|
Stock & Crypto Portfolio Tracker
|
||||||
Features:
|
Features:
|
||||||
@@ -79,7 +88,7 @@ class StockTracker:
|
|||||||
self.positions = self._load_positions()
|
self.positions = self._load_positions()
|
||||||
self.prices = self._load_prices()
|
self.prices = self._load_prices()
|
||||||
|
|
||||||
# ============== Data Management ==============
|
# ============== 데이터 관리 / Data Management ==============
|
||||||
|
|
||||||
def _load_positions(self) -> Dict[str, Position]:
|
def _load_positions(self) -> Dict[str, Position]:
|
||||||
if os.path.exists(PORTFOLIO_FILE):
|
if os.path.exists(PORTFOLIO_FILE):
|
||||||
@@ -102,7 +111,7 @@ class StockTracker:
|
|||||||
with open(PRICES_FILE, 'w') as f:
|
with open(PRICES_FILE, 'w') as f:
|
||||||
json.dump({k: asdict(v) for k, v in self.prices.items()}, f, indent=2)
|
json.dump({k: asdict(v) for k, v in self.prices.items()}, f, indent=2)
|
||||||
|
|
||||||
# ============== Portfolio Management ==============
|
# ============== 포트폴리오 관리 / Portfolio Management ==============
|
||||||
|
|
||||||
def add_position(self, symbol: str, asset_type: str, quantity: float,
|
def add_position(self, symbol: str, asset_type: str, quantity: float,
|
||||||
avg_cost: float, entry_date: str = "", notes: str = "") -> bool:
|
avg_cost: float, entry_date: str = "", notes: str = "") -> bool:
|
||||||
@@ -135,7 +144,7 @@ class StockTracker:
|
|||||||
def get_positions(self) -> List[Position]:
|
def get_positions(self) -> List[Position]:
|
||||||
return list(self.positions.values())
|
return list(self.positions.values())
|
||||||
|
|
||||||
# ============== Price Fetching ==============
|
# ============== 가격 가져오기 / Price Fetching ==============
|
||||||
|
|
||||||
def fetch_price(self, symbol: str) -> Optional[PriceData]:
|
def fetch_price(self, symbol: str) -> Optional[PriceData]:
|
||||||
"""Fetch current price for a symbol using yfinance"""
|
"""Fetch current price for a symbol using yfinance"""
|
||||||
@@ -188,7 +197,7 @@ class StockTracker:
|
|||||||
self._save_prices()
|
self._save_prices()
|
||||||
return self.prices
|
return self.prices
|
||||||
|
|
||||||
# ============== Performance Calculation ==============
|
# ============== 성과 계산 / Performance Calculation ==============
|
||||||
|
|
||||||
def calculate_portfolio_summary(self) -> PortfolioSummary:
|
def calculate_portfolio_summary(self) -> PortfolioSummary:
|
||||||
"""Calculate portfolio summary with P&L"""
|
"""Calculate portfolio summary with P&L"""
|
||||||
@@ -291,7 +300,7 @@ class StockTracker:
|
|||||||
return ((price.current_price - pos.avg_cost) / pos.avg_cost) * 100
|
return ((price.current_price - pos.avg_cost) / pos.avg_cost) * 100
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# ============== Crypto & Market Data ==============
|
# ============== 암호화폐 및 시장 데이터 / Crypto & Market Data ==============
|
||||||
|
|
||||||
def get_crypto_price(self, symbol: str = "BTC") -> Optional[PriceData]:
|
def get_crypto_price(self, symbol: str = "BTC") -> Optional[PriceData]:
|
||||||
"""Fetch cryptocurrency price using yfinance"""
|
"""Fetch cryptocurrency price using yfinance"""
|
||||||
@@ -359,7 +368,7 @@ class StockTracker:
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# ============== Reporting ==============
|
# ============== 리포팅 / Reporting ==============
|
||||||
|
|
||||||
def generate_daily_report(self) -> str:
|
def generate_daily_report(self) -> str:
|
||||||
"""Generate daily portfolio report"""
|
"""Generate daily portfolio report"""
|
||||||
|
|||||||
Reference in New Issue
Block a user