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); }
protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); AvStockProvider stockProvider = new AvStockProvider("XD6HTE47G8ZZIDRB"); StockData stockData = await stockProvider.RequestDailyAsync("SGO.PA"); ((MainWindow)Application.Current.MainWindow).volumeChart.StockData = stockData; ((MainWindow)Application.Current.MainWindow).volumeChart.init(); }
private async void addStockBtn_Click(object sender, RoutedEventArgs e) { string symbol = this.stockTextBox.Text; if (string.IsNullOrEmpty(symbol)) { return; } AvStockProvider stockProvider = new AvStockProvider("XD6HTE47G8ZZIDRB"); StockData stockData = await stockProvider.RequestDailyAsync(symbol); ((MainWindow)Application.Current.MainWindow).volumeChart.StockData = stockData; ((MainWindow)Application.Current.MainWindow).volumeChart.init(); }
private async void addStockBtn_Click(object sender, RoutedEventArgs e) { string symbol = this.stockTextBox.Text; if (string.IsNullOrEmpty(symbol)) { return; } foreach (var line in StockSeriesCollection) { if (line.Title.Equals(symbol)) { return; } } AvStockProvider stockProvider = new AvStockProvider("XD6HTE47G8ZZIDRB"); StockData stockData = await stockProvider.RequestDailyAsync(symbol); if (stockData.Data.Values.Count == 0) { return; } StockPanel stockPanel = new StockPanel(); stockPanel.stockLabel.Content = symbol; stockPanel.delStockBtn.Click += new RoutedEventHandler(delegate(object s, RoutedEventArgs args) { removeStock(symbol); }); allStocksPanel.Children.Add(stockPanel); var lineSeries = new LineSeries { Title = symbol, Values = new ChartValues <StockDataItem>(stockData.Data.Values) }; StockSeriesCollection.Add(lineSeries); }
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); }
public AvStockRequestManager(AvStockProvider avStockProvider) { _avStcokProvider = avStockProvider; _requests = new ConcurrentQueue<StockRequestData>(); }