Xpersona
M

mapulse-korea

CLAWHUB · Unverified

한국주식 analyst Telegram bot. Monitors KOSPI/KOSDAQ, tracks watchlist, delivers AI briefings, answers natural-language questions in Korean/Chinese/English. Cove...

62
Rank
84
Safety
972
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 972 downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s173btr78pwygm4wanfj0ezk1h83h9b6:mapulse-korea
  1. Install using `clawhub skill install s173btr78pwygm4wanfj0ezk1h83h9b6:mapulse-korea` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/lbtsm/mapulse-korea before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-lbtsm-mapulse-korea/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

149,137 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: mapulse
description: >
  한국주식 analyst Telegram bot. Monitors KOSPI/KOSDAQ,
  tracks watchlist, delivers AI briefings, answers natural-language questions
  in Korean/Chinese/English. Covers stock prices, sector rankings, DART
  disclosures, crash alerts, crypto, commodities, and market news.
metadata:
  openclaw:
    env:
      - name: TELEGRAM_BOT_TOKEN
        required: false
        description: Enables Telegram bot integration (sending and receiving messages). If not provided, Telegram features will be disabled .
      - name: OPENROUTER_API_KEY
        required: false
        description: OpenRouter API key for AI deep analysis
      - name: ANTHROPIC_API_KEY
        required: false
        description: Anthropic API key (alternative to OpenRouter)
      - name: DART_API_KEY
        required: false
        description: DART API key for Korean corporate disclosures
      - name: ALLOWED_GROUPS
        required: false
        description: Comma-separated Telegram group IDs to restrict bot access
      - name: MAPULSE_DB
        required: false
        description: "SQLite database path (default: data/mapulse.db)"
      - name: MAPULSE_CLAUDE_MODEL
        required: false
        description: "LLM model override (default: claude-sonnet-4)"
      - name: KOREA_STOCK_WATCHLIST
        required: false
        description: "Default watchlist tickers, comma-separated"
      - name: RATE_LIMIT_PER_MIN
        required: false
        description: "Max requests per user per minute (default: 10)"
      - name: RATE_LIMIT_COOLDOWN
        required: false
        description: "Min seconds between requests (default: 3)"
      - name: OPS_CHAT_IDS
        required: false
        description: "Comma-separated Telegram user IDs for daily stats reports"
      - name: MAPULSE_CHANNEL_ID
        required: false
        description: "Telegram channel ID for public briefing pushes"
      - name: OPENNEWS_TOKEN
        required: false
        description: "6551.io news API token"
      - name: TWITTER_TOKEN
        required: false
        description: "6551.io Twitter API token"
---

# Mapulse 🇰🇷

Korean stock market AI analyst Telegram bot. Free, no billing — just set your bot token and go 한국 주식, 시장 분위기, 해외 변수까지 분석해주는 AI .

## Quick Start

```bash
# 1. Install dependencies
pip install python-telegram-bot pykrx requests beautifulsoup4

# 2. Set your bot token
export TELEGRAM_BOT_TOKEN=your_token_here

# 3. Start the bot
cd bot && python3 mapulse_bot.py
```

All configuration is via environment variables. No `.env` files are loaded automatically.

## Environment Variables

