快速入門
只需使用我們的 API 套件創建實例,登入您的帳戶並啟用認證,然後您就可以開始下單了。
登入並啟用憑證¶
using System;
using Sinopac.Shioaji;
Shioaji _api = new Shioaji();
var _accounts = _api.Login("YOUR_API_KEY", "YOUR_SECRET_KEY");
_api.ca_activate(
"C:/ekey/551/person_id/S/Sinopac.pfx",
"YOUR_CA_PASSWORD",
"Person of this Ca"
);
using System;
using Sinopac.Shioaji;
Shioaji _api = new Shioaji();
var _accounts = _api.Login("YOUR_PERSON_ID", "YOUR_PASSWORD");
_api.ca_activate(
"C:/ekey/551/person_id/S/Sinopac.pfx",
"YOUR_CA_PASSWORD",
"Person of this Ca"
);
訂閱行情¶
訂閱行情需將商品檔帶入 Subscribe
功能,並指定行情類型,就可以接收資料。
_api.Subscribe(_api.Contracts.Stocks["TSE"]["2330"], QuoteType.bidask);
_api.Subscribe(_api.Contracts.Stocks["TSE"]["2330"], QuoteType.tick);
_api.Subscribe(_api.Contracts.Futures["TXF"]["TXF202012"], QuoteType.bidask);
行情類型
目前我們支持 QuoteType
中的兩種行情類型。
下單¶
var _contract = _api.Contracts.Stocks["TSE"]["2890"];
var _stockOrder = new StockOrder()
{
price = 16.5,
quantity = 1,
action = Action.Buy,
price_type = StockPriceType.LMT,
order_type = StockOrderType.ROD,
order_lot = StockOrderLot.Common,
};
var _trade = _api.PlaceOrder(_contract, _stockOrder);
Console.WriteLine(_trade);