Example #1
0
        private void _futureSellBtn_Click(object sender, EventArgs e)
        {
            HttpSender     http   = new HttpSender("https://fincloud.apex.com.tw/FinCloud/api/GVE/PutOrder");
            HttpHeaderList header = new HttpHeaderList();

            header.AddHeader("Content-Type", "application/json");
            header.AddHeader("Host", "fincloud.apex.com.tw");
            header.AddHeader("Referer", "https://fincloud.apex.com.tw/");
            header.AddHeader("User-Agent", @"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
            CookieContainer cookies = new CookieContainer();

            cookies.Add(_loginCookie);
            PutOrderPostReq req = new PutOrderPostReq
            {
                assetcode = "TXFJ8.tw", // 期貨商品(參數)
                bs        = "S",        //買賣(參數)
                dt        = 0,          //當沖單(參數)
                gmrid     = this._gmrid,
                oct       = "O",
                on        = "IOC", //
                ot        = "MKT", //限價或市價
                price     = 0,     //價格(參)
                volume    = 1      //量(參)
            };

            ResponseResult rsp = http.SendRequest(HttpRequestMethod.Post, JsonConvert.SerializeObject(req), header, cookies);
        }
Example #2
0
        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());
        }
Example #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());
        }