capital_api
Developer Toolshttps://github.com/AlexChiang0208/capital_api
群益證券/期貨 Python API SDK
About this project
The **capital-api-sdk** is a Python wrapper for the Capital Securities/Futures `SKCOM.dll`, providing an easy-to-use SDK for login, account queries, quote retrieval, real-time quotes, order placement, and reporting. It's implemented based on the official CapitalAPI 2.13.58 manual and Python examples, with quote and account queries tested in production with 76 parameter combinations (as of 2026-07-28). Order methods are aligned with official examples but **not production-tested**—users should verify with small orders first. Key features include: - **Account queries**: Fetch snapshots of balances, positions, orders, and reports (with optional history). - **Quote retrieval**: Get snapshots, ticks, order books, or live streams for stocks, futures, and spread products. - **Order placement**: Support for limit/market orders, odd-lot trading, and order modifications/cancellations (dry-run mode available). - **Real-time streaming**: Collect updates over time or continuously stream events. - **Historical data**: Fetch K-line data (though spread products return 0 rows due to SKCOM limitations). To get started, ensure a Windows environment with `SKCOM.dll` registered (Python bitness must match the DLL). Install with `pip install -e .` and set up `.env` with credentials and DLL path. Basic usage involves logging in and querying accounts or quotes, as shown in the quickstart example.
This is a GitHub repository (source code), not a hosted HTTP API endpoint.
From the docs
Snippets taken from the repository README when available.
from capital_api_sdk import CapitalClient
client = CapitalClient.from_env(enable_live_order=False) # False = 下單只回 dry-run payload
client.login(read_cert=True, connect_reply=True) # connect_reply=True 才收得到委託回報
for account in client.get_accounts():
print(account)