Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config">Configuration for this adapter</param>
        public YahooFinanceInput(YahooFinanceConfig config)
        {
            _config = config;
            Patterns tmp = new Patterns(config.StockSymbol);

            screenScraper = new ScreenScraper(tmp.URL,
                                              config.Timeout, tmp.MatchPattern);
        }
Esempio n. 2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            var streamInsightInstanceName = Properties.Settings.Default.InstanceName;
            var server = Server.Create(streamInsightInstanceName);
            var application = server.CreateApplication("yahoofinancetest");

            // Configure output adapter
            var outputConfig = new StackerConfig
            {
                StackerCtlPipeName = stackerCtl1.PipeName,
                StackerCtlHostName = "localhost"
            };

            var inputConfig = new YahooFinanceConfig
            {
                StockSymbol = "^GSPC",
                StockName = "S&P 500",
                Timeout = 10000,
                Interval = 1000
            };

            var input = CepStream<StockQuote>.Create("yahoo", typeof(YahooFinanceFactory), inputConfig, EventShape.Point);

            // Create query and bind to the output adapter
            query = input.ToQuery(application, "query", "...", typeof(StackerFactory), outputConfig, EventShape.Point, StreamEventOrder.ChainOrdered);

            // Start query
            query.Start();

            // Wait until query change state
            DiagnosticView diagnosticView;
            stopFlag = false;
            do
            {
                Thread.Sleep(100);
                diagnosticView = query.Application.Server.GetDiagnosticView(query.Name);
            } while (!stopFlag && (string)diagnosticView["QueryState"] == "Running");

            // Stop query
            query.Stop();

            Thread.Sleep(1000);

            application.Delete();
            server.Dispose();
        }