Example For

Place Order Intraday Odd

In [18]:
import shioaji as sj

api = sj.Shioaji()
accounts = api.login("YOUR_PERSON_ID", "YOUR_PASSWORD", contracts_timeout=10000)
api.activate_ca(
    ca_path="/c/your/ca/path/Sinopac.pfx",
    ca_passwd="YOUR_CA_PASSWORD",
    person_id="Person of this Ca",
)

contract = api.Contracts.Stocks.TSE.TSE0050
order = api.Order(
            price=90,
            quantity=10,
            action="Buy",
            price_type="LMT",
            order_type="ROD",
            order_lot="IntradayOdd", 
            account=api.stock_account
        )
trade = api.place_order(contract, order)
Response Code: 0 | Event Code: 0 | Info: host '218.32.76.102:80', IP 218.32.76.102:80 (host 1 of 1) (host connection attempt 1 of 1) (total connection attempt 1 of 1) | Event: Session up
In [19]:
trade
Out[19]:
Trade(contract=Stock(exchange=<Exchange.TSE: 'TSE'>, code='0050', symbol='TSE0050', name='元大台灣50', category='00', limit_up=114.85, limit_down=94.05, reference=104.45, update_date='2020/09/22', margin_trading_balance=15390, short_selling_balance=2, day_trade=<DayTrade.Yes: 'Yes'>), order=Order(action=<Action.Buy: 'Buy'>, price=90, quantity=10, id='bc156fac', seqno='482348', ordno='00000', account=Account(account_type=<AccountType.Stock: 'S'>, person_id='PAPIUSER04', broker_id='9A95', account_id='0506112', signed=True), price_type=<StockPriceType.LMT: 'LMT'>, order_type=<FuturesOrderType.ROD: 'ROD'>, order_lot=<TFTStockOrderLot.IntradayOdd: 'IntradayOdd'>), status=OrderStatus(id='bc156fac', status=<Status.PendingSubmit: 'PendingSubmit'>, status_code='0', order_datetime=datetime.datetime(2020, 9, 22, 9, 10, 12), deals=[]))

Cancel Order

In [8]:
api.update_status(api.stock_account)
api.cancel_order(trade)
api.update_status(api.stock_account)
In [9]:
trade
Out[9]:
Trade(contract=Stock(exchange=<Exchange.TSE: 'TSE'>, code='0050', symbol='TSE0050', name='元大台灣50', category='00', limit_up=114.85, limit_down=94.05, reference=104.45, update_date='2020/09/22', margin_trading_balance=15390, short_selling_balance=2, day_trade=<DayTrade.Yes: 'Yes'>), order=Order(action=<Action.Buy: 'Buy'>, price=90.0, quantity=10, id='a0696a8b', seqno='482344', ordno='     ', account=Account(account_type=<AccountType.Stock: 'S'>, person_id='PAPIUSER04', broker_id='9A95', account_id='0506112', signed=True), price_type=<StockPriceType.LMT: 'LMT'>, order_type=<FuturesOrderType.ROD: 'ROD'>, order_lot=<TFTStockOrderLot.IntradayOdd: 'IntradayOdd'>), status=OrderStatus(id='a0696a8b', status=<Status.Cancelled: 'Cancelled'>, status_code='X', order_datetime=datetime.datetime(2020, 9, 22, 8, 48, 28), cancel_quantity=10, deals=[]))

Update Order

In [12]:
api.update_status(api.stock_account)
api.update_order(trade=trade, qty=2)
api.update_status(api.stock_account)
In [13]:
trade
Out[13]:
Trade(contract=Stock(exchange=<Exchange.TSE: 'TSE'>, code='0050', symbol='TSE0050', name='元大台灣50', category='00', limit_up=114.85, limit_down=94.05, reference=104.45, update_date='2020/09/22', margin_trading_balance=15390, short_selling_balance=2, day_trade=<DayTrade.Yes: 'Yes'>), order=Order(action=<Action.Buy: 'Buy'>, price=90.0, quantity=10, id='a7ac2c0d', seqno='482345', ordno='     ', account=Account(account_type=<AccountType.Stock: 'S'>, person_id='PAPIUSER04', broker_id='9A95', account_id='0506112', signed=True), price_type=<StockPriceType.LMT: 'LMT'>, order_type=<FuturesOrderType.ROD: 'ROD'>, order_lot=<TFTStockOrderLot.IntradayOdd: 'IntradayOdd'>), status=OrderStatus(id='a7ac2c0d', status=<Status.PreSubmitted: 'PreSubmitted'>, status_code='R', order_datetime=datetime.datetime(2020, 9, 22, 8, 54, 32), cancel_quantity=2, deals=[]))
In [ ]: