moonpay-trading-automation

通过结合 mp CLI 命令与操作系统调度(如 cron 或 launchd)设置自动化交易策略,包括定投(DCA)、限价单和止损单。

仓库最近推送
GitHub Stars
112
Forks
31
Issues / PRs
4

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "moonpay-trading-automation":https://skillpi.com/zh/skills/deepskill-e9c8f5f2991f3341c1a1ab58463399deb0aa7f67a389c819194b75ff5863db4a。安装前核对上游来源和版本:https://github.com/moonpay/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

通过结合 mp CLI 命令与操作系统调度(如 cron 或 launchd)设置自动化交易策略,包括定投(DCA)、限价单和止损单。

0 下载

介绍来源: third_party · moonpay · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
来源文档未说明。
输入和输出
来源文档未说明。
软件、账号及付费要求
翻译待完成,请参阅来源文档。
限制与区别
来源文档未说明。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: moonpay-trading-automation
description: Set up automated trading strategies — DCA, limit orders, and stop losses — by composing mp CLI commands with OS scheduling (cron/launchd).
tags: [trading, automation]

Trading automation

Goal

Compose mp CLI commands with OS scheduling (cron/launchd) to run unattended trading strategies: dollar-cost averaging, limit orders, and stop losses. The agent generates shell scripts and schedules them — no new tools needed.

Prerequisites

  • Authenticated: mp user retrieve
  • Funded wallet: mp token balance list --wallet <name> --chain <chain>
  • mp binary on PATH: which mp (note the full path for scheduled scripts)
  • jq installed: which jq

Shell script pattern

Every strategy uses the same base pattern. Scripts live in ~/.config/moonpay/scripts/ and log to ~/.config/moonpay/logs/trading.log.

#!/bin/bash
set -euo pipefail

MP="$(which mp)"  # absolute path for cron/launchd
LOG="$HOME/.config/moonpay/logs/trading.log"
mkdir -p "$(dirname "$LOG")"

log() { echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*" >> "$LOG"; }

# --- Config (agent fills these in) ---
WALLET="main"
CHAIN="solana"
FROM_TOKEN="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"  # USDC
TO_TOKEN="So11111111111111111111111111111111111111111"         # SOL
AMOUNT=5

# --- Execute ---
log "SWAP: $AMOUNT $FROM_TOKEN -> $TO_TOKEN on $CHAIN"
RESULT=$("$MP" --json token swap \
  --wallet "$WALLET" --chain "$CHAIN" \
  --from-token "$FROM_TOKEN" --from-amount "$AMOUNT" \
  --to-token "$TO_TOKEN" 2>&1) || {
  log "FAILED: $RESULT"
  exit 1
}
log "OK: $RESULT"

Key points:

  • mp --json outputs single-line JSON, ideal for jq parsing
  • Use $(which mp) and store as MP — cron/launchd have minimal PATH
  • Wallet names only in scripts — mp handles keychain decryption at runtime
  • If the user gives token names/symbols, resolve to addresses first with mp token search

DCA (Dollar-Cost Averaging)

"Buy $5 of SOL every day at 9am"

Script: ~/.config/moonpay/scripts/dca-sol.sh

Use the base pattern above with the user's token, amount, wallet, and chain.

Schedule with cron (Linux)

# Buy $5 of SOL daily at 9am UTC — moonpay:dca-sol
0 9 * * * ~/.config/moonpay/scripts/dca-sol.sh

Add with: (crontab -l 2>/dev/null; echo '0 9 * * * ~/.config/moonpay/scripts/dca-sol.sh # moonpay:dca-sol') | crontab -

Common intervals:

  • Every hour: 0 * * * *
  • Every 4 hours: 0 */4 * * *
  • Daily at 9am: 0 9 * * *
  • Weekly Monday 9am: 0 9 * * 1

Schedule with launchd (macOS)

Write a plist to ~/Library/LaunchAgents/com.moonpay.dca-sol.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.moonpay.dca-sol</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/bash</string>
    <string>/Users/USERNAME/.config/moonpay/scripts/dca-sol.sh</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>9</integer>
    <key>Minute</key>
    <integer>0</integer>
  </dict>
  <key>StandardErrorPath</key>
  <string>/Users/USERNAME/.config/moonpay/logs/dca-sol.err</string>
</dict>
</plist>

Load with: launchctl load ~/Library/LaunchAgents/com.moonpay.dca-sol.plist

Important: Tilde (~) does NOT expand in plist files. Always use the full path (e.g., /Users/USERNAME/...). Get it with echo $HOME.

Limit order

"Buy SOL when price drops below $80"

Script: ~/.config/moonpay/scripts/limit-buy-sol.sh

#!/bin/bash
set -euo pipefail

MP="$(which mp)"
LOG="$HOME/.config/moonpay/logs/trading.log"
mkdir -p "$(dirname "$LOG")"
log() { echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*" >> "$LOG"; }

# --- Config ---
WALLET="main"
CHAIN="solana"
TOKEN="So11111111111111111111111111111111111111111"
BUY_WITH="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"  # USDC
BUY_AMOUNT=50
TARGET_PRICE=80
SCRIPT_NAME="limit-buy-sol"

# --- Check price ---
PRICE=$("$MP" --json token search --query "$TOKEN" --chain "$CHAIN" | jq -r '.items[0].marketData.price')

if [ -z "$PRICE" ] || [ "$PRICE" = "null" ]; then
  log "LIMIT $SCRIPT_NAME: price fetch failed, skipping"
  exit 0
fi

# --- Compare ---
if (( $(echo "$PRICE < $TARGET_PRICE" | bc -l) )); then
  log "LIMIT $SCRIPT_NAME: price $PRICE < $TARGET_PRICE — executing buy"
  RESULT=$("$MP" --json token swap \
    --wallet "$WALLET" --chain "$CHAIN" \
    --from-token "$BUY_WITH" --from-amount "$BUY_AMOUNT" \
    --to-token "$TOKEN" 2>&1) || {
    log "LIMIT $SCRIPT_NAME FAILED: $RESULT"
    exit 1
  }
  log "LIMIT $SCRIPT_NAME OK: bought at $PRICE — $RESULT"

  # Self-disable after fill
  if [[ "$OSTYPE" == "darwin"* ]]; then
    launchctl unload "$HOME/Library/LaunchAgents/com.moonpay.${SCRIPT_NAME}.plist" 2>/dev/null || true
  else
    crontab -l | grep -v "$SCRIPT_NAME" | crontab -
  fi
  log "LIMIT $SCRIPT_NAME: disabled after fill"
else
  log "LIMIT $SCRIPT_NAME: price $PRICE >= $TARGET_PRICE — waiting"
fi

Schedule every 5 minutes:

  • Cron: */5 * * * * ~/.config/moonpay/scripts/limit-buy-sol.sh # moonpay:limit-buy-sol
  • Launchd: use <key>StartInterval</key><integer>300</integer> instead of StartCalendarInterval

Stop loss

"Sell all my SOL if price drops below $70"

Same structure as limit order but sells instead of buys. For "sell all", query the balance first:

# --- Config ---
SELL_TOKEN="So11111111111111111111111111111111111111111"   # SOL
TO_TOKEN="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" # USDC
TRIGGER_PRICE=70
SCRIPT_NAME="stop-loss-sol"

# --- Check price ---
PRICE=$("$MP" --json token search --query "$SELL_TOKEN" --chain "$CHAIN" | jq -r '.items[0].marketData.price')

if (( $(echo "$PRICE < $TRIGGER_PRICE" | bc -l) )); then
  # Get current balance to sell all
  BALANCE=$("$MP" --json token balance list --wallet "$WALLET" --chain "$CHAIN" \
    | jq -r --arg addr "$SELL_TOKEN" '.items[] | select(.address == $addr) | .balance.amount')

  if [ -n "$BALANCE" ] && (( $(echo "$BALANCE > 0" | bc -l) )); then
    log "STOP-LOSS $SCRIPT_NAME: price $PRICE < $TRIGGER_PRICE — selling $BALANCE"
    RESULT=$("$MP" --json token swap \
      --wallet "$WALLET" --chain "$CHAIN" \
      --from-token "$SELL_TOKEN" --from-amount "$BALANCE" \
      --to-token "$TO_TOKEN" 2>&1) || {
      log "STOP-LOSS $SCRIPT_NAME FAILED: $RESULT"
      exit 1
    }
    log "STOP-LOSS $SCRIPT_NAME OK: sold at $PRICE — $RESULT"
    # Self-disable (same pattern as limit order)
  fi
fi

Managing automations

List active automations

# macOS
launchctl list | grep moonpay

# Linux
crontab -l | grep moonpay

Remove an automation

# macOS
launchctl unload ~/Library/LaunchAgents/com.moonpay.dca-sol.plist
rm ~/Library/LaunchAgents/com.moonpay.dca-sol.plist

# Linux
crontab -l | grep -v "moonpay:dca-sol" | crontab -

View logs

tail -50 ~/.config/moonpay/logs/trading.log

Pause / resume (macOS only)

launchctl unload ~/Library/LaunchAgents/com.moonpay.dca-sol.plist   # pause
launchctl load ~/Library/LaunchAgents/com.moonpay.dca-sol.plist     # resume

Platform detection

Detect the OS and use the appropriate scheduler:

if [[ "$OSTYPE" == "darwin"* ]]; then
  # macOS: use launchd (fires even if machine was asleep)
else
  # Linux: use crontab
fi

Tips

  • Start with a small DCA amount to verify the setup works before going bigger
  • Check logs after the first run: tail -20 ~/.config/moonpay/logs/trading.log
  • Scripts don't contain secrets — mp decrypts wallets via OS keychain at runtime
  • The machine must be logged in (user session active) for keychain access to work
  • Price checks via mp token search are free; swaps cost gas
  • Limit order checks every 5 minutes is reasonable — don't go below 1 minute
  • Use bc -l for decimal price comparison (bash can't compare floats natively)
  • If bc isn't available, use: awk "BEGIN {exit !($PRICE < $TARGET)}"
  • Always tag cron entries with # moonpay:{name} so they can be found and removed

Related skills

  • moonpay-swap-tokens — Swap and bridge command syntax
  • moonpay-check-wallet — Check balances before setting up automation
  • moonpay-discover-tokens — Research tokens and resolve addresses
  • moonpay-price-alerts — Observe-only price notifications (no trading)

当前收录版本

0.0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值95/100

亮点

  • 提供自动化交易策略(定投、限价单、止损单),直接解决用户核心交易痛点
  • 显著提升日常高频交易场景的效率,具有高实用价值
触发精准95/100

亮点

  • 触发词精准完整,覆盖多种变体,边界清晰
  • description 明确描述自动化交易策略,易于用户理解
结构规范95/100

亮点

  • Phase/步骤清晰,有出口条件,含端到端示例
  • frontmatter完整,单文件≤500行,结构规范
执行可靠95/100

亮点

  • 工具来源明确(mp CLI),参数正确
  • 覆盖主要异常,不可逆操作有确认机制,执行可靠性高
证据可验 (前四项均值)95/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • www.apple.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

翻译待完成,请参阅来源文档。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。