| Variable | Required | Description |
|---|---|---|
| `TELEGRAM_BOT_TOKEN` | ✅ | Telegram bot token from @BotFather |
| `OPENROUTER_API_KEY` | ❌ | AI deep analysis (OpenRouter) |
| `ANTHROPIC_API_KEY` | ❌ | AI deep analysis (Anthropic, alternative) |
| `DART_API_KEY` | ❌ | Korean corporate disclosure data |
| `ALLOWED_GROUPS` | ❌ | Restrict to specific Telegram group IDs |
| `MAPULSE_DB

README.md

# Mapulse 🇰🇷

Korean stock market AI analyst — Telegram bot.

Monitor KOSPI/KOSDAQ, track your watchlist, get AI briefings, and ask natural-language questions in Korean, Chinese, or English.

## Quick Start

```bash
pip install python-telegram-bot pykrx requests beautifulsoup4
export TELEGRAM_BOT_TOKEN=your_token_here
cd bot && python3 mapulse_bot.py
```

Open Telegram → find your bot → `/start`

## Environment Variables

| Variable | Required | Description |
|---|---|---|
| `TELEGRAM_BOT_TOKEN` | ❌ | Enables Telegram bot integration (sending and receiving messages). If not provided, Telegram features will be disabled . |
| `OPENROUTER_API_KEY` | ❌ | AI deep analysis (OpenRouter) |
| `ANTHROPIC_API_KEY` | ❌ | AI deep analysis (Anthropic, alternative to OpenRouter) |
| `DART_API_KEY` | ❌ | DART corporate disclosure data (free at https://opendart.fss.or.kr) |
| `ALLOWED_GROUPS` | ❌ | Restrict to specific Telegram group IDs (comma-separated) |

## Features

**Stock Queries** — type naturally:
- 삼성전자 / NAVER / 005930
- 삼성 왜 빠졌어? (why analysis)
- 비교 삼성 하이닉스 (compare)

**Market Overview:**
- 시황 / 코스피 / 업종 (sector rankings)

**Global Assets:**
- 환율 / 비트코인 / 금 / 원유

**Alerts:**
- /alert 005930 3.0 (crash alert at -3%)

**DART Disclosures** (requires DART_API_KEY):
- 삼성 공시

## Data Sources (free, no keys)

- **pykrx** — KRX official KOSPI/KOSDAQ data
- **Yahoo Finance** — real-time quotes, FX, commodities
- **Daum Finance** — sector rankings, trending stocks
- **CoinGecko** — crypto prices

## AI Analysis (optional)

Set `OPENROUTER_API_KEY` or `ANTHROPIC_API_KEY` to enable:
- Cause analysis (why did X drop?)
- Stock comparisons
- Risk/opportunity assessment
- Multi-language responses

Without an AI key, the bot still works — just returns data without deep analysis.

## Project Structure

```
bot/
  mapulse_bot.py        # Telegram bot entry point
scripts/
  chat_query.py         # Query processing & intent classification
  db.py                 # SQLite database layer
  market_data.py        # KRX data via pykrx
  claude_ai.py          # AI analysis layer
  commodities.py        # Commodities & FX data
  crypto.py             # Crypto prices
  crash_alert.py        # Price alert monitoring
  fetch_briefing.py     # Daily briefing generator
  daum_finance.py       # Sector rankings
  cron_*.py             # Scheduled tasks
docs/
  TUTORIAL.md           # Setup tutorial
  architecture.md       # Technical architecture
