Exemplo n.º 1
0
        private static async Task <SendParentOrderResponse> SendStopLimitSimple
        (
            AuthBitflyer auth,
            string product_code,
            string side,
            double size,
            double price,
            double trigger_price
        )
        {
            SendParentOrderResponse retObj = null;

            try
            {
                if (side == null)
                {
                    return(null);
                }

                if (side.Length <= 0)
                {
                    return(null);
                }

                if (side != "BUY" && side != "SELL")
                {
                    return(null);
                }

                SendParentOrderBody bodyObj = new SendParentOrderBody();
                if (bodyObj == null)
                {
                    Console.WriteLine("failed to create SendParentOrderBody.");
                    return(null);
                }
                bodyObj.order_method     = "SIMPLE";
                bodyObj.minute_to_expire = 10000;
                bodyObj.time_in_force    = "GTC";

                List <SendParentOrderParameter> parameters = new List <SendParentOrderParameter>();
                if (parameters == null)
                {
                    Console.WriteLine("failed to create SendParentOrderBody's parameters.");
                    return(null);
                }
                bodyObj.parameters = parameters;

                {
                    SendParentOrderParameter buyParam = new SendParentOrderParameter();
                    buyParam.condition_type = "STOP_LIMIT";
                    buyParam.trigger_price  = trigger_price;
                    buyParam.price          = price;
                    buyParam.product_code   = product_code;
                    buyParam.side           = side;
                    buyParam.size           = size;

                    bodyObj.parameters.Add(buyParam);
                }


                retObj = await PostSendParentOrder(auth, bodyObj);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }
Exemplo n.º 2
0
        public static async Task <SendParentOrderResponse> SendStopLimitIFD
        (
            AuthBitflyer auth,
            string product_code,
            string first_side,
            double first_size,
            double first_price,
            double first_trigger_price,
            string second_side,
            double second_size,
            double second_price,
            double second_trigger_price
        )
        {
            SendParentOrderResponse retObj = null;

            try
            {
                SendParentOrderBody bodyObj = new SendParentOrderBody();
                if (bodyObj == null)
                {
                    Console.WriteLine("failed to create SendParentOrderBody.");
                    return(null);
                }
                bodyObj.order_method     = "OCO";
                bodyObj.minute_to_expire = 10000;
                bodyObj.time_in_force    = "GTC";

                List <SendParentOrderParameter> parameters = new List <SendParentOrderParameter>();
                if (parameters == null)
                {
                    Console.WriteLine("failed to create SendParentOrderBody's parameters.");
                    return(null);
                }
                bodyObj.parameters = parameters;

                {
                    SendParentOrderParameter firstParam = new SendParentOrderParameter();
                    firstParam.condition_type = "STOP_LIMIT";
                    firstParam.trigger_price  = first_trigger_price;
                    firstParam.price          = first_price;
                    firstParam.product_code   = product_code;
                    firstParam.side           = first_side;
                    firstParam.size           = first_size;

                    bodyObj.parameters.Add(firstParam);
                }

                {
                    SendParentOrderParameter secondParam = new SendParentOrderParameter();
                    secondParam.condition_type = "STOP_LIMIT";
                    secondParam.trigger_price  = second_trigger_price;
                    secondParam.price          = second_price;
                    secondParam.product_code   = product_code;
                    secondParam.side           = second_side;
                    secondParam.size           = second_size;

                    bodyObj.parameters.Add(secondParam);
                }

                retObj = await PostSendParentOrder(auth, bodyObj);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }