Skip to content

QA

為什麼行情只能收幾行就斷掉了

If your code something like this, and possibly run code on cmd/terminal with python stream.py. Then you definitely won't get any additional ticks, since the python program has already terminated.

# stream.py
import shioaji as sj

api = sj.Shioaji(simulation=True)
api.login('PAPIUSER01', '2222')
api.quote.subscribe(
    api.Contracts.Stocks["2330"], 
    quote_type = sj.constant.QuoteType.Tick
)

If you wish your python program to survive, please modify you python script as below.

# stream.py
import shioaji as sj
from threading import Event

api = sj.Shioaji(simulation=True)
api.login('PAPIUSER01', '2222')
api.quote.subscribe(
    api.Contracts.Stocks["2330"], 
    quote_type = sj.constant.QuoteType.Tick
)

Event().wait()

如何更改shioaji.log

Please add environment variable before import shioaji. (version >= 0.3.3.dev0)

linux or Mac OS:

export SJ_LOG_PATH=/path/to/shioaji.log

windows:

set SJ_LOG_PATH=C:\path\to\shioaji.log

如何下市價單(MKT)、範圍市價單(MKP)

In

order = api.Order(
    action=sj.constant.Action.Buy,
    price=0, # MKT, MKP will not use price parameter
    quantity=1,
    price_type='MKP', # change to MKT or MKP
    order_type='IOC', # MKT, MKP only accecpt IOC order
    octype=sj.constant.FuturesOCType.Auto,
    account=api.futopt_account
)


如何掛漲(跌)停限價ROD單

First, we need to know the limit up(limit down) price of the security. Just take a look at the api.Contracts, you will find the information you want.

In

api.Contracts.Stocks.TSE['TSE2330']

Out

Stock(
    exchange=<Exchange.TSE: 'TSE'>, 
    code='2330', 
    symbol='TSE2330', 
    name='台積電', 
    category='24', 
    unit=1000, 
    limit_up=653.0, 
    limit_down=535.0, 
    reference=594.0, 
    update_date='2021/08/27', 
    margin_trading_balance=6565, 
    short_selling_balance=365, 
    day_trade=<DayTrade.Yes: 'Yes'>
)
Example place LMT and ROD order at limit up price.

In

contract = api.Contracts.Stocks.TSE['TSE2330']
price = contract.limit_up
order = api.Order(
    action=sj.constant.Action.Buy,
    price=price,
    quantity=1,
    price_type='LMT',
    order_type='ROD', 
    order_lot=sj.constant.TFTStockOrderLot.Common,
    account=api.stock_account
)


輸入密碼錯誤3次怎麼辦

線上解鎖
Note that you only have 2 chances to unlock your account online in a day.