```

## License

MIT

_meta.json

{
  "ownerId": "kn74b581segnhmrtjgfbncscxs82tbdg",
  "slug": "mapulse-korea",
  "version": "1.0.4",
  "publishedAt": 1779353636523
}

docs/architecture.md

# Architecture — Mapulse v1.1.0

## System Overview

Mapulse is a Korean stock market AI analyst delivered as a Telegram Bot. It combines real-time market data from multiple sources with LLM analysis to provide instant, context-rich answers to stock market questions in Korean, Chinese, and English.

## Core Components

### 1. Telegram Bot (`bot/mapulse_bot.py`)

Entry point. Handles:
- 15 slash commands (see Bot Commands below)
- Natural language messages (routed to chat_query.py)
- Group chat support (responds to @mentions and replies)
- Billing v2 integration (pay-per-call, free trial, Infini Money checkout)

### 2. Query Engine (`scripts/chat_query.py`)

The brain. 2,000+ lines handling 22 intent types:

| Intent | Trigger Examples | Handler |
|--------|-----------------|---------|
| `STOCK_PRICE` | 삼성 / Samsung / 005930 | `handle_stock_price()` |
| `WHY_DROP` | 왜 빠졌어 / 为什么跌 / why drop | `handle_why_move()` |
| `WHY_RISE` | 왜 올랐어 / 为什么涨 / why up | `handle_why_move()` |
| `MARKET_OVERVIEW` | 시장 / 코스피 / 市场 | `handle_market_overview()` |
| `SECTOR_RANKING` | 업종 / 行业 / sector | `handle_sector_ranking()` |
| `HOT_RANK` | 인기 / 热门 / trending | `handle_hot_rank()` |
| `NEWS` | 뉴스 / 新闻 / news | `handle_news()` |
| `COMMUNITY` | 분위기 / 舆论 / sentiment | `handle_community()` |
| `RESEARCH` | 리서치 / 研报 / research | `handle_research()` |
| `SUPPLY_DEMAND` | 수급 / 外资 / foreign | `handle_supply_demand()` |
| `COMPARE` | 비교 / 对比 / compare | `handle_compare()` |
| `OUTLOOK` | 전망 / 怎么看 / outlook | `handle_outlook()` |
| `COMMODITY` | 금시세 / 黄金 / gold | `query_commodity()` |
| `CRYPTO` | 비트코인 / BTC / ETH | `fetch_price()` |
| `DISCLOSURE` | 공시 / 公告 | `fetch_disclosure()` |
| `FINANCIAL` | 재무 / 财务 | `fetch_financial_summary()` |
| `EXCHANGE_RATE` | 환율 / 汇率 / forex | `fetch_exchange_rates()` |
| `FEAR_GREED` | 공포 / VIX | `fetch_fear_greed()` |
| `CHAT` | 자유 대화 | LLM freeform |
| `UNKNOWN` | (unclassified) | fallback |

#### Ticker Resolution (v1.1 updated)

```
Input → resolve_ticker(text)
  ├─ 직접 티커 (6자리 숫자) → return
  ├─ 별명 매칭 (최장매칭 우선, 172개 별명)
  │   정렬: _ALIASES_SORTED = sorted by len(alias) desc
  │   삼성바이오로직스 → 207940 (삼성 보다 먼저 매칭)
  ├─ 정식 이름 매칭 (길이 내림차순)
  └─ KRX API fallback: krx.get_market_ticker_name(ticker)
```

Theme keywords (117개): 반도체, AI, 2차전지, 방산, 바이오, K-POP, etc.

#### Two-Phase Response

```
Phase 1: process_query_fast()  → 1-5 seconds, no LLM
  ├─ Intent classification (keyword match)
  ├─ Ticker resolution (longest-match first)
  ├─ Data fetch (Daum + Naver + pykrx)
  ├─ Format + enhanced data (market cap, PER, 52w)
  └─ Immediate send

Phase 2: process_query_deep()  → 5-20 seconds, LLM
  ├─ Collect: news + community + research + global news
  ├─ AI analysis with full context
  ├─ Trust badge (data source attribution)
  └─ Append send
```

### 3. Data Layer

#### Daum Finance (`scripts/daum_finance.py`)

7 API endpoints, all free, no key required:

| Function | API | Returns |
|----------|-----|---------|
| `fetch_daum_stock(ticker)` | `/api/quotes

docs/changelog.md

# Changelog

All notable changes to Mapulse are documented here.

---

## [1.1.0] — 2026-03-24

### 🔥 Bug Fixes (Critical)
- **상승 TOP에 마이너스 종목 표시** — `gainers` 필터에 `change_pct > 0` 조건 누락으로 전종목 하락일에 -1.0% 종목이 상승 TOP3에 포함되는 버그 수정
- **종목명 미표시** — ticker 직접 입력 시 `277810 (277810)` 처럼 코드만 표시되던 버그 수정. KRX API fallback `_resolve_stock_name()` 추가
- **resolve_ticker 최장매칭** — `삼성바이오로직스` 입력 시 `삼성`이 먼저 매칭되어 삼성전자(005930)로 잘못 조회되는 버그 수정. 별명 길이 내림차순 정렬로 최장매칭 우선
- **레인보우로보틱스 ticker 오류** — 454910(두산로보틱스)으로 잘못 매핑 → 277810으로 수정
- **Telegram Markdown 파싱 오류** — `_이탤릭_` 사용으로 면책 문구·CTA 깨지는 문제 수정

### 🚀 New Features

