Example #1
0
        public static async Task <bool> isActive
        (
            AuthBitflyer auth,
            string product_code
        )
        {
            bool result = false;

            try
            {
                bool isOrder = await isExistsActiveOrders(auth, product_code);


                bool isPosition = await isExistsPosition(auth, product_code);

                result = (isOrder || isPosition);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
            }
            return(result);
        }
Example #2
0
        public static AuthBitflyer createAuthBitflyer(string filePath)
        {
            AuthBitflyer result = null;

            try
            {
                if (filePath == null || filePath.Length <= 0)
                {
                    result = null;
                    return(result);
                }

                AuthBitflyer auth = null;
                if (UtilityJson.loadFromJson <AuthBitflyer>(out auth, filePath) != 0)
                {
                    result = null;
                    return(result);
                }

                result = auth;
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception: {0}", ex.Message);
                result = null;
            }
            finally
            {
            }
            return(result);
        }
Example #3
0
        public static async Task <bool> isExistsPosition
        (
            AuthBitflyer auth,
            string product_code
        )
        {
            bool result = false;

            try
            {
                JArray retArray = await getPositions(auth, product_code);

                if (retArray != null && retArray.Count > 0)
                {
                    result = true;
                    return(result);
                }
                result = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
            }
            return(result);
        }
Example #4
0
        private static async Task <double> SellMarketAcceptance
        (
            AuthBitflyer auth,
            string product_code,
            double size
        )
        {
            double result = 0.0;

            try
            {
                double retObj = await SendMarketAcceptance(
                    auth,
                    "SELL",
                    product_code,
                    size
                    );
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = 0.0;
            }
            finally
            {
            }
            return(result);
        }
