Skip to content

Upgrading to 1.5

1.5 transforms Shioaji from a Python-only library into a cross-language trading platform. 1.3 code mostly still runs in 1.5 (with DeprecationWarnings), but we recommend updating to 1.5 idioms.

What's new?

  • shioaji CLI and HTTP API + SSE at localhost:8080, callable from any language
  • Dashboard at localhost:8080/dashboard for live monitoring

How to migrate to 1.5?

1. What does not change

Core business APIs keep the same call style: login, market data queries, order flow, accounting queries, contract access, callback registration, and default accounts.

2. Import from the top level

Submodules (shioaji.constant / shioaji.position / shioaji.order / ...) re-export everything to the top level.

from shioaji.constant import Action, StockOrderCond, FuturesOCType, Unit
from shioaji.position import StockPosition, AccountBalance
from shioaji.order import Trade, OrderStatus
from shioaji import (
    Action, StockOrderCond, FuturesOCType, Unit,
    StockPosition, AccountBalance,
    Trade, OrderStatus,
)

3. __dict__.dict()

df = pd.DataFrame(s.__dict__ for s in positions)
df = pl.DataFrame(s.dict() for s in positions)

4. api.quote.subscribeapi.subscribe

api.quote.subscribe(api.Contracts.Stocks["2330"], quote_type=...)
api.quote.unsubscribe(api.Contracts.Stocks["2330"])
api.subscribe(api.Contracts.Stocks["2330"], quote_type=...)
api.unsubscribe(api.Contracts.Stocks["2330"])

5. api.OrderStockOrder / FuturesOrder

1.3 used one api.Order(...) for both stock and futures, mixing fields. 1.5 splits it into two dedicated classes.

order = api.Order(action="Buy", price=30, quantity=1, price_type="LMT", ...)
order = sj.StockOrder(action=sj.Action.Buy, price=30, quantity=1,
                      price_type=sj.StockPriceType.LMT, ...)
# For futures, use sj.FuturesOrder(...)

How to use the new platform?

The CLI and HTTP server read credentials and mode from environment variables — no Python changes required:

# .env (in the working directory)
SJ_API_KEY=YOUR_API_KEY
SJ_SEC_KEY=YOUR_SECRET_KEY
SJ_PRODUCTION=false                 # simulation; set to true for production

shioaji server start

Once started, Python, JS, Go, and other languages can all operate via localhost:8080.