예제 #1
0
        private static void RequestStocks(string apiKey)
        {
            AvStockProvider provider     = new AvStockProvider(apiKey);
            var             sgoDailyData = provider.RequestDaily("SGO.PA", true);

            log.Info(sgoDailyData);
            var sgoWeeklyData = provider.RequestWeekly("SGO.PA");

            log.Info(sgoWeeklyData);
            var sgoMonthlyData = provider.requestMonthly("SGO.PA");

            log.Info(sgoMonthlyData);

            IDictionary <string, StockRealtime> batchData = provider.BatchRequest(new string[] { "MSFT", "IBM", "AAPL" });

            log.Info("Batch Request for MSFT, IBM and AAPL");
            foreach (var kvp in batchData)
            {
                log.InfoFormat("{0} : Price = {1}, Volume = {2}, Date = {3}", kvp.Key, kvp.Value.Price, kvp.Value.Volume, kvp.Value.Timestamp);
            }
            AvStockRequestManager requestManager = new AvStockRequestManager(provider);

            string[] stocks = new string[] { "SGO.PA", "GLE.PA", "BNP.PA", "VIV.PA", "RNO.PA", "CS.PA" };
            requestManager.Start();
            requestManager.Delay = 4000;
            foreach (var stock in stocks)
            {
                requestManager.Add(StockRequestType.Daily, stock, Callback);
                requestManager.Add(StockRequestType.Weekly, stock, Callback);
                requestManager.Add(StockRequestType.Monthly, stock, Callback);
            }
            requestManager.Stop(true);
        }
예제 #2
0
        private void worker_DownloadData(object sender, DoWorkEventArgs e)
        {
            StockSeriesCollection[0].Values.Clear();
            AvStockProvider       stockProvider   = new AvStockProvider("XD6HTE47G8ZZIDRB");
            AvStockRequestManager stockRequestMgr = new AvStockRequestManager(stockProvider);

            stockRequestMgr.EnabledRetry = true;
            stockRequestMgr.Delay        = 8000;
            stockRequestMgr.MaxRetry     = 10;
            stockRequestMgr.Start();
            bool download = (bool)e.Argument;

            if (download)
            {
                foreach (var symbol in CAC40Helper.CAC40_STOCKS)
                {
                    stockRequestMgr.Add(StockRequestType.Daily, symbol, StockDailyCallback);
                }
            } // end if (download)
            stockRequestMgr.Stop(true);
        }