public string AddOptionOrder( string symbol, FutureBuyOrSell buySell, FutureCloseType openClose, FutureTradeCondition condition, FuturePriceType priceType, decimal price, int vol) { HttpSender http = new HttpSender(_sendFutureOrderApi); CookieContainer cookies = new CookieContainer(); cookies.Add(this._loginCookies); string odrPriceType = ""; string odrCondition = ""; if (condition == FutureTradeCondition.IOC) { odrCondition = "IOC"; odrPriceType = "MKT"; } else if (condition == FutureTradeCondition.ROD) { odrCondition = "ROD"; odrPriceType = "LMT"; } else { odrCondition = "FOK"; odrPriceType = "LMT"; } PutOrderPostReq req = new PutOrderPostReq { assetcode = symbol, bs = buySell == FutureBuyOrSell.Buy ? "B" : "S", gmrid = this._gmrid, oct = openClose == FutureCloseType.Open ? "O" :"C", on = odrCondition, ot = odrPriceType, price = condition == FutureTradeCondition.IOC ? 0 : price, volume = vol, fip = "125.227.70.205" }; ResponseResult response = http.SendRequest(HttpRequestMethod.Post, JsonConvert.SerializeObject(req), this._header, cookies); Console.Write(response.ResponseBody); PutOrderPostRsp rsp = JsonConvert.DeserializeObject <PutOrderPostRsp>(response.ResponseBody); PutOrderIdToCase(rsp.msg.Trim()); return(rsp.msg.Trim()); }
/// <summary> /// 送出股票買賣委託單 /// </summary> /// <param name="symbol"></param> /// <param name="buySell"></param> /// <param name="price"></param> /// <param name="vol"></param> /// <returns></returns> public string AddStockOrder(string symbol, StockBuyOrSell buySell, decimal price, int vol) { HttpSender http = new HttpSender(_sendStockOrderApi); CookieContainer cookies = new CookieContainer(); cookies.Add(this._loginCookies); string buySellStr = ""; switch (buySell) { case StockBuyOrSell.Buy: buySellStr = "B"; break; case StockBuyOrSell.Sell: buySellStr = "S"; break; case StockBuyOrSell.MarginBuy: buySellStr = "MB"; break; case StockBuyOrSell.MarginSell: buySellStr = "MS"; break; case StockBuyOrSell.RentBuy: buySellStr = "RB"; break; case StockBuyOrSell.RentSell: buySellStr = "RS"; break; default: break; } PutOrderPostReq req = new PutOrderPostReq { assetcode = symbol, bs = buySellStr, gmrid = this._gmrid, ot = "LMT", price = price, volume = vol, fip = "125.227.70.205" }; ResponseResult response = http.SendRequest(HttpRequestMethod.Post, JsonConvert.SerializeObject(req), this._header, cookies); Console.Write(response.ResponseBody); PutOrderPostRsp rsp = JsonConvert.DeserializeObject <PutOrderPostRsp>(response.ResponseBody); PutOrderIdToCase(rsp.msg.Trim()); return(rsp.msg.Trim()); }