Skip to content

Advanced indicator-driven trading bot using EMA/RSI/MACD, volume signals, breakouts, and multi-timeframe analysis to generate automated KAS trading decisions.

Notifications You must be signed in to change notification settings

lorine93s/kaspa-indicator-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaspa Price-Action + Indicator Bot

Production-grade Kaspa trading bot that uses technical indicators and price-action analysis to generate automated trading signals.
Supports multi-timeframe analysis, custom indicator configurations, TradingView webhook integration, and intelligent risk management with trailing stops.

What the Kaspa Indicator Bot Does

  • Multi-timeframe technical analysis using RSI, MACD, EMA, VWAP, Bollinger Bands, and ATR.
  • Price-action strategies including breakouts, volume spikes, and trend-following signals.
  • Smart risk management with configurable stop-loss, take-profit, and trailing stops.
  • TradingView webhook integration for external signal injection.
  • Real-time candle data from exchange APIs (CCXT).
  • YAML strategy configuration for easy strategy customization without code changes.

Note: Kaspa blockchain is used for settling profits and transferring funds only.
Trading signals are generated from exchange candle data, not on-chain data.

Core Features

Technical Indicators

  • RSI (Relative Strength Index) – Oversold/overbought detection
  • MACD – Trend momentum and crossover signals
  • EMA (Exponential Moving Average) – Trend direction and crossovers
  • VWAP (Volume-Weighted Average Price) – Intraday support/resistance
  • Bollinger Bands – Volatility-based entry/exit signals
  • ATR (Average True Range) – Volatility measurement for dynamic stops

Price-Action Strategies

  • Breakout Detection – Identifies price breaking above/below recent highs/lows
  • Volume Triggers – Signals when volume exceeds threshold (e.g., 1.5x average)
  • EMA Crossovers – Bullish/bearish crossovers between fast and slow EMAs
  • Multi-timeframe Analysis – Combines signals from multiple timeframes (15m, 1h, 4h)

Risk Management

  • Stop-Loss Orders – Configurable percentage-based stop losses
  • Take-Profit Targets – Automatic profit-taking at target levels
  • Trailing Stops – Dynamic stop-loss that follows price movement
  • Position Size Limits – Maximum position size in USD

Data Sources

  • Exchange Candle API – Real-time OHLCV data via CCXT
  • TradingView Webhook – External signal injection via HTTP POST
  • Multi-timeframe Support – Simultaneous analysis across multiple timeframes

Technical Requirements

Indicator Engine

  • pandas-ta – Technical analysis library for indicator calculations
  • pandas – Data manipulation and time-series analysis
  • numpy – Numerical computations

Exchange Integration

  • CCXT – Unified exchange API for candle data
  • Supported exchanges: MEXC, Gate.io, KuCoin, Bitget, BingX, Kraken, and 100+ others

Infrastructure

  • Python 3.11+ with asyncio for concurrent data fetching
  • FastAPI + Uvicorn for TradingView webhook server
  • Prometheus metrics for monitoring signals, positions, and profitability
  • Structured JSON logging via structlog

Kaspa Integration

  • Kaspa wallet address for profit settlement (optional)
  • On-chain transfers only when signals trigger profitable exits

Architecture Overview

┌──────────────────┐      ┌──────────────────────┐      ┌──────────────────┐
│ Exchange APIs    │      │ CandleFetcher        │      │ IndicatorEngine  │
│ (OHLCV Data)     │ ---> │ (Multi-timeframe)    │ ---> │ (RSI, MACD, etc)│
└──────────────────┘      └──────────────────────┘      └──────────────────┘
         │                           │                            │
         │                           v                            │
         │                  ┌──────────────────┐                 │
         │                  │ SignalGenerator  │                 │
         │                  │ (Breakouts, etc) │                 │
         │                  └──────────────────┘                 │
         │                           │                            │
         v                           v                            v
┌──────────────────┐      ┌──────────────────┐      ┌──────────────────┐
│ TradingView      │      │ OrderManager     │      │ Risk Management  │
│ Webhook          │      │ (Position mgmt)  │      │ (Stops, Limits)  │
└──────────────────┘      └──────────────────┘      └──────────────────┘

