Shiaoji SinoPac 永豐金證券 Python API
- python >= 3.9
- Shioaji v1.2.5 (2025-02-19)
pip install -r requirements.txt
pip install shioaji[speed]
cp .env.template .env
api = sj.Shioaji(simulation=True) # 模擬模式登入
accounts = api.login(
api_key=os.getenv('API_KEY'),
secret_key=os.getenv('SECRET_KEY')
)
accounts
Response Code: 0 | Event Code: 0 | Info: host '203.66.91.161:80', hostname '203.66.91.161:80' IP 203.66.91.161:80 (host 1 of 1) (host connection attempt 1 of 1) (total connection attempt 1 of 1) | Event: Session up[FutureAccount(person_id='F123456789', broker_id='F002000', account_id='1234567', signed=True, username='莊OO'), StockAccount(person_id='F123456789', broker_id='9A95', account_id='1234568', signed=True, username='莊OO')]
CA_CERT_PATH="C:/ekey/1234/Sinopac.pfx"