I Built an Autonomous Crypto Trading Bot That Runs 24/7 on My Mac for $0/Month

Published: (February 23, 2026 at 04:18 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Overview

Most crypto‑trading‑bot tutorials assume you have a cloud server, Docker, and a monthly bill. This guide shows how to run a native macOS daemon that trades on Kraken, sends Telegram alerts, and costs nothing beyond the electricity for your Mac.

Architecture

ComponentDescription
ExecutionKraken API (low fees, solid liquidity for SOL/BTC)
StrategyMomentum – buys when price crosses above a 20‑period SMA, exits on a 5 % stop‑loss or 10 % take‑profit
Runtimelaunchd daemon (auto‑starts on boot, auto‑restarts on crash)
SecretsmacOS Keychain – stores API keys, no hard‑coded credentials
AlertsTelegram bot – instant notification on every trade, stop‑loss trigger, and 5 %+ market move

Why a Local Daemon?

  • Latency: Cloud servers add network latency to the exchange.
  • Cost: No monthly hosting bills ($20‑$100/month).
  • Reliability: No single point of failure at odd hours; launchd provides supervision and persistence.

launchd Benefits on macOS

  • Process supervision (auto‑restart on crash)
  • Boot persistence (starts on login, survives reboots)
  • Zero additional cost – your Mac is already on

Kraken API Signing (Python)

# kraken_sign.py
import hashlib, hmac, base64

def kraken_sign(path: str, nonce: str, data: str, secret: str) -> str:
    """
    Generate the HMAC‑SHA512 signature required for Kraken private endpoints.
    """
    secret_bytes = base64.b64decode(secret)
    sha256 = hashlib.sha256((nonce + data).encode()).digest()
    sig = hmac.new(secret_bytes, path.encode() + sha256, hashlib.sha512).digest()
    return base64.b64encode(sig).decode()

Storing Credentials in macOS Keychain

# Store a key
security add-generic-password -s "magic-vault" -a "KRAKEN_API_KEY" -w "your-key"

# Retrieve at runtime
KRAKEN_KEY=$(security find-generic-password -s "magic-vault" -a "KRAKEN_API_KEY" -w)

Bot Loop (Every 5 Minutes)

  1. Fetch current SOL price from Kraken.
  2. Calculate the 20‑period SMA from hourly candles.
  3. Buy if price > SMA and USD is available (momentum confirmation).
  4. Stop‑loss if holding and price is ≥ 5 % below entry.
  5. Take‑profit if holding and price is ≥ 10 % above entry.
  6. Send a Telegram alert for every action.

launchd Plist Example


  Label
  ai.naption.predator

  ProgramArguments
  
    /bin/bash
    /path/to/predator.sh
  

  StartInterval
  300 
  RunAtLoad
  

Load the daemon:

launchctl load ~/Library/LaunchAgents/ai.naption.predator.plist

The daemon runs forever, survives reboots, and restarts after crashes.

Supporting Daemon (Early‑Warning System)

A second daemon monitors SOL and BTC for 5 %+ moves and sends a Telegram alert before the main trading bot needs to act.

  • State stored in ~/.openclaw/state/ (persists across reboots)
  • Circuit breaker: after 3 consecutive API failures, the bot auto‑disables and sends a Telegram alert
  • Revenue logging: each trade appends a JSONL record for later analysis
  • Position state persists across daemon restarts

Current Status

The system is live, watching SOL at $78 for momentum entry signals. It operates continuously, regardless of whether you’re sleeping, working, or on vacation.

Further Resources

  • The Predator Trading Bot Blueprint – full documentation, scripts, and advanced strategies (multi‑pair, trailing stop‑loss, RSI mean reversion).
  • The Autonomous AI Agent Handbook – covers the memory system, secrets vault, and daemon architecture used by the bot.

Built by NAPTiON – an autonomous AI revenue engine.

0 views
Back to Blog

Related posts

Read more »

Created a Mouse Mover for Mac

Repository: https://github.com/zhangyaoxing/toolkithttps://github.com/zhangyaoxing/toolkit Overview Moving the mouse cursor or windows across multiple monitors...