又到了每天把玩Python API的時間了,還記得Day8的文章嗎? 我們對於下單的狀態訊息做了示範與說明。今天來談查詢委託單,查詢動作對交易很重要,不過其實程式很簡易。
登入狀態下,可以用下列指令查詢:
api.update_status()
api.list_trades()
例如下列有跑出兩筆結果,顯示交易狀態是刪單:
[
Trade(
contract=Contract(security_type=<SecurityType.Future: 'FUT'>, exchange=<Exchange.TAIFEX: 'TAIFEX'>, code='TXFA1'),
order=Order(action=<Action.Buy: 'Buy'>, price=13770.0, quantity=1, id='63f8f2c9', seqno='896206', ordno='ky007', account=Account(account_type=<AccountType.Future: 'F'>, person_id='PAPIUSER06', broker_id='F002000', account_id='9102620', signed=True), price_type=<StockPriceType.LMT: 'LMT'>, order_type=<FuturesOrderType.ROD: 'ROD'>, octype=<FuturesOCType.New: 'New'>),
status=OrderStatus(id='63f8f2c9', ==status=<Status.Cancelled: 'Cancelled'>==, status_code='0000', order_datetime=datetime.datetime(2020, 12, 2, 11, 1, 48), modified_price=13770.0, cancel_quantity=1, deals=[])
),
Trade(
contract=Contract(security_type=<SecurityType.Future: 'FUT'>, exchange=<Exchange.TAIFEX: 'TAIFEX'>, code='TXFA1'),
order=Order(action=<Action.Buy: 'Buy'>, price=13770.0, quantity=1, id='7808d809', seqno='896208', ordno='ky008', account=Account(account_type=<AccountType.Future: 'F'>, person_id='PAPIUSER06', broker_id='F002000', account_id='9102620', signed=True), price_type=<StockPriceType.LMT: 'LMT'>, order_type=<FuturesOrderType.ROD: 'ROD'>, octype=<FuturesOCType.New: 'New'>),
status=OrderStatus(id='7808d809', ==status=<Status.Cancelled: 'Cancelled'>==, status_code='0000', order_datetime=datetime.datetime(2020, 12, 2, 11, 2, 17), modified_price=13770.0, cancel_quantity=1, deals=[])
)
]
以上就是今天的查詢指令分享,我們明天見!