{
  "schemaVersion": "1.0",
  "item": {
    "slug": "okx-exchange",
    "name": "OKX Exchange",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/lk2023060901/okx-exchange",
    "canonicalUrl": "https://clawhub.ai/lk2023060901/okx-exchange",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/okx-exchange",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=okx-exchange",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "README.md",
      "README_ZH.md",
      "SKILL.md",
      "docs/decision-engine-guide.md",
      "docs/learning-system-data-management.md",
      "docs/trading-rules.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/okx-exchange"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/okx-exchange",
    "agentPageUrl": "https://openagent3.xyz/skills/okx-exchange/agent",
    "manifestUrl": "https://openagent3.xyz/skills/okx-exchange/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/okx-exchange/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "OKX Exchange Skill",
        "body": "Quantitative trading agent for OKX exchange via the official V5 API.\n\nAPI Docs: https://www.okx.com/docs-v5/en/"
      },
      {
        "title": "Setup (First Time)",
        "body": "# 1. Add credentials to .env\ncat >> ~/.openclaw/workspace/.env << 'EOF'\nOKX_API_KEY=your_key\nOKX_SECRET_KEY=your_secret\nOKX_PASSPHRASE=your_passphrase\nOKX_SIMULATED=1\nEOF\n\n# 2. Run setup\ncd ~/.openclaw/workspace/skills/okx-exchange/scripts\npython setup.py\n\nImportant: OKX_SIMULATED=1 = paper trading (safe). Set to 0 for live trading."
      },
      {
        "title": "Session Init",
        "body": "On every session, load credentials first:\n\nsource ~/.openclaw/workspace/.env\ncd ~/.openclaw/workspace/skills/okx-exchange/scripts"
      },
      {
        "title": "Unified CLI (Recommended)",
        "body": "Use okx.py as the single entry point for all commands:\n\npython3 okx.py help           # Show all commands\npython3 okx.py account        # Portfolio overview\npython3 okx.py buy BTC-USDT market 0.01\npython3 okx.py trend analyze BTC-USDT-SWAP\n\nAll individual scripts remain usable directly, but okx.py is preferred for agent use."
      },
      {
        "title": "Instrument ID Format",
        "body": "TypeFormatExampleSpot{BASE}-{QUOTE}BTC-USDTPerpetual Swap{BASE}-{QUOTE}-SWAPBTC-USDT-SWAPFutures{BASE}-{QUOTE}-{EXPIRY}BTC-USDT-250328\n\ntdMode: cash (spot), cross (cross-margin), isolated (isolated-margin)"
      },
      {
        "title": "Account & Portfolio",
        "body": "python3 okx.py account                          # Full portfolio summary\npython3 okx.py account balance                  # Balances only\npython3 okx.py account balance USDT             # Specific currency\npython3 okx.py account positions                # All positions\npython3 okx.py account orders                   # Pending orders\npython3 okx.py account history                  # Filled order history (SPOT)\npython3 okx.py account history SWAP             # Perpetual swap order history\npython3 okx.py account history SPOT BTC-USDT    # History for specific symbol"
      },
      {
        "title": "Trading Mode (Live / Demo)",
        "body": "python3 okx.py mode           # Show current mode\npython3 okx.py mode demo      # Switch to paper trading (safe)\npython3 okx.py mode live      # Switch to live trading (requires confirmation + LIVE credentials)\n\nLive credentials use separate env vars:\n\nOKX_API_KEY_LIVE / OKX_SECRET_KEY_LIVE / OKX_PASSPHRASE_LIVE"
      },
      {
        "title": "Order Execution",
        "body": "# Spot market buy\npython3 okx.py buy BTC-USDT market 0.01\n\n# Spot limit sell\npython3 okx.py sell BTC-USDT limit 0.01 --px 50000\n\n# Perpetual swap — long with TP/SL (attached to the order)\npython3 okx.py buy BTC-USDT-SWAP market 1 --td cross --pos long --tp 55000 --sl 42000\n\n# Perpetual swap — short\npython3 okx.py sell BTC-USDT-SWAP market 1 --td cross --pos short\n\n# Close position (reduce-only)\npython3 okx.py sell BTC-USDT-SWAP market 1 --td cross --pos long --reduce\n\n# Cancel order\npython3 okx.py cancel BTC-USDT <ord_id>\n\n# Cancel all orders for symbol\npython3 okx.py cancel-all BTC-USDT\n\n# Set leverage\npython3 okx.py leverage BTC-USDT-SWAP 10 --td cross\n\n# Transfer funds between accounts (6=Funding, 18=Trading)\npython3 okx.py transfer USDT 500 funding trading   # Funding → Trading\npython3 okx.py transfer USDT 500 trading funding   # Trading → Funding\n\nSkip confirmation prompt (for automation):\n\npython3 okx.py buy BTC-USDT market 0.01 --no-confirm"
      },
      {
        "title": "Algo Orders (Standalone TP/SL — for existing positions)",
        "body": "Use when a position is already open and you want to add a stop-loss or take-profit separately.\nUnlike --tp/--sl flags (which attach to the entry order), algo orders are independent.\n\n# OCO: TP + SL together — whichever triggers first cancels the other\npython3 okx.py algo oco BTC-USDT-SWAP 1 --tp 55000 --sl 45000 --td cross --pos long --reduce\n\n# Conditional: single stop-loss only\npython3 okx.py algo stop BTC-USDT-SWAP 1 --sl 45000 --td cross --reduce\n\n# List all pending algo orders\npython3 okx.py algo list\npython3 okx.py algo list BTC-USDT-SWAP   # filter by instrument\n\n# Cancel a specific algo order\npython3 okx.py algo cancel BTC-USDT-SWAP <algo_id>\n\nWhen to use which:\n\n--tp/--sl at order time → atomic, guaranteed to attach, best for new entries\nalgo oco → add/replace TP+SL after entry, or adjust levels mid-trade"
      },
      {
        "title": "Trend Following (MA + RSI + MACD)",
        "body": "# Analyze only (no trade)\npython3 okx.py trend analyze BTC-USDT-SWAP --bar 1H\n\n# Run with auto-execution\npython3 okx.py trend run BTC-USDT-SWAP 1 --bar 4H --tp 0.05 --sl 0.03 --td cross --pos long\n\n# Dry run (analysis only, no trade)\npython3 okx.py trend run BTC-USDT-SWAP 1 --dry\n\nSignal logic:\n\nBUY: MA_fast > MA_slow + RSI < 70 + MACD histogram > 0\nSELL: MA_fast < MA_slow + RSI > 30 + MACD histogram < 0"
      },
      {
        "title": "Grid Trading",
        "body": "# Setup grid: BTC-USDT, range 40000-50000, 10 grids, 1000 USDT total\npython3 okx.py grid setup BTC-USDT 40000 50000 10 1000\n\n# Check and rebalance filled orders (run periodically)\npython3 okx.py grid check BTC-USDT\n\n# Stop and cancel all grid orders\npython3 okx.py grid stop BTC-USDT"
      },
      {
        "title": "Spot-Futures Arbitrage",
        "body": "# Scan all pairs for opportunities\npython3 okx.py arb scan\n\n# Check specific pair basis\npython3 okx.py arb basis BTC-USDT BTC-USDT-SWAP\n\n# Open arbitrage position (buy spot + short swap)\npython3 okx.py arb open BTC-USDT BTC-USDT-SWAP 1000 --min-basis 0.1\n\n# Close arbitrage position when basis converges\npython3 okx.py arb close BTC-USDT BTC-USDT-SWAP 0.01 1 --max-basis 0.02"
      },
      {
        "title": "Snapshot Report",
        "body": "Fetches live data from the API on every run, persists the snapshot, and outputs a full report with a real historical tracking table.\n\npython3 okx.py snapshot\n\nOutput includes:\n\nTotal equity, initial capital, % change (relative to first snapshot)\nAvailable USDT, major holdings\nContract positions (entry price, mark price, unrealized PnL, liquidation distance)\nHistorical tracking table (from memory/okx-monitor-snapshots.json, up to 48 entries)\n\nAll figures are sourced directly from the OKX API — no estimates or fabricated values."
      },
      {
        "title": "Automated Monitoring (Cron)",
        "body": "# Default: sl-tp every 5 minutes, scan every 30 minutes\nbash scripts/cron_setup.sh setup\n\n# Custom intervals (dynamic parameters)\nbash scripts/cron_setup.sh setup 1m       # sl-tp every 1 minute\nbash scripts/cron_setup.sh setup 10m 1h   # sl-tp every 10 minutes, scan every 1 hour\n\n# Stop all jobs\nbash scripts/cron_setup.sh teardown\n\n# Show status\nbash scripts/cron_setup.sh status\n\nCron jobs:\n\nokx-sl-tp — periodically runs snapshot + monitor sl-tp, reports live data\nokx-scan  — periodically runs monitor scan, reports strategy signals"
      },
      {
        "title": "Adjust cron interval (via user instruction)",
        "body": "If the user asks to change the monitoring frequency (e.g. \"change to every 10 minutes\"):\n\n# Find the cron job ID first\nopenclaw cron list\n\n# Then edit the interval (replace <id> with the okx-sl-tp job ID)\nopenclaw cron edit <id> --every 10m   # e.g. 1m, 5m, 15m, 30m, 1h"
      },
      {
        "title": "Manual monitor run",
        "body": "python3 okx.py snapshot             # Full account snapshot report (with history — recommended)\npython3 okx.py monitor              # SL/TP check + strategy scan + liquidation risk\npython3 okx.py monitor sl-tp        # Only SL/TP check\npython3 okx.py monitor scan         # Only strategy scan\npython3 okx.py monitor liq-risk     # Liquidation risk check (default: alert if within 10%)\npython3 okx.py monitor liq-risk 5   # Alert if mark price within 5% of liquidation price"
      },
      {
        "title": "CRITICAL: Cron reporting rules",
        "body": "Every cron report MUST call the scripts first. NEVER fabricate, estimate, or reuse previous numbers.\n\nRecommended single command for cron:\n\ncd ~/.openclaw/workspace/skills/okx-exchange/scripts\npython3 okx.py snapshot\npython3 okx.py monitor sl-tp\n\nsnapshot automatically saves the snapshot and generates a report with historical tracking. Forward the output verbatim — do not add, remove, or rephrase any content.\n\nReport only what the scripts actually output. If a script returns an error, report the error — do not substitute with previously seen values.\n\nWhy this matters: Each cron run is an isolated session with no memory of previous runs. Any numbers not fetched from the API in this session are either fabricated or stale."
      },
      {
        "title": "Performance Report",
        "body": "python3 okx.py report daily    # Today's P&L summary\npython3 okx.py report weekly   # Last 7 days\npython3 okx.py report all      # All-time\n\nOutput includes: trade count, win rate, total P&L, best/worst trade, and top-5 coin breakdown."
      },
      {
        "title": "Configuration",
        "body": "View or update preferences without editing JSON directly:\n\npython3 okx.py prefs show\npython3 okx.py prefs set auto_trade true\npython3 okx.py prefs set stop_loss_pct 3.0\npython3 okx.py prefs set watchlist BTC-USDT-SWAP,ETH-USDT-SWAP,SOL-USDT-SWAP\n\nFull preferences schema (~/.openclaw/workspace/memory/okx-trading-preferences.json):\n\n{\n  \"max_order_usd\": 100,\n  \"max_leverage\": 10,\n  \"price_impact_warn\": 0.005,\n  \"price_impact_abort\": 0.01,\n  \"require_confirm\": true,\n  \"stop_loss_pct\": 5.0,\n  \"take_profit_pct\": 10.0,\n  \"auto_trade\": false,\n  \"max_position_usd\": 100,\n  \"max_daily_trades\": 10,\n  \"default_sz\": \"0.01\",\n  \"strategies\": [\"trend\"],\n  \"watchlist\": [\"BTC-USDT-SWAP\", \"ETH-USDT-SWAP\"]\n}\n\nParameterDefaultDescriptionmax_order_usd100Max USD per single ordermax_leverage10Max allowed leverageprice_impact_warn0.005Warn if market order impact > 0.5%price_impact_abort0.01Abort if market order impact > 1%require_confirmtruePrompt before placing ordersstop_loss_pct5.0Auto stop-loss at -X% unrealized PnLtake_profit_pct10.0Auto take-profit at +X% unrealized PnLauto_tradefalseExecute trades automatically (no confirmation)max_position_usd100Max USD per positionmax_daily_trades10Max auto-trades per daydefault_sz\"0.01\"Default size for auto-tradingstrategies[\"trend\"]Active strategies: trend / arbitragewatchlist[...]Instruments for monitor scan"
      },
      {
        "title": "Environment Variables",
        "body": "VariableDefaultDescriptionOKX_API_KEY—Demo API keyOKX_SECRET_KEY—Demo API secretOKX_PASSPHRASE—Demo API passphraseOKX_API_KEY_LIVE—Live API key (used when mode=live)OKX_SECRET_KEY_LIVE—Live API secretOKX_PASSPHRASE_LIVE—Live API passphraseOKX_SIMULATED0Set 1 for paper trading (demo account)OKX_WS0Set 1 to enable WebSocket feed (real-time cache for tickers/candles/account/positions)OKX_API_URLhttps://www.okx.comOverride API base URLOKX_LOG_LEVELINFODEBUG / INFO / WARNING / ERROROKX_LOG_FORMATtexttext or json (structured logging)OKX_CRON_MODE0Set 1 to suppress INFO output (for cron)"
      },
      {
        "title": "WebSocket Mode (OKX_WS=1)",
        "body": "When enabled, a background thread maintains real-time caches:\n\nPublic feed: tickers, candles — OKXClient.ticker() / candles() read from cache first\nPrivate feed: account balances, positions, orders — balance() / positions() read from cache first\nREST API is used as fallback when cache is empty or WS is disabled"
      },
      {
        "title": "Trading Rules",
        "body": "Before making any buy/sell decision, read and apply the principles in:\n\ndocs/trading-rules.md\n\nThese rules define how to observe the market, weigh signals, size positions, and learn from outcomes.\nThey do not prescribe a fixed strategy — the agent is expected to adapt its approach based on what the market is actually showing."
      },
      {
        "title": "Safety Rules",
        "body": "Always confirm before placing orders unless auto_trade=true or --no-confirm\nPrice impact check: abort if >1%, warn if >0.5%\nStart with OKX_SIMULATED=1 — validate everything before going live\nNever print or log credentials — load via source .env only\nSet stop-loss on every position — meme coins and leveraged positions can move fast\nDaily trade limit — auto-trading will stop when max_daily_trades is reached"
      },
      {
        "title": "Memory Files",
        "body": "FilePurposememory/okx-trading-preferences.jsonStrategy config, risk parameters, and trading modememory/okx-trading-state.jsonRuntime state (daily trade count, last scan)memory/okx-trading-journal.jsonTrade history from monitor (SL/TP closures, auto-entries)memory/okx-trade-journal.jsonTrade history from learning system (signal analysis)memory/okx-learning-model.jsonLearning model (win rates by coin/regime, optimal params)memory/okx-grid-{inst_id}.jsonGrid state per instrument"
      },
      {
        "title": "Kill Switch",
        "body": "# Stop all automated trading\nbash scripts/cron_setup.sh teardown\n# Or remove OKX_API_KEY from .env to prevent any API calls"
      }
    ],
    "body": "OKX Exchange Skill\n\nQuantitative trading agent for OKX exchange via the official V5 API.\n\nAPI Docs: https://www.okx.com/docs-v5/en/\n\nSetup (First Time)\n# 1. Add credentials to .env\ncat >> ~/.openclaw/workspace/.env << 'EOF'\nOKX_API_KEY=your_key\nOKX_SECRET_KEY=your_secret\nOKX_PASSPHRASE=your_passphrase\nOKX_SIMULATED=1\nEOF\n\n# 2. Run setup\ncd ~/.openclaw/workspace/skills/okx-exchange/scripts\npython setup.py\n\n\nImportant: OKX_SIMULATED=1 = paper trading (safe). Set to 0 for live trading.\n\nSession Init\n\nOn every session, load credentials first:\n\nsource ~/.openclaw/workspace/.env\ncd ~/.openclaw/workspace/skills/okx-exchange/scripts\n\nUnified CLI (Recommended)\n\nUse okx.py as the single entry point for all commands:\n\npython3 okx.py help           # Show all commands\npython3 okx.py account        # Portfolio overview\npython3 okx.py buy BTC-USDT market 0.01\npython3 okx.py trend analyze BTC-USDT-SWAP\n\n\nAll individual scripts remain usable directly, but okx.py is preferred for agent use.\n\nInstrument ID Format\nType\tFormat\tExample\nSpot\t{BASE}-{QUOTE}\tBTC-USDT\nPerpetual Swap\t{BASE}-{QUOTE}-SWAP\tBTC-USDT-SWAP\nFutures\t{BASE}-{QUOTE}-{EXPIRY}\tBTC-USDT-250328\n\ntdMode: cash (spot), cross (cross-margin), isolated (isolated-margin)\n\nAccount & Portfolio\npython3 okx.py account                          # Full portfolio summary\npython3 okx.py account balance                  # Balances only\npython3 okx.py account balance USDT             # Specific currency\npython3 okx.py account positions                # All positions\npython3 okx.py account orders                   # Pending orders\npython3 okx.py account history                  # Filled order history (SPOT)\npython3 okx.py account history SWAP             # Perpetual swap order history\npython3 okx.py account history SPOT BTC-USDT    # History for specific symbol\n\nTrading Mode (Live / Demo)\npython3 okx.py mode           # Show current mode\npython3 okx.py mode demo      # Switch to paper trading (safe)\npython3 okx.py mode live      # Switch to live trading (requires confirmation + LIVE credentials)\n\n\nLive credentials use separate env vars:\n\nOKX_API_KEY_LIVE / OKX_SECRET_KEY_LIVE / OKX_PASSPHRASE_LIVE\n\nOrder Execution\n# Spot market buy\npython3 okx.py buy BTC-USDT market 0.01\n\n# Spot limit sell\npython3 okx.py sell BTC-USDT limit 0.01 --px 50000\n\n# Perpetual swap — long with TP/SL (attached to the order)\npython3 okx.py buy BTC-USDT-SWAP market 1 --td cross --pos long --tp 55000 --sl 42000\n\n# Perpetual swap — short\npython3 okx.py sell BTC-USDT-SWAP market 1 --td cross --pos short\n\n# Close position (reduce-only)\npython3 okx.py sell BTC-USDT-SWAP market 1 --td cross --pos long --reduce\n\n# Cancel order\npython3 okx.py cancel BTC-USDT <ord_id>\n\n# Cancel all orders for symbol\npython3 okx.py cancel-all BTC-USDT\n\n# Set leverage\npython3 okx.py leverage BTC-USDT-SWAP 10 --td cross\n\n# Transfer funds between accounts (6=Funding, 18=Trading)\npython3 okx.py transfer USDT 500 funding trading   # Funding → Trading\npython3 okx.py transfer USDT 500 trading funding   # Trading → Funding\n\n\nSkip confirmation prompt (for automation):\n\npython3 okx.py buy BTC-USDT market 0.01 --no-confirm\n\nAlgo Orders (Standalone TP/SL — for existing positions)\n\nUse when a position is already open and you want to add a stop-loss or take-profit separately. Unlike --tp/--sl flags (which attach to the entry order), algo orders are independent.\n\n# OCO: TP + SL together — whichever triggers first cancels the other\npython3 okx.py algo oco BTC-USDT-SWAP 1 --tp 55000 --sl 45000 --td cross --pos long --reduce\n\n# Conditional: single stop-loss only\npython3 okx.py algo stop BTC-USDT-SWAP 1 --sl 45000 --td cross --reduce\n\n# List all pending algo orders\npython3 okx.py algo list\npython3 okx.py algo list BTC-USDT-SWAP   # filter by instrument\n\n# Cancel a specific algo order\npython3 okx.py algo cancel BTC-USDT-SWAP <algo_id>\n\n\nWhen to use which:\n\n--tp/--sl at order time → atomic, guaranteed to attach, best for new entries\nalgo oco → add/replace TP+SL after entry, or adjust levels mid-trade\nStrategies\nTrend Following (MA + RSI + MACD)\n# Analyze only (no trade)\npython3 okx.py trend analyze BTC-USDT-SWAP --bar 1H\n\n# Run with auto-execution\npython3 okx.py trend run BTC-USDT-SWAP 1 --bar 4H --tp 0.05 --sl 0.03 --td cross --pos long\n\n# Dry run (analysis only, no trade)\npython3 okx.py trend run BTC-USDT-SWAP 1 --dry\n\n\nSignal logic:\n\nBUY: MA_fast > MA_slow + RSI < 70 + MACD histogram > 0\nSELL: MA_fast < MA_slow + RSI > 30 + MACD histogram < 0\nGrid Trading\n# Setup grid: BTC-USDT, range 40000-50000, 10 grids, 1000 USDT total\npython3 okx.py grid setup BTC-USDT 40000 50000 10 1000\n\n# Check and rebalance filled orders (run periodically)\npython3 okx.py grid check BTC-USDT\n\n# Stop and cancel all grid orders\npython3 okx.py grid stop BTC-USDT\n\nSpot-Futures Arbitrage\n# Scan all pairs for opportunities\npython3 okx.py arb scan\n\n# Check specific pair basis\npython3 okx.py arb basis BTC-USDT BTC-USDT-SWAP\n\n# Open arbitrage position (buy spot + short swap)\npython3 okx.py arb open BTC-USDT BTC-USDT-SWAP 1000 --min-basis 0.1\n\n# Close arbitrage position when basis converges\npython3 okx.py arb close BTC-USDT BTC-USDT-SWAP 0.01 1 --max-basis 0.02\n\nSnapshot Report\n\nFetches live data from the API on every run, persists the snapshot, and outputs a full report with a real historical tracking table.\n\npython3 okx.py snapshot\n\n\nOutput includes:\n\nTotal equity, initial capital, % change (relative to first snapshot)\nAvailable USDT, major holdings\nContract positions (entry price, mark price, unrealized PnL, liquidation distance)\nHistorical tracking table (from memory/okx-monitor-snapshots.json, up to 48 entries)\n\nAll figures are sourced directly from the OKX API — no estimates or fabricated values.\n\nAutomated Monitoring (Cron)\n# Default: sl-tp every 5 minutes, scan every 30 minutes\nbash scripts/cron_setup.sh setup\n\n# Custom intervals (dynamic parameters)\nbash scripts/cron_setup.sh setup 1m       # sl-tp every 1 minute\nbash scripts/cron_setup.sh setup 10m 1h   # sl-tp every 10 minutes, scan every 1 hour\n\n# Stop all jobs\nbash scripts/cron_setup.sh teardown\n\n# Show status\nbash scripts/cron_setup.sh status\n\n\nCron jobs:\n\nokx-sl-tp — periodically runs snapshot + monitor sl-tp, reports live data\nokx-scan — periodically runs monitor scan, reports strategy signals\nAdjust cron interval (via user instruction)\n\nIf the user asks to change the monitoring frequency (e.g. \"change to every 10 minutes\"):\n\n# Find the cron job ID first\nopenclaw cron list\n\n# Then edit the interval (replace <id> with the okx-sl-tp job ID)\nopenclaw cron edit <id> --every 10m   # e.g. 1m, 5m, 15m, 30m, 1h\n\nManual monitor run\npython3 okx.py snapshot             # Full account snapshot report (with history — recommended)\npython3 okx.py monitor              # SL/TP check + strategy scan + liquidation risk\npython3 okx.py monitor sl-tp        # Only SL/TP check\npython3 okx.py monitor scan         # Only strategy scan\npython3 okx.py monitor liq-risk     # Liquidation risk check (default: alert if within 10%)\npython3 okx.py monitor liq-risk 5   # Alert if mark price within 5% of liquidation price\n\nCRITICAL: Cron reporting rules\n\nEvery cron report MUST call the scripts first. NEVER fabricate, estimate, or reuse previous numbers.\n\nRecommended single command for cron:\n\ncd ~/.openclaw/workspace/skills/okx-exchange/scripts\npython3 okx.py snapshot\npython3 okx.py monitor sl-tp\n\n\nsnapshot automatically saves the snapshot and generates a report with historical tracking. Forward the output verbatim — do not add, remove, or rephrase any content.\n\nReport only what the scripts actually output. If a script returns an error, report the error — do not substitute with previously seen values.\n\nWhy this matters: Each cron run is an isolated session with no memory of previous runs. Any numbers not fetched from the API in this session are either fabricated or stale.\n\nPerformance Report\npython3 okx.py report daily    # Today's P&L summary\npython3 okx.py report weekly   # Last 7 days\npython3 okx.py report all      # All-time\n\n\nOutput includes: trade count, win rate, total P&L, best/worst trade, and top-5 coin breakdown.\n\nConfiguration\n\nView or update preferences without editing JSON directly:\n\npython3 okx.py prefs show\npython3 okx.py prefs set auto_trade true\npython3 okx.py prefs set stop_loss_pct 3.0\npython3 okx.py prefs set watchlist BTC-USDT-SWAP,ETH-USDT-SWAP,SOL-USDT-SWAP\n\n\nFull preferences schema (~/.openclaw/workspace/memory/okx-trading-preferences.json):\n\n{\n  \"max_order_usd\": 100,\n  \"max_leverage\": 10,\n  \"price_impact_warn\": 0.005,\n  \"price_impact_abort\": 0.01,\n  \"require_confirm\": true,\n  \"stop_loss_pct\": 5.0,\n  \"take_profit_pct\": 10.0,\n  \"auto_trade\": false,\n  \"max_position_usd\": 100,\n  \"max_daily_trades\": 10,\n  \"default_sz\": \"0.01\",\n  \"strategies\": [\"trend\"],\n  \"watchlist\": [\"BTC-USDT-SWAP\", \"ETH-USDT-SWAP\"]\n}\n\nParameter\tDefault\tDescription\nmax_order_usd\t100\tMax USD per single order\nmax_leverage\t10\tMax allowed leverage\nprice_impact_warn\t0.005\tWarn if market order impact > 0.5%\nprice_impact_abort\t0.01\tAbort if market order impact > 1%\nrequire_confirm\ttrue\tPrompt before placing orders\nstop_loss_pct\t5.0\tAuto stop-loss at -X% unrealized PnL\ntake_profit_pct\t10.0\tAuto take-profit at +X% unrealized PnL\nauto_trade\tfalse\tExecute trades automatically (no confirmation)\nmax_position_usd\t100\tMax USD per position\nmax_daily_trades\t10\tMax auto-trades per day\ndefault_sz\t\"0.01\"\tDefault size for auto-trading\nstrategies\t[\"trend\"]\tActive strategies: trend / arbitrage\nwatchlist\t[...]\tInstruments for monitor scan\nEnvironment Variables\nVariable\tDefault\tDescription\nOKX_API_KEY\t—\tDemo API key\nOKX_SECRET_KEY\t—\tDemo API secret\nOKX_PASSPHRASE\t—\tDemo API passphrase\nOKX_API_KEY_LIVE\t—\tLive API key (used when mode=live)\nOKX_SECRET_KEY_LIVE\t—\tLive API secret\nOKX_PASSPHRASE_LIVE\t—\tLive API passphrase\nOKX_SIMULATED\t0\tSet 1 for paper trading (demo account)\nOKX_WS\t0\tSet 1 to enable WebSocket feed (real-time cache for tickers/candles/account/positions)\nOKX_API_URL\thttps://www.okx.com\tOverride API base URL\nOKX_LOG_LEVEL\tINFO\tDEBUG / INFO / WARNING / ERROR\nOKX_LOG_FORMAT\ttext\ttext or json (structured logging)\nOKX_CRON_MODE\t0\tSet 1 to suppress INFO output (for cron)\nWebSocket Mode (OKX_WS=1)\n\nWhen enabled, a background thread maintains real-time caches:\n\nPublic feed: tickers, candles — OKXClient.ticker() / candles() read from cache first\nPrivate feed: account balances, positions, orders — balance() / positions() read from cache first\nREST API is used as fallback when cache is empty or WS is disabled\nTrading Rules\n\nBefore making any buy/sell decision, read and apply the principles in:\n\ndocs/trading-rules.md\n\n\nThese rules define how to observe the market, weigh signals, size positions, and learn from outcomes. They do not prescribe a fixed strategy — the agent is expected to adapt its approach based on what the market is actually showing.\n\nSafety Rules\nAlways confirm before placing orders unless auto_trade=true or --no-confirm\nPrice impact check: abort if >1%, warn if >0.5%\nStart with OKX_SIMULATED=1 — validate everything before going live\nNever print or log credentials — load via source .env only\nSet stop-loss on every position — meme coins and leveraged positions can move fast\nDaily trade limit — auto-trading will stop when max_daily_trades is reached\nMemory Files\nFile\tPurpose\nmemory/okx-trading-preferences.json\tStrategy config, risk parameters, and trading mode\nmemory/okx-trading-state.json\tRuntime state (daily trade count, last scan)\nmemory/okx-trading-journal.json\tTrade history from monitor (SL/TP closures, auto-entries)\nmemory/okx-trade-journal.json\tTrade history from learning system (signal analysis)\nmemory/okx-learning-model.json\tLearning model (win rates by coin/regime, optimal params)\nmemory/okx-grid-{inst_id}.json\tGrid state per instrument\nKill Switch\n# Stop all automated trading\nbash scripts/cron_setup.sh teardown\n# Or remove OKX_API_KEY from .env to prevent any API calls"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/lk2023060901/okx-exchange",
    "publisherUrl": "https://clawhub.ai/lk2023060901/okx-exchange",
    "owner": "lk2023060901",
    "version": "1.0.1",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/okx-exchange",
    "downloadUrl": "https://openagent3.xyz/downloads/okx-exchange",
    "agentUrl": "https://openagent3.xyz/skills/okx-exchange/agent",
    "manifestUrl": "https://openagent3.xyz/skills/okx-exchange/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/okx-exchange/agent.md"
  }
}