Key Modules

  • src/config.py – Pydantic settings for exchanges, timeframes, and risk parameters.
  • src/data/candle_fetcher.py – Multi-timeframe OHLCV data fetching from exchanges.
  • src/indicators/indicator_engine.py – Technical indicator calculations (RSI, MACD, EMA, VWAP).
  • src/signals/signal_generator.py – Price-action and indicator-based signal generation.
  • src/strategies/price_action_strategy.py – Strategy logic with breakout, volume, and trend detection.
  • src/execution/order_manager.py – Position management with trailing stops and risk controls.
  • src/services/tradingview_webhook.py – HTTP webhook server for TradingView alerts.
  • src/main.py – Async entrypoint that orchestrates data fetching, analysis, and execution.

Getting Started

1. Requirements

  • Python 3.11+
  • Exchange API keys for at least 1 exchange (MEXC, Gate.io, KuCoin, etc.).
  • API keys must have trading permissions enabled.
  • Exchange account with sufficient balance for trading.

2. Install

git clone https://github.com/your-org/kaspa-indicator-bot.git
cd kaspa-indicator-bot
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt

3. Configure Environment

Create a .env file:

ENVIRONMENT=development

# Exchange credentials
EXCHANGES_JSON=[{"name":"mexc","api_key":"xxx","secret_key":"yyy"}]

# Trading pair
TRADING_PAIR=KAS/USDT

# Timeframes
PRIMARY_TIMEFRAME=15m
ANALYSIS_TIMEFRAMES=["15m","1h","4h"]

# Strategy configuration
STRATEGY_CONFIG_PATH=strategies/default.yaml

# Risk management
MAX_POSITION_SIZE_USD=1000.0
TRAILING_STOP_PCT=2.0
TAKE_PROFIT_PCT=5.0
STOP_LOSS_PCT=3.0

# TradingView webhook (optional)
TRADINGVIEW_WEBHOOK_ENABLED=false
TRADINGVIEW_WEBHOOK_PORT=8080

# Kaspa integration (optional)
KASPA_SETTLEMENT_ENABLED=false
KASPA_WALLET_ADDRESS=

# Metrics and logging
METRICS_HOST=0.0.0.0
METRICS_PORT=9304
LOG_LEVEL=INFO

4. Configure Strategy

Edit strategies/default.yaml to customize indicator parameters and signal triggers:

indicators:
  rsi_length: 14
  rsi_oversold: 30
  rsi_overbought: 70
  macd_fast: 12
  macd_slow: 26
  ema_length: 20

signals:
  breakout_enabled: true
  rsi_enabled: true
  macd_enabled: true
  volume_spike_enabled: true
  volume_threshold: 1.5
  ema_cross_enabled: true
  vwap_enabled: true

risk_management:
  max_position_size_usd: 1000.0
  stop_loss_pct: 3.0
  take_profit_pct: 5.0
  trailing_stop_pct: 2.0

5. Run the Indicator Bot

python -m src.main

The bot will:

  • Fetch multi-timeframe candle data from the exchange.
  • Calculate technical indicators (RSI, MACD, EMA, VWAP, etc.).
  • Generate trading signals based on price-action and indicator conditions.
  • Execute trades when signals meet your strategy criteria.
  • Manage positions with stop-loss, take-profit, and trailing stops.
  • Log all signals and executions.
  • Expose Prometheus metrics on http://localhost:9304/metrics.

6. Docker Support

docker compose up --build

Services:

  • indicator-bot – Main trading bot process.
  • Prometheus metrics exposed on port 9304.
  • TradingView webhook server on port 8080 (if enabled).

Strategy Examples

RSI + MACD Strategy

Enable RSI oversold (< 30) and MACD bullish crossover:

signals:
  rsi_enabled: true
  rsi_oversold: 30
  macd_enabled: true

Breakout + Volume Strategy

Trade breakouts above 20-period high with volume confirmation:

