コード例 #1
0
        static void Main(string[] args)
        {
            ORDER  hOrder = new OPTIONORDER();
            Object err    = null;
            Object result;

            hOrder.Side      = "Buy";
            hOrder.Symbol    = "IBM";
            hOrder.Type      = "Call";
            hOrder.Date      = "Jun '16";
            hOrder.Strike    = "160.00";
            hOrder.Position  = "Open";
            hOrder.Quantity  = "1";
            hOrder.PriceType = "Market";
            hOrder.Exchange  = "TST2 DMA";
            hOrder.TIF       = "Day";
            hOrder.Account   = "00999900";
            hOrder.Ticket    = "Bypass";

            result = hOrder.Submit(err);

            System.Console.WriteLine(result + " " + err + hOrder.Ticket);
            System.Console.WriteLine(DateTime.Now.ToString("h:mm:ss.fff tt"));
            Console.ReadLine();
        }
コード例 #2
0
        //Submit an order to REDI
        private void SendOrder()
        {
            OPTIONORDER objOrder = new OPTIONORDER();

            PrintOrder();

            objOrder.Symbol    = options.Symbol;
            objOrder.PriceType = options.PriceType;
            objOrder.Quantity  = options.Quantity.ToString();

            //Set the limit price or stop price according to the price type
            switch (options.PriceType)
            {
            case "Limit":
            case "Limit Close":
                objOrder.Price = options.Price.ToString();
                break;

            case "Stop":
                objOrder.StopPrice = options.StopPrice.ToString();
                break;

            case "Stop Limit":
                objOrder.Price     = options.Price.ToString();
                objOrder.StopPrice = options.StopPrice.ToString();
                break;
            }
            objOrder.type     = options.Type;
            objOrder.Date     = options.Date;
            objOrder.Strike   = options.Strike;
            objOrder.Position = options.Position;
            objOrder.Side     = options.Side;
            objOrder.Exchange = options.Exchange;
            objOrder.TIF      = options.TIF;
            objOrder.Account  = options.Account;
            objOrder.Ticket   = options.Ticket;

            object ord_err = null;
            bool   status;

            //Submit an order
            status = objOrder.Submit(ref ord_err);
            if (!status)
            {
                Console.WriteLine("Error: {0}", (string)ord_err);
                string error = (string)ord_err;

                //If the error is "Invalid Date.", show the first availble expiration date
                if (error == "Invalid Date.")
                {
                    Console.WriteLine("The first valid expiration date is: \"{0}\". Please try with this expiration date.", GetExpirationDate(options.Symbol));
                }
            }
            else
            {
                Console.WriteLine("Order has been submitted properly");
            }
        }
コード例 #3
0
        static public string GetAccount()
        {
            OPTIONORDER objOrder        = new OPTIONORDER();
            object      objAccountCount = null;

            objOrder.GetAccountCount(ref objAccountCount);
            if (objAccountCount == null || (int)objAccountCount == 0)
            {
                return(null);
            }
            else
            {
                return((string)objOrder.GetAccountAt(0));
            }
        }
コード例 #4
0
        static public string GetExpirationDate(string symbol)
        {
            OPTIONORDER objOrder = new OPTIONORDER();

            objOrder.Symbol = symbol;

            object objExpirationCount = null;

            objOrder.GetExpirationDatesCount(ref objExpirationCount);
            if (objExpirationCount == null || (int)objExpirationCount == 0)
            {
                return(null);
            }
            else
            {
                return((string)(objOrder.GetExpirationDateAt(0)));
            }
        }
コード例 #5
0
        static public string GetStrikePrice(string symbol, string type, string expirationDate, int index = 0)
        {
            OPTIONORDER objOrder = new OPTIONORDER();

            objOrder.Symbol = symbol;
            objOrder.type   = type;
            objOrder.Date   = expirationDate;

            object objStrikeCount = null;

            objOrder.GetStrikesCount(ref objStrikeCount);

            if (objStrikeCount == null || (int)objStrikeCount == 0)
            {
                return(null);
            }
            else
            {
                return((string)objOrder.GetStrikeAt(index));
            }
        }