Ejemplo n.º 1
0
 /// <summary>
 /// get the list of available engines
 /// </summary>
 public void GetEngines(MicexISSDataHandler myhandler)
 {
     myhandler.EnginesStorage = new Dictionary <string, string>();
     try
     {
         var reply   = GetReply(_urls["engines"]);
         var engines = GetDataBlock(XDocument.Parse(reply), "engines");
         if (!engines.HasElements)
         {
             return;
         }
         var rows = GetRows(engines);
         if (!rows.HasElements)
         {
             return;
         }
         foreach (var el in rows.Elements())
         {
             myhandler.Process_engines(GetAttribute(el, "name"), GetAttribute(el, "title"));
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Error while processing XML with engines: " + e.Message);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// get the list of boards on a given engine and a given market
 /// </summary>
 public void GetBoards(string engineName, string marketName, MicexISSDataHandler myhandler)
 {
     myhandler.BoardsStorage = new Dictionary <string, string>();
     try
     {
         var reply  = GetReply(String.Format(_urls["boards"], engineName, marketName));
         var boards = GetDataBlock(XDocument.Parse(reply), "boards");
         if (!boards.HasElements)
         {
             return;
         }
         var rows = GetRows(boards);
         if (!rows.HasElements)
         {
             return;
         }
         foreach (var el in rows.Elements())
         {
             myhandler.Process_boards(GetAttribute(el, "boardid"), GetAttribute(el, "title"));
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Error while processing XML with boards: " + e.Message);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// full cycle to get the end-of-day results
        /// only Security ID, number of trades and the official close price are stored in this example
        /// </summary>
        public void GetHistorySecurities(String engine, String market, String board, String histdate, MicexISSDataHandler myhandler)
        {
            var start    = 0;
            var replyLen = 1;

            myhandler.HistoryStorage = new List <Tuple <string, double, uint> >();
            try
            {
                // it is very important to keep in mind that the server reply can be split into serveral pages,
                // so we use the 'start' argument to the request
                while (replyLen > 0)
                {
                    replyLen = 0;

                    var fullurl = String.Format(_urls["history_secs"], engine, market, board, histdate, start);
                    var reply   = GetReply(fullurl);

                    // get the data block with historical data
                    // we ignore metadata in this example
                    var history = GetDataBlock(XDocument.Parse(reply), "history");
                    if (history.HasElements)
                    {
                        var rows = GetRows(history);
                        if (rows.HasElements)
                        {
                            foreach (var el in rows.Elements())
                            {
                                var secid     = GetAttribute(el, "SECID");
                                var numtrades = UInt32.Parse(GetAttribute(el, "NUMTRADES"));
                                // need to use Val instead of Convert or CDbl, because the ISS float numbers always come with. as the delimiter
                                var closeprice = 0.0;
                                if (Double.TryParse(GetAttribute(el, "LEGALCLOSEPRICE"), out var parcedDouble))
                                {
                                    closeprice = parcedDouble;
                                }
                                myhandler.Process_history(secid, closeprice, numtrades);
                            }
                            replyLen = rows.Elements().Count();
                        }
                    }
                    start = start + replyLen;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error while processing XML with history_secs: " + e.Message);
            }
        }