Example #1
0
        /// <summary>
        /// Creates a Spark.Stock reference for the specified security and exchange.
        /// </summary>
        /// <param name="symbol">Security symbol</param>
        /// <param name="exchange">Security exchange</param>
        /// <param name="stock">Stock reference generated by the method</param>
        /// <returns>TRUE if Spark was able to create the specified stock, else FALSE</returns>
        internal static bool GetSparkStock(string symbol, string exchange, out Spark.Stock stock)
        {
            //Get internal spark security symbol
            Tuple <string, string> sparkSymbolExchange = ApiFunctions.GetSparkSymbolExchange(symbol, exchange);

            //Get reference to stock
            string identifier = sparkSymbolExchange.Item1 + "." + sparkSymbolExchange.Item2;

            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + "\t" + "Initiating event feed for " + identifier);
            stock = new Spark.Stock();
            if (!Spark.GetStock(ref stock, sparkSymbolExchange.Item1, sparkSymbolExchange.Item2))
            {
                Console.WriteLine("Can't get {0}: {1}", identifier, Spark.DescribeError(Spark.GetLastError()));
                return(false);
            }

            //Wait to allow Spark API to data access
            System.Threading.Thread.Sleep(1000);
            return(true);
        }