skills/shioaji/SKILL.md
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)。
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). The Rust reimplementation (rshioaji) transforms Shioaji from a Python-only library into a universal trading platform — any programming language can now trade Taiwan markets through the HTTP API server.
Shioaji 是永豐金證券的跨語言、跨平台交易 API。Rust 重新實作(rshioaji)將 Shioaji 從 Python 專屬函式庫轉變為通用交易平台 — 任何程式語言都能透過 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 clientInstall:
claude plugin marketplace add Sinotrade/rshioaji→claude plugin install rshioajiThis can coexist with the oldSinotrade/Shioajiplugin (different name). At production release, plugin name changes toshioaji.
Official Docs: https://sinotrade.github.io/
For most tasks, load only 1-2 files. Use both axes: what (task) + how (access method).
| Task | Load File | |------|-----------| | Install, login, API keys, CA cert, simulation, env vars, constants | PREPARE.md | | Look up contract codes, attributes, security types | CONTRACTS.md | | Place, modify, cancel orders; combos; order events | 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 | Complete project guide |
| Go | GO.md | Complete project guide |
| C/C++ | CPP.md | Complete project guide |
| C# | CSHARP.md | Complete project guide |
| Rust | RUST.md | HTTP client guide |
| Java/Kotlin | JAVA.md | Complete project guide |
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 (which covers HTTP setup).
import shioaji as sj
api = sj.Shioaji()
api.login(api_key="YOUR_KEY", secret_key="YOUR_SECRET")
uv tool install rshioaji
export SJ_API_KEY=YOUR_KEY SJ_SEC_KEY=YOUR_SECRET
shioaji server start # start HTTP server (simulation)
shioaji order place --code 2330 --action Buy --price 580 --quantity 1
# Server must be running first (see CLI above)
curl http://localhost:8080/api/v1/auth/accounts
curl -X POST http://localhost:8080/api/v1/data/snapshots \
-H "Content-Type: application/json" \
-d '{"contracts":[{"security_type":"STK","exchange":"TSE","code":"2330"}]}'
See PREPARE.md for full installation and setup.
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 |
try:
trade = api.place_order(contract, order)
except Exception as e:
print(f"Order failed: {e}")
HTTP API returns JSON errors: {"code": 400, "message": "...", "details": "..."}
api.logout()
tools
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.
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? | | ------------------------------------------------------ | --------------------------