Esempio n. 1
0
 public string SendStockOrder(string symbol,
                              StockBuyOrSell bs,
                              decimal price,
                              int vol)
 {
     return(_fireOrderMgrInstance.AddStockOrder(symbol, bs, price, vol));
 }
Esempio n. 2
0
        private void _sendStockOrderBtn_Click(object sender, EventArgs e)
        {
            StockBuyOrSell buySellType = StockBuyOrSell.None;

            if (this._stockBuyRdo.Checked)
            {
                buySellType = StockBuyOrSell.Buy;
            }
            if (this._stockSellRdo.Checked)
            {
                buySellType = StockBuyOrSell.Sell;
            }
            if (this._stockMarginBuyRdo.Checked)
            {
                buySellType = StockBuyOrSell.MarginBuy;
            }
            if (this._stockRentBuyRdo.Checked)
            {
                buySellType = StockBuyOrSell.RentBuy;
            }
            if (this._stockMarginSellRdo.Checked)
            {
                buySellType = StockBuyOrSell.MarginSell;
            }
            if (this._stockRentSellRdo.Checked)
            {
                buySellType = StockBuyOrSell.RentSell;
            }

            this._apexApiFacade.SendStockOrder(this._stockCodeTxt.Text.Trim(),
                                               buySellType,
                                               decimal.Parse(this._stockPriceTxt.Text),
                                               int.Parse(this._stockVolTxt.Text) * 1000);
        }
Esempio n. 3
0
        /// <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());
        }