signals:
  breakout_enabled: true
  breakout_period: 20
  volume_spike_enabled: true
  volume_threshold: 1.5

Multi-Timeframe Trend Following

Use EMA crossovers on multiple timeframes:

signals:
  ema_cross_enabled: true
  ema_fast: 12
  ema_slow: 26

Combine with ANALYSIS_TIMEFRAMES=["15m","1h","4h"] for multi-timeframe confirmation.

TradingView Webhook Integration

Enable webhook server in .env:

TRADINGVIEW_WEBHOOK_ENABLED=true
TRADINGVIEW_WEBHOOK_PORT=8080

Configure TradingView alert to POST to:

POST http://your-bot-ip:8080/webhook
Content-Type: application/json

{
  "signal": "buy",
  "symbol": "KAS/USDT",
  "price": 0.1234
}

The bot will process TradingView signals alongside its own indicator-based signals.

SEO: Who Is This Bot For?

This project is designed for people searching for:

  • Kaspa trading bot with indicators
  • Technical analysis bot for KAS
  • Price-action trading bot
  • RSI MACD EMA trading bot
  • Multi-timeframe trading bot
  • TradingView webhook bot
  • Kaspa automated trading

It provides a production-ready codebase for:

  • Automating trades based on technical indicators and price-action patterns.
  • Combining multiple timeframes for signal confirmation.
  • Managing risk with stop-loss, take-profit, and trailing stops.
  • Integrating external signals via TradingView webhooks.

Monitoring & Observability

Prometheus Metrics

  • kas_indicator_signals_total – Counter of signals generated by type and source.
  • kas_indicator_position_usd – Gauge of current position size in USD.
  • kas_indicator_profit_usd – Gauge of cumulative profit in USD.
  • kas_indicator_value – Gauge of current indicator values by indicator and timeframe.
  • kas_indicator_execution_latency_seconds – Histogram of signal execution times.

Access metrics at: http://localhost:9304/metrics

Structured Logging

All events are logged as JSON via structlog:

  • Signal generation events with indicator values.
  • Position open/close events.
  • Risk management triggers (stop-loss, take-profit).
  • Error details with context.

Performance & Optimization

  • Data Fetching: Fetches candles from exchange every 60 seconds (configurable).
  • Multi-timeframe: Analyzes 3+ timeframes simultaneously.
  • Indicator Calculations: Uses optimized pandas-ta library for fast indicator computation.
  • Optimization Tips:
    • Use shorter timeframes (15m, 5m) for more frequent signals.
    • Combine multiple indicators for stronger signal confirmation.
    • Test strategies on historical data before live trading.

Risk Management

  • Start Small: Use low MAX_POSITION_SIZE_USD values initially.
  • Test Strategies: Validate indicator combinations on historical data.
  • Set Stops: Always configure stop-loss and take-profit percentages.
  • Trailing Stops: Enable trailing stops to lock in profits on trending moves.
  • Multi-timeframe: Require signal confirmation across multiple timeframes to reduce false signals.

Future Enhancements

  • Backtesting Framework: Historical strategy performance testing (cancelled in current version).
  • Machine Learning: ML-based signal weighting and entry/exit optimization.
  • Advanced Indicators: Custom indicator combinations and proprietary formulas.
  • Kaspa Settlement: Automated on-chain transfers when profits exceed threshold.
  • Portfolio Management: Multi-asset support and portfolio-level risk controls.

Development & Linting

ruff check src
black src
pytest

License

Use at your own risk. Technical indicator trading involves capital risk and market volatility.
You are responsible for ensuring compliance with local regulations and exchange terms of service before running this in production.

Safety & Compliance

  • This bot executes real trades based on technical signals. Test thoroughly before using real funds.
  • Review your jurisdiction's rules for automated trading.
  • Ensure exchange API keys have appropriate permissions and IP allowlists configured.
  • Monitor all signals and executions, maintain audit logs for compliance.
  • Use position limits and stop-losses in production environments.

About

Advanced indicator-driven trading bot using EMA/RSI/MACD, volume signals, breakouts, and multi-timeframe analysis to generate automated KAS trading decisions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published