Login Shioaji.

In [6]:
import shioaji as sj
api = sj.Shioaji()
Response Code: 0 | Event Code: 0 | Info: host '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
In [9]:
accounts = api.login("YOUR_PERSON_ID", "YOUR_PASSWORD")
accounts
Ca Initial Done.
Out[9]:
0
In [ ]:
api.activate_ca(
    ca_path="/c/your/ca/path/Sinopac.pfx",
    ca_passwd="YOUR_CA_PASSWORD",
    person_id="Person of this Ca",
)

Get Contract Object.

In [10]:
contract = api.Contracts.Futures.TXF.TXF202004
contract

Making Order Object.

Buy

In [19]:
order = api.Order(
            action="Buy",
            price=10200,
            quantity=2,
            order_type="ROD",
            price_type="LMT",
            octype="Auto",
            account=api.futopt_account
        )
order

Place Order

In [18]:
trade = api.place_order(contract, order)
In [ ]:
trade

Example For

Place Order ROD LMT

In [ ]:
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.Futures.TXF.TXF202004
order = api.Order(
            action="Buy",
            price=10200,
            quantity=2,
            order_type="ROD",
            price_type="LMT",
            octype="Auto",
            account=api.futopt_account
        )
trade = api.place_order(contract, order)
In [ ]:
trade

Cancel Order

In [ ]:
api.update_status(api.futopt_account)
api.cancel_order(trade)
api.update_status(api.futopt_account)
In [ ]:
trade

Update Order

In [ ]:
api.update_status(api.futopt_account)
api.update_order(trade=trade, price=10200, qty=1)
api.update_status(api.futopt_account)
In [ ]:
trade