public void RecordOrderBook()
        {
            string filePath = CheckFileAndDirectoryOrdersBook();

            // Sending rate increase the meter and check if can continue ootherwise stop 4sec;
            SRM.RateAddition(2);
            HTMLUpdate("LastAction", "RecordOrderBook");

            var ordersbook = this.GetOrdersBook();

            // null if error in parsing likely due to a error message from API
            if (ordersbook == null)
            {
                return;
            }

            string LinesAskToAdd = "";
            foreach (List<string> ls in ordersBook.Asks)
            {
                // Foreach line, register in file and in the lsit
                CurrentOrder co = new CurrentOrder();
                co.OrderType = "ask";
                LinesAskToAdd = "ask";

                int i = 0;
                foreach (string s in ls)
                {
                    RecordOrdersBookInList(i, s, co);
                    LinesAskToAdd += s + ",";
                    i++;
                }

                ListOfCurrentOrder.Add(co);
                LinesAskToAdd += LinesAskToAdd + Environment.NewLine;
            }
            File.AppendAllText(filePath, LinesAskToAdd);

            string LinesBidToAdd = "";
            foreach(List<string> ls in ordersbook.Bids)
            {
                CurrentOrder co = new CurrentOrder();
                int i = 0;
                co.OrderType = "bid";
                LinesBidToAdd = "bid";

                foreach(string s in ls)
                {
                    RecordOrdersBookInList(i, s, co);
                    LinesBidToAdd += s + ",";
                    i++;
                }

                ListOfCurrentOrder.Add(co);
                LinesBidToAdd += LinesBidToAdd + Environment.NewLine;
            }
            File.AppendAllText(filePath, LinesBidToAdd);
        }
        public void RecordOrdersBookInList(int i, string value, CurrentOrder order)
        {
            switch(i)
            {
                case 0:
                    order.Price = Convert.ToDouble(value,NumberProvider);
                 break;
                case 1:
                 order.Volume = Convert.ToDouble(value,NumberProvider);
                 break;
                case 2:
                 order.Timestamp = Convert.ToDouble(value, NumberProvider);
                 break;

            }
        }
        public string GetOpenOrders()
        {
            //Sleep to avoid temporary lock out caused by GetOpenOrder() method call
            SRM.RateAddition(2);
            HTMLUpdate("LastAction", "GetOpenOrders");

            JObject obj = JObject.Parse(client.GetOpenOrders().ToString());
            OpenedOrders.Clear();
            try
            {
                JObject OpenedOrdersJson = (JObject)obj["result"]["open"];
                // if orderID is empty, it means that no orders are currently done or th application has been stopped and started
                if (OpenedOrders != null && OpenedOrders.ToString() != "{}")
                {
                    string txid = OpenedOrdersJson.Properties().First().Name;
                    // Foreach orders store each orders
                    foreach (JProperty jn in OpenedOrdersJson.Properties())
                    {
                        CurrentOrder openedorder = new CurrentOrder();
                        JObject order = (JObject)OpenedOrdersJson[jn.Name];
                        openedorder.OrderID = jn.Name;
                        openedorder.Type = order["descr"]["type"].ToString();
                        openedorder.OrderType = order["descr"]["ordertype"].ToString();
                        openedorder.Price = Convert.ToDouble(order["descr"]["price"], NumberProvider);
                        openedorder.Price2 = Convert.ToDouble(order["descr"]["price2"],NumberProvider);
                        openedorder.Volume = Convert.ToDouble(order["vol"], NumberProvider);

                        if (OpenedOrders.Count == 0 || OpenedOrders.Where(a => a.OrderID == openedorder.OrderID).Count() == 0)
                            OpenedOrders.Add(openedorder);
                    }

                    return txid;
                }
                return null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Get Opened Order Error: " + obj["error"]);
                return null;
            }
        }