plugins/shioaji/skills/shioaji/SKILL.md
Use this skill whenever the user works with Shioaji, SinoPac (永豐金), or Taiwan financial markets (TWSE/TPEX/TAIFEX) — even if they don't name the library. Covers all access layers: Python binding (sync/async), `shioaji` CLI, HTTP API server with SSE streaming, dashboard with custom-app embedding, and multi-language HTTP clients (JavaScript/TypeScript, Go, C/C++, C#, Rust, Java/Kotlin). Tasks covered: place/modify/cancel stock/futures/options orders (limit, market, ROD/IOC/FOK, margin, short, odd-lot, combo); real-time streaming (tick, bidask, quote) via Python callbacks or HTTP SSE; historical kbars/ticks/snapshots; account balance/margin/positions/P&L; watchlists, scanners, reserve orders; building HTTP/SSE clients in any language against the Shioaji server. Trigger keywords: shioaji, sinopac, 永豐金, 台股, TWSE, TPEX, TAIFEX, 下單, 即時行情, 台灣股票交易, shioaji CLI, shioaji server, SSE streaming. First-time users: when the user says they have never used Shioaji, are using it for the first time, do not know how to start, or asks to be guided step by step, first ask whether they already have a SinoPac securities/futures account and whether they need stock, futures/options, or both. Do not start with install commands, Python snippets, local project inspection, .env/.venv setup, or workspace checks until onboarding gates are confirmed or the user explicitly asks for that technical step. Not for: US/HK markets, Interactive Brokers, generic ta-lib/pandas indicators unless paired with Shioaji data.
npx skillsauth add sinotrade/shioaji shioajiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Shioaji is SinoPac's cross-language, cross-platform trading API for Taiwan financial markets (TWSE/TPEX/TAIFEX). It includes Python bindings, a CLI, and an HTTP API server that lets any programming language trade Taiwan markets.
Shioaji 是永豐金證券的跨語言、跨平台交易 API,提供 Python 綁定、CLI 與 HTTP API 伺服器,讓任何程式語言都能透過 HTTP API 交易台灣市場。
Three access layers / 三種存取層:
import shioaji) for best performance, sync and asyncshioaji command-line tool for server management, trading, and data querieslocalhost:8080, accessible from JS/TS, Go, C/C++, C#, Rust, Java/Kotlin, or any HTTP clientReasoning about connections, timeouts, processes, or state? Read CONCEPTS.md first. It is the shared mental model these three layers assume — which timeout applies on which path, why Python needs no server but CLI/HTTP share one daemon, the per-person connection cap, streaming vs request-reply. Answer those questions from CONCEPTS.md instead of guessing. 推理連線、逾時、行程或狀態時,先讀 CONCEPTS.md。 這是三個存取層共用的心智模型 — 哪個 timeout 在哪條路徑生效、為何 Python 不需 server 而 CLI/HTTP 共用一個 daemon、每人連線上限、串流 vs 請求-回覆。這類問題從 CONCEPTS.md 找答案,不要猜。
Answer users directly from the bundled references. Do not route users to external documentation pages as a substitute for answering. This skill uses Shioaji 1.5 as the baseline; use MIGRATION.md only for legacy/deprecated idioms. Response handling always belongs in the matching functional reference. When an exact command flag, request field, or response schema must be confirmed, use installed CLI --help or the running server's /openapi.json.
First-time-user response / 首次使用者回應:
https://www.sinotrade.com.tw/newweb/PythonAPIKey/; signing pages do not issue API keys. After signing, do not jump straight to CA; confirm API credentials and run the required simulation login/order tests first. CA download is from the API management page, not the signing pages.https://www.sinotrade.com.tw/openact?strProd=0254&strWeb=0684&s=013211&utm_source=shioaji; API Key and CA use https://www.sinotrade.com.tw/newweb/PythonAPIKey/; stock signing uses https://www.sinotrade.com.tw/newweb/signCenter/S_openAPI/; futures/options signing uses https://www.sinotrade.com.tw/newweb/signCenter/F_openApi/. Never write "same page"/"同上頁面" for API Key or CA when the previous row is a signing page..env, .venv, uv sync, code examples, local file inspection, or order examples until the user confirms the relevant onboarding gates are done or explicitly asks for that technical step.只有在知道或明顯推斷使用者沒用過 Shioaji、第一次使用、不知道怎麼開始、或尚未完成永豐 API 開通時,才走首次使用者流程。不要把所有寬泛「我想用 shioaji」都預設為零經驗。確認/推定為首次使用者後,「請一步一步帶我」「慢慢來」「從零開始」代表沿著開通流程逐步確認,不是允許檢查 workspace 或建立本機入門專案。使用者回答第一個開通問題前,不要執行命令、列出檔案、提 Python 版本、提既有專案、提本機環境。第一步是資格/開通確認,不是技術設定:先確認是否已有永豐證券/期貨帳戶、要用證券或期貨/選擇權、API Key/Secret、API 約定書簽署、模擬登入/下單測試、正式環境 CA、正式就緒檢查。開戶後先確認/建立 API Key 與 Secret Key;簽署頁不會發 API Key,也不可稱為申請金鑰頁。簽署完成後不要直接跳 CA,先確認 API 憑證並跑模擬登入/下單測試。CA 下載在 API 管理頁,不是簽署頁。整理步驟表時每列都要寫明正確 URL;開戶不可使用永豐首頁,必須使用指定開戶頁;API Key 與 CA 不可寫「同上頁面」指向簽署頁。絕對不要要求使用者把 API Key、Secret Key、CA 密碼或憑證內容貼到對話,即使說只暫時使用也不行。除非使用者確認相關前置已完成或明確要求該技術步驟,否則不要進入安裝、.env、.venv、uv sync、程式碼範例、專案檔案檢查或下單範例。
Cross-access-layer response guardrails / 跨層回應守則:
success=false, an error code, or an operation status/message, branch on that field before continuing.PendingSubmit are not final failure/success signals; check the matching functional reference before deciding the next step.Token-efficient lookup / 精簡載入:
Response and Decision Summary, Prerequisites.For most tasks, load only 1-2 files. Use both axes: what (task) + how (access method).
Routing rule: choose the functional reference first, then add the access-method reference only when needed. Functional references own the workflow, payload rules, response shapes, and decision logic for that task. Language references explain how to send requests, receive responses, stream SSE, add auth headers, handle errors, and generate typed clients; they must not restate endpoint-specific business rules. Use HTTP_API.md for endpoint inventory and /openapi.json for exact installed-server schemas.
| Task | Load File |
|------|-----------|
| Understand the architecture: process model, connections, timeout layering, streaming vs request-reply, state | CONCEPTS.md |
| Migrate legacy code or fix deprecated Shioaji idioms | MIGRATION.md |
| Install, login, API keys, CA cert, simulation, env vars, constants | PREPARE.md |
| Install this Shioaji plugin/skill into Claude, Codex, Cursor, or another agent environment | AGENTS.md |
| Look up contract codes, attributes, security types | CONTRACTS.md |
| Place, modify, cancel orders; combos; order_deal_event active order/deal reports (Python callbacks, HTTP order-event SSE) | ORDERS.md |
| Reserve shares for disposition/attention stocks | RESERVE.md |
| Subscribe real-time quotes, tick/bidask/quote callbacks, SSE streams | STREAMING.md |
| Historical ticks, K-bars, snapshots, scanners, credit enquiry | MARKET_DATA.md |
| Account balance, margin, positions, P&L, settlements, limits | ACCOUNTING.md |
| Manage watchlists (CRUD, add/remove contracts) | WATCHLIST.md |
| Non-blocking mode, quote binding, stop orders, advanced patterns | ADVANCED.md |
| Errors, connection issues, troubleshooting | TROUBLESHOOTING.md |
| Access Method | Additional File | Notes |
|---------------|-----------------|-------|
| Python (sync or async) | None — task refs include Python examples | Default path |
| CLI (shioaji command) | CLI.md | Task ref (concept) + CLI.md (commands) |
| HTTP API (any language) | HTTP_API.md | Canonical endpoint inventory |
| JavaScript/TypeScript | JAVASCRIPT.md | HTTP/SSE client patterns |
| Go | GO.md | HTTP/SSE client patterns |
| C/C++ | CPP.md | HTTP/SSE client patterns |
| C# | CSHARP.md | HTTP/SSE client patterns |
| Rust | RUST.md | HTTP/SSE client patterns |
| Java/Kotlin | JAVA.md | HTTP/SSE client patterns |
Python users: load only the task reference (Axis 1).
CLI users: load the task reference + CLI.md.
Other languages: load the task reference + language reference. For example, "use JS to place an order" means load ORDERS.md for payload and Trade decision logic, plus JAVASCRIPT.md for fetch/SSE implementation patterns.
For installation, first-use setup, API keys, signing, CA, login, and readiness checks, load PREPARE.md. 安裝、首次開通、API 金鑰、簽署、CA、登入與就緒檢查請讀 PREPARE.md。
WARNING 警告: Always verify the server mode before placing orders. Production mode executes real trades with real money. 下單前務必確認伺服器模式。正式環境會使用真實資金進行真實交易。
shioaji server check (CLI) or GET /api/v1/info (HTTP — returns simulation field)shioaji server start --production or SJ_PRODUCTION=trueshioaji server stop then shioaji server start (without --production)| Category | Limit | |----------|-------| | Daily Traffic | 500MB–10GB (based on trading volume) | | Quote Query | 50 requests / 5 sec | | Accounting Query | 25 requests / 5 sec | | Connections | 5 per person ID | | Daily Logins | 1000 times |
HTTP API returns JSON errors: {"code": 400, "message": "...", "details": "..."}
Check the task reference before retrying. For example, empty market-data responses, PendingSubmit order status, and success=false subscription responses each require different next steps.
api.logout()
For task examples, see the functional reference (Axis 1). For transport and client patterns, see the language reference (Axis 2). 任務範例請見功能參考(軸 1);傳輸與客戶端模式請見語言參考(軸 2)。
tools
ALWAYS USE THIS SKILL when working with Shioaji, rshioaji, SinoPac, or Taiwan financial markets. Covers ALL access layers: Python native binding (sync and async), CLI tool (`shioaji` command), HTTP API server with SSE streaming, dashboard with custom app embedding, and multi-language SDK integration (JavaScript/TypeScript, Go, C/C++, C#, Rust, Java/Kotlin). Covers: placing/modifying/canceling stock/futures/options orders (buy, sell, limit, market, ROD, IOC, FOK, margin, short selling, odd lot, combo orders), real-time streaming via Python callbacks or HTTP SSE (tick, bidask, quote), historical kbars/ticks/snapshots, account balance/margin/positions/P&L, watchlists, scanners, reserve orders, and automated trading systems on TWSE/TPEX/TAIFEX. Use this skill when users mention: shioaji, rshioaji, sinopac, Taiwan stocks, TWSE, TPEX, TAIFEX, 永豐金, trading API, stock order, futures order, options order, market data streaming, SSE streaming, shioaji CLI, shioaji server, shioaji HTTP API, shioaji dashboard, custom trading app, or building trading clients in any programming language against the shioaji server. 使用 Shioaji、rshioaji、永豐金證券、台灣金融市場交易時務必使用本技能。 涵蓋:Python 原生綁定(同步/非同步)、CLI 命令列工具、HTTP API 伺服器(SSE 即時串流)、 儀表板(自訂應用嵌入)、多語言 SDK 整合(JS/TS、Go、C/C++、C#、Rust、Java/Kotlin)。
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------