#### Billing v2 — 사용량 과금 시스템
- `scripts/billing.py` — Pay-per-call 과금 엔진
  - 일반 조회 $0.08/회, 심층 분석 $0.16/회
  - 7일/50회 무료 대화 + 7일 무료 추송 trial
  - 잔액 체크, 사용 기록, trial 만료 안내
- `scripts/infini_pay.py` — Infini Money 결제 게이트웨이 (HMAC-SHA256 인증)
  - 주문 생성 → 호스티드 체크아웃 → 웹훅 수신 → 잔액 자동 충전
  - 최소 충전 $10 USDT
- `scripts/payment_monitor.py` — 결제 상태 모니터링 (cron 1분 간격)
- Bot commands: `/topup`, `/balance`

#### Referral System — 추천 리워드
- `scripts/referral.py` — A→B 추천 시 B 결제금의 15% 를 A에게 USDT 크레딧 지급
  - 추천 코드 자동 생성 (ref_XXXXXX)
  - 누적 커미션 추적
- Bot commands: `/invite`, `/referrals`

#### Platform Push — 4-타임 정기 추송
- `scripts/cron_platform_push.py` — LLM 기반 시황 추송 (OpenRouter)
  - 🌅 08:30 모닝 브리프 (개장 전)
  - 📊 12:20 장중 리포트 (오전장 정리)
  - ⚡ 14:00 오후 핵심 변수 (질문 유도)
  - 🌙 20:50 나이트 브리프 (해외 시장)
- 모든 추송에 🚨 *한 줄 요약* + 📌 *행동 지침* 포함 (v1.1 신규)
- 공개 채널 + 개인 사용자 동시 발송

#### News Intelligence — 뉴스 수집 & 분석
- `scripts/cron_news_aggregate.py` — 뉴스 수집 + 점수화 (news_digest 테이블)
  - Investing.com, Yahoo RSS, 6551.io 소스 통합
  - impact_direction / score 자동 분류
- `scripts/cron_news_scan.py` — 실시간 뉴스 스캔 + 고영향 즉시 push

#### Push Performance Tracker
- `scripts/push_tracker.py` — 추송 성과 추적
  - 추천 종목 추후 가격 변동 기록 (D+1, D+3, D+5)
  - 방향 적중률 / 수익률 통계
  - `/track` command + `backfill` cron

#### User Engagement
- `scripts/cron_day2_survey.py` — Day-2 사용자 프로필 설문 (투자 성향, 관심 섹터)
- `scripts/cron_daily_metrics.py` — 일일 운영 지표 리포트 (DAU, 메시지, 전환율)
- `scripts/trust_badge.py` — 신뢰 배지 시스템 (intent별 데이터 출처 명시)

#### Extended Coverage
- `scripts/extended_aliases.py` — 종목 별명 172개, 종목 59개, 테마 키워드 117개
  - 반도체, AI, 2차전지, 방산, 바이오, K-POP 등 테마 검색 지원
  - 한국어/중국어/영어 트리링걸 별명
- `resolve_multiple_tickers()` — 겹침 방지 + 최장매칭 다중 종목 추출

### Enhanced
- **Stock queries** — 종목 조회 시 KRX에 없는 ticker도 자동 이름 조회 (fallback)
- **Push quality** — SYSTEM_PROMPT에 한 줄 요약 필수, 행동 지침 필수, Markdown 안전 규칙 추가
- **Bot commands** — 15개 명령어 체계: `/start`, `/help`, `/pulse`, `/stock`, `/sector`, `/hot`, `/dart`, `/alert`, `/notify`, `/track`, `/stats`, `/topup`, `/balance`, `/invite`, `/referrals`

### Technical
- systemd service: `mapulse-bot.service` (auto-restart)
- cron: 12개 정기 작업 (push 4회, news 2회, metrics, survey, payment monitor 등)
- LLM: OpenRouter (Haiku fast + Opus deep), temperature 0.4
- DB: SQLite with billing, referral, push_log, news_digest, push_tracking tables

---

## [1.0.0] — 2026-03-17

### Added
- **Daum Finance + Naver Extended Integration**
  -

Sponsored

Ads related to mapulse-korea and adjacent AI workflows.