Example #5
0
        public static async Task <SendParentOrderResponse> SellStopLimitSimple
        (
            AuthBitflyer auth,
            string product_code,
            double size,
            double price,
            double trigger_price
        )
        {
            SendParentOrderResponse retObj = null;

            try
            {
                retObj = await SendStopLimitSimple(auth, product_code, "SELL", size, price, trigger_price);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }
Example #6
0
        public static async Task <SendChildOrderResponse> SellMarket
        (
            AuthBitflyer auth,
            string product_code,
            double size
        )
        {
            SendChildOrderResponse retObj = null;

            try
            {
                retObj = await PostSendChildOrder(
                    auth,
                    product_code,
                    "MARKET",
                    "SELL",
                    0.0,
                    size,
                    10000,
                    "GTC"
                    );
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }
Example #7
0
        private static async Task <SendParentOrderResponse> PostSendParentOrder
        (
            AuthBitflyer auth,
            SendParentOrderBody bodyObj
        )
        {
            SendParentOrderResponse retObj = null;

            try
            {
                if (bodyObj == null)
                {
                    Console.WriteLine("SendParentOrderBody is null.");
                    return(null);
                }

                string method = "POST";
                string path   = "/v1/me/sendparentorder";

                string body = JsonConvert.SerializeObject(bodyObj, Formatting.None);
                if (body == null || body.Length <= 0)
                {
                    Console.WriteLine("failed to Serialize bodyObj.");
                    return(null);
                }

                string resJson = await RequestBitflyer.Request(auth, method, path, body);

                if (resJson == null)
                {
                    //Console.WriteLine("failed to RequestBitflyer.");
                    return(null);
                }

                retObj = JsonConvert.DeserializeObject <SendParentOrderResponse>(resJson);
                if (retObj == null)
                {
                    Console.WriteLine("SendParentOrder's DeserializeObject is null.");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }
Example #8
0
        public static async Task <int> cancelParentOrderAcceptance
        (
            AuthBitflyer auth,
            string product_code,
            string acceptance_id
        )
        {
            int result = 0;

            try
            {
                CancelParentOrderAcceptanceBody bodyObj = new CancelParentOrderAcceptanceBody();
                if (bodyObj == null)
                {
                    result = -1;
                    return(result);
                }
                bodyObj.parent_order_acceptance_id = acceptance_id;
                bodyObj.product_code = product_code;

                string body = JsonConvert.SerializeObject(bodyObj, Formatting.None);
                if (body == null || body.Length <= 0)
                {
                    result = -1;
                    return(result);
                }

                string method = "POST";
                string path   = "/v1/me/cancelparentorder";

                int resCode = await RequestBitflyer.RequestChkSuccessCode(auth, method, path, body);

                if (resCode != 0)
                {
                    Console.WriteLine("failed to RequestChkSuccessCode for cancel.");
                    result = -1;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = -1;
            }
            finally
            {
            }
            return(result);
        }
Example #9
0
        private static async Task <JArray> getParentOrders
        (
            AuthBitflyer auth,
            string product_code,
            int after_page_id,
            int before_page_id
        )
        {
            JArray retArray = null;

            try
            {
                string method = "GET";
                string path   = "/v1/me/getparentorders";
                string query  = string.Format(
                    "?product_code={0}&after={1}&before={2}"
                    , product_code
                    , after_page_id
                    , before_page_id
                    );
                string body = "";

                path = path + query;

                string resJson = await RequestBitflyer.Request(auth, method, path, body);

                if (resJson == null)
                {
                    Console.WriteLine("failed to getParentOrders-RequestBitflyer.");
                    return(null);
                }

                retArray = (JArray)JsonConvert.DeserializeObject(resJson);
                if (retArray == null)
                {
                    Console.WriteLine("Ticker's DeserializeObject is null.");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retArray = null;
            }
            finally
            {
            }
            return(retArray);
        }
Example #10
0
        public static async Task <JArray> getChildOrders
        (
            AuthBitflyer auth,
            string product_code,
            string child_order_state
        )
        {
            JArray retArray = null;

            try
            {
                string method = "GET";
                string path   = "/v1/me/getchildorders";
                string query  = string.Format(
                    "?product_code={0}&child_order_state={1}"
                    , product_code
                    , child_order_state
                    );
                string body = "";

                path = path + query;

                string resJson = await RequestBitflyer.Request(auth, method, path, body);

                if (resJson == null)
                {
                    Console.WriteLine("failed to getChildOrders-Request.");
                    return(null);
                }

                retArray = (JArray)JsonConvert.DeserializeObject(resJson);
                if (retArray == null)
                {
                    Console.WriteLine("Ticker's DeserializeObject is null.");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retArray = null;
            }
            finally
            {
            }
            return(retArray);
        }
Example #11
0
        private static async Task <JObject> getParentOrderAcceptance
        (
            AuthBitflyer auth,
            string product_code,
            string acceptance_id
        )
        {
            JObject retObj = null;

            try
            {
                string method = "GET";
                string path   = "/v1/me/getparentorder";
                string query  = string.Format(
                    "?product_code={0}&parent_order_acceptance_id={1}"
                    , product_code
                    , acceptance_id
                    );
                string body = "";

                path = path + query;

                string resJson = await RequestBitflyer.Request(auth, method, path, body);

                if (resJson == null)
                {
                    Console.WriteLine("failed to getParentOrderAcceptance-RequestBitflyer.");
                    return(null);
                }

                retObj = (JObject)JsonConvert.DeserializeObject(resJson);
                if (retObj == null)
                {
                    Console.WriteLine("Ticker's DeserializeObject is null.");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }
Example #12
0
        public static async Task <string> getParentOrderState
        (
            AuthBitflyer auth,
            string product_code,
            int page_id
        )
        {
            string result = null;

            try
            {
                JArray retArray = await getParentOrders(auth, product_code, page_id - 1, page_id + 1);

                if (retArray == null || retArray.Count <= 0 || retArray.Count > 1)
                {
                    result = null;
                    return(result);
                }

                JObject jobj = (JObject)retArray[0];
                if (jobj == null)
                {
                    result = null;
                    return(result);
                }

                string state = (string)jobj["parent_order_state"];
                if (state == null || state.Length <= 0)
                {
                    result = null;
                    return(result);
                }

                result = state;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = null;
            }
            finally
            {
            }
            return(result);
        }
Example #13
0
        public static async Task <SendChildOrderResponse> PostSendChildOrder
        (
            AuthBitflyer auth,
            string product_code,
            string child_order_type,
            string side,
            double price,
            double size,
            int minute_to_expire,
            string time_in_force
        )
        {
            SendChildOrderResponse retObj = null;

            try
            {
                SendChildOrderBody bodyObj = new SendChildOrderBody();
                if (bodyObj == null)
                {
                    Console.WriteLine("failed to create SendChildOrderBody.");
                    return(null);
                }
                bodyObj.product_code     = product_code;
                bodyObj.child_order_type = child_order_type;
                bodyObj.side             = side;
                bodyObj.price            = price;
                bodyObj.size             = size;
                bodyObj.minute_to_expire = minute_to_expire;
                bodyObj.time_in_force    = time_in_force;

                retObj = await PostSendChildOrder(auth, bodyObj);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                retObj = null;
            }
            finally
            {
            }
            return(retObj);
        }
Example #14
0
        public static async Task <bool> isExistsActiveOrders
        (
            AuthBitflyer auth,
            string product_code
        )
        {
            bool result = false;

            try
            {
                bool   isParentOrder = false;
                JArray parentArray   = await SendParentOrder.getParentOrders(auth, product_code, "ACTIVE");

                if (parentArray != null && parentArray.Count > 0)
                {
                    isParentOrder = true;
                }

                bool   isChildOrder = false;
                JArray childArray   = await SendChildOrder.getChildOrders(auth, product_code, "ACTIVE");

                if (childArray != null && childArray.Count > 0)
                {
                    isChildOrder = true;
                }

                result = (isParentOrder || isChildOrder);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
            }
            return(result);
        }
Example #15
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);
        }
Example #16
0
        public static async Task <int> RequestChkSuccessCode
        (
            AuthBitflyer auth,
            string method,
            string path,
            string body
        )
        {
            int result = -1;

            try
            {
                StringContent content = null;
                if (body != null && body.Length > 0)
                {
                    content = new StringContent(body);
                }

                using (var client = new HttpClient())
                    using (var request = new HttpRequestMessage(new HttpMethod(method), path))
                    {
                        client.BaseAddress = EndPoint.endpointUri;

                        if (content != null)
                        {
                            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                            request.Content             = content;
                        }

                        if (auth != null)
                        {
                            var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
                            var data      = timestamp + method + path + body;
                            var hash      = SignWithHMACSHA256(data, auth.m_access_secret);

                            request.Headers.Add("ACCESS-KEY", auth.m_access_key);
                            request.Headers.Add("ACCESS-TIMESTAMP", timestamp);
                            request.Headers.Add("ACCESS-SIGN", hash);
                        }

                        var message = await client.SendAsync(request);

                        // string responce = await message.Content.ReadAsStringAsync();

                        if (message.IsSuccessStatusCode == false)
                        {
                            //Console.WriteLine(message.RequestMessage);
                            result = -1;
                        }
                        else
                        {
                            result = 0;
                        }
                    }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = -1;
            }
            finally
            {
            }
            return(result);
        }
Example #17
0
        // average_priceを返す 失敗すれば0.0
        public static async Task <GetParentOrderResponse> getParentOrderOCO
        (
            AuthBitflyer auth,
            string product_code,
            string acceptance_id
        )
        {
            GetParentOrderResponse result = null;

            try
            {
                JObject retObj = await getParentOrderAcceptance(auth, product_code, acceptance_id);

                if (retObj == null)
                {
                    result = null;
                    return(result);
                }

                int    page_id         = (int)retObj["id"];
                string parent_order_id = (string)retObj["parent_order_id"];
                if (parent_order_id == null || parent_order_id.Length <= 0)
                {
                    result = null;
                    return(result);
                }

                JArray retArray = await getChildOrdersParent(auth, product_code, parent_order_id);

                if (retArray == null || retArray.Count <= 0)
                {
                    result = new GetParentOrderResponse();
                    if (result == null)
                    {
                        return(result);
                    }
                    result.page_id            = page_id;
                    result.parent_order_id    = parent_order_id;
                    result.side               = "";
                    result.average_price      = 0.0;
                    result.parent_order_state = "NONE";

                    return(result);
                }

                JObject compObj = null;

                int cntReject  = 0;
                int cntExpired = 0;
                int cntCanceld = 0;
                int cntActive  = 0;

                List <GetChildOrderResponse> children = new List <GetChildOrderResponse>();
                if (children == null)
                {
                    result = null;
                    return(result);
                }

                foreach (JObject jobj in retArray)
                {
                    if (jobj == null)
                    {
                        continue;
                    }

                    GetChildOrderResponse child = new GetChildOrderResponse();
                    if (child == null)
                    {
                        continue;
                    }

                    child.child_order_state         = (string)jobj["child_order_state"];
                    child.average_price             = (double)jobj["average_price"];
                    child.price                     = (double)jobj["price"];
                    child.child_order_id            = (string)jobj["child_order_id"];
                    child.child_order_acceptance_id = (string)jobj["child_order_acceptance_id"];
                    child.side = (string)jobj["side"];

                    children.Add(child);


                    if (child.child_order_state == "COMPLETED")
                    {
                        compObj = jobj;
                    }
                    else if (child.child_order_state == "REJECTED")
                    {
                        cntReject++;
                    }
                    else if (child.child_order_state == "EXPIRED")
                    {
                        cntExpired++;
                    }
                    else if (child.child_order_state == "CANCELED")
                    {
                        cntCanceld++;
                    }
                    else if (child.child_order_state == "ACTIVE")
                    {
                        cntActive++;
                    }
                }

                if (compObj != null)
                {
                    result = new GetParentOrderResponse();
                    if (result == null)
                    {
                        return(result);
                    }
                    result.page_id            = page_id;
                    result.parent_order_id    = parent_order_id;
                    result.side               = (string)compObj["side"];;
                    result.average_price      = (double)compObj["average_price"];
                    result.parent_order_state = (string)compObj["child_order_state"];
                    result.children           = children;
                    Console.WriteLine("COMPLETED. side={0} state={1} accept_id={2} parent_id={3}", result.side, result.parent_order_state, acceptance_id, parent_order_id);
                }
                else if (cntActive == retArray.Count)
                {
                    result = new GetParentOrderResponse();
                    if (result == null)
                    {
                        return(result);
                    }
                    result.page_id            = page_id;
                    result.parent_order_id    = parent_order_id;
                    result.side               = "";
                    result.average_price      = 0.0;
                    result.parent_order_state = "ACTIVE";
                    result.children           = children;
                    //Console.WriteLine("ACTIVE. side={0} state={1} accept_id={2} parent_id={3}", result.side, result.parent_order_state, acceptance_id, parent_order_id);
                }
                else if (cntCanceld == retArray.Count)
                {
                    result = new GetParentOrderResponse();
                    if (result == null)
                    {
                        return(result);
                    }
                    result.page_id            = page_id;
                    result.parent_order_id    = parent_order_id;
                    result.side               = "";
                    result.average_price      = 0.0;
                    result.parent_order_state = "CANCELED";
                    result.children           = children;
                    Console.WriteLine("CANCELED. side={0} state={1} accept_id={2} parent_id={3}", result.side, result.parent_order_state, acceptance_id, parent_order_id);
                }
                else if ((cntReject + cntExpired) == retArray.Count)
                {
                    result = new GetParentOrderResponse();
                    if (result == null)
                    {
                        return(result);
                    }
                    result.page_id            = page_id;
                    result.parent_order_id    = parent_order_id;
                    result.side               = "";
                    result.average_price      = 0.0;
                    result.parent_order_state = "REJECTED";
                    result.children           = children;
                    Console.WriteLine("REJECTED. side={0} state={1} accept_id={2} parent_id={3}", result.side, result.parent_order_state, acceptance_id, parent_order_id);
                }
                else
                {
                    //Console.WriteLine("Entry Order is NULL. accept_id={0} parent_id={1}", acceptance_id, parent_order_id);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = null;
            }
            finally
            {
            }
            return(result);
        }
Example #18
0
        // average_priceを返す 失敗すれば0.0
        private static async Task <double> SendMarketAcceptance
        (
            AuthBitflyer auth,
            string side,
            string product_code,
            double size
        )
        {
            double result = 0.0;

            try
            {
                SendChildOrderResponse retObj = await PostSendChildOrder(
                    auth,
                    product_code,
                    "MARKET",
                    side,
                    0.0,
                    size,
                    10000,
                    "GTC"
                    );

                if (retObj == null)
                {
                    Console.WriteLine("faile to SellMarketAcceptance.");
                    return(result);
                }

                Console.WriteLine("child_order_acceptance_id={0}", retObj.child_order_acceptance_id);

                int retry_cnt = 0;
                while (true)
                {
                    System.Threading.Thread.Sleep(1000);

                    JArray retArray = await getChildOrdersAcceptance(auth, product_code, retObj.child_order_acceptance_id);

                    if (retArray != null && retArray.Count > 0)
                    {
                        JObject jobj   = (JObject)retArray[0];
                        JValue  jvalue = (JValue)jobj["average_price"];
                        result = (double)jvalue.Value;
                        break;
                    }
                    else
                    {
                        Console.WriteLine("retry={0}. faile to getChildOrdersAcceptance.", retry_cnt);
                    }


                    retry_cnt++;
                    if (retry_cnt > 180)
                    {
                        Console.WriteLine("timeout. faile to getChildOrdersAcceptance.");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = 0.0;
            }
            finally
            {
            }
            return(result);
        }
Example #19
0
        // average_priceを返す 失敗すれば0.0
        public static async Task <GetChildOrderResponse> getChildOrderAveragePrice
        (
            AuthBitflyer auth,
            string product_code,
            string acceptance_id
        )
        {
            GetChildOrderResponse result = null;

            try
            {
                JArray retArray = await getChildOrdersAcceptance(auth, product_code, acceptance_id);

                if (retArray != null && retArray.Count > 0)
                {
                    bool   isReject   = false;
                    bool   isFullComp = true;
                    double price      = 0.0;
                    string state      = "";
                    bool   isFirst    = true;
                    foreach (JObject jobj in retArray)
                    {
                        JValue average_price     = (JValue)jobj["average_price"];
                        JValue child_order_state = (JValue)jobj["child_order_state"];
                        if ((string)child_order_state != "COMPLETED")
                        {
                            isFullComp = false;
                        }
                        if ((string)child_order_state == "REJECTED")
                        {
                            isReject = true;
                        }
                        if (isFirst)
                        {
                            price   = (double)average_price;
                            state   = (string)child_order_state;
                            isFirst = false;
                        }
                    }

                    if (isFullComp)
                    {
                        result = new GetChildOrderResponse();
                        if (result == null)
                        {
                            return(result);
                        }
                        result.average_price     = price;
                        result.child_order_state = state;
                    }
                    else if (isReject)
                    {
                        result = new GetChildOrderResponse();
                        if (result == null)
                        {
                            return(result);
                        }
                        result.average_price     = 0.0;
                        result.child_order_state = "REJECTED";
                    }
                }
                else
                {
                    //Console.WriteLine("failed to getChildOrderAveragePrice.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = null;
            }
            finally
            {
            }
            return(result);
        }
Example #20
0
        public static async Task <bool> isCanceldChildOrders
        (
            AuthBitflyer auth,
            string product_code,
            List <string> acceptance_ids
        )
        {
            bool result = false;

            try
            {
                if (acceptance_ids == null || acceptance_ids.Count <= 0)
                {
                    result = false;
                    return(result);
                }

                foreach (string acceptance_id in acceptance_ids)
                {
                    if (acceptance_id == null || acceptance_id.Length <= 0)
                    {
                        result = false;
                        return(result);
                    }

                    bool isExistOrders = false;
                    {
                        JArray retArray = await getChildOrdersAcceptance(auth, product_code, acceptance_id);

                        if (retArray != null && retArray.Count > 0)
                        {
                            isExistOrders = true;
                            foreach (JObject jobj in retArray)
                            {
                                if (jobj == null)
                                {
                                    continue;
                                }

                                string child_order_state = (string)jobj["child_order_state"];
                                if (child_order_state != "COMPLETED")
                                {
                                    result = false;
                                    return(result);
                                }
                            }
                        }
                        else
                        {
                            isExistOrders = false;
                        }
                    }

                    if (!isExistOrders)
                    {
                        JArray retArray = await Trade.getExecutionsAcceptance(auth, product_code, acceptance_id);

                        if (retArray != null && retArray.Count > 0)
                        {
                            result = false;
                            return(result);
                        }
                        // 建玉にキャンセルした注文が入ってなければキャンセル済みとする
                        result = true;
                        return(result);
                    }
                    else
                    {
                        result = true;
                        return(result);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = false;
            }
            finally
            {
            }
            return(result);
        }
Example #21
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);
        }