Shioaji is sinopac provide the most pythonic api for trading the taiwan and global financial market. You can use your favorite Python packages such as numpy, scipy, pandas, pytorch or tensorflow to build your own trading model with intergrated the shioaji api on cross platform.
[請問] 程式要如何抓到下面的訊息? callback 似乎不行
OrderState.FOrder {'operation': {'op_type': 'New', 'op_code': '99Q9', 'op_msg': '可委託金額不足'}, 'order': {'id': 'a305afb9', 'seqno': '605709', 'ordno': '00', 'action': 'Buy', 'price': 12380.0, 'qua 1, 'order_cond': None, 'order_type': 'ROD', 'price_type': 'LMT', 'market_type': 'Day', 'oc_type': 'New', 'subaccount': ''}, 'status': {'id': 'a305afb9', 'exchange_ts': 1595814959, 'modified_price': 0.0, 'cancel_quantity': 0}, 'contract': {'security_type': 'FUT', 'code': 'MXF', 'exchange': 'TIM', 'delivery_month': '202008', 'strike_price': 0.0, 'option_right': 'Future'}}
模擬帳號似乎沒有很完整 看來只能用正式帳戶去測試
另外問一下
如果成交多筆的callback 同一筆訂單會回傳多筆?https://sinotrade.github.io/tutor/order_deal_event/#stock
比方說 place_order 下單後 數量 12 價格100
OrderState.TFTOrder 回報 new 下單 做多 數量 12 價格100
OrderState.TFTDeal 回報 數量5
OrderState.TFTDeal 回報 數量8
OrderState.TFTDeal 回報 數量12 ?(是分開自己加總還是給累積量)
OrderState.TFTDeal 的 trade_id 怎麼與 OrderState.TFTOrder order_id 做對照?(要怎樣知道這個成交是哪一個訂單成交的)
api = sj.Shioaji(simulation=True)
accounts = api.login(
"PAPIUSER01",
"2222",
contracts_timeout=10000,
contracts_cb=lambda security_type: print(f"{repr(security_type)} fetch done.")
)
contract = api.Contracts.Futures.TXF.TXF202008
order = api.Order(action="Buy",
price=13000,
quantity=2,
order_type="ROD",
price_type="MKT",
octype="Auto",
account=api.futopt_account)
trade = api.place_order(contract, order)
contract=Future(code='TXFH0', symbol='TXF202008', name='臺股期貨', category='TXF', delivery_month='202008', underlying_kind='I', limit_up=13747.0, limit_down=11249.0, reference=12498.0, update_date='2020/07/28') order=Order(action=<Action.Buy: 'Buy'>, price=13000, quantity=2, id='4ad2725b', seqno='854403', account=Account(account_type=<AccountType.Future: 'F'>, person_id='PAPIUSER01', broker_id='F002000', account_id='9100020', signed=True), price_type=<FuturesPriceType.MKT: 'MKT'>, order_type=<FuturesOrderType.ROD: 'ROD'>) status=OrderStatus(id='4ad2725b', status=<Status.PendingSubmit: 'PendingSubmit'>, status_code=' ', order_datetime=datetime.datetime(2020, 7, 28, 18, 9, 42), deals=[])
[求救] 請問 Order 已經成功, 但是list_positions以及get_account_openposition卻沒有資料?
試試看這個
請教一下轉倉單的問題。例如:元大台灣50ETF期
api.Contracts.Futures.NYF
NYF(NYF202106, NYF202012, NYF202008, NYF202103, NYF202009)
目前是這些合約。但是有所謂的轉倉單,可以在你們的系統當中找到。例如我要從NYF202008轉到NYF202009去,如果是多單我只要購買「轉倉單」:「元大台灣50ETF期08/09」,代號是 NYFQ0/U0
這部分請問有嗎?或是在哪裡可以找到呢?
shioaji 昨天更新版本 0.3.0.dev4,新增 kbar,參考文件
https://sinotrade.github.io/tutor/market_data/historical/#kbar-data
@linsamtw kbar的high/low很像寫反了
買賣值有錯
?我應該是剛好掛跌停 ROD 買入,謝謝