private void InitializePrices() { string csvData; if (Stocks == null) { throw new Exception("Failed to retrieve symbols."); } string url = Definitions.YahooFinanceUrl; foreach (var stock in Stocks) { url += stock.Symbol + "+"; } url = url.TrimEnd('+') + "&f="; url = string.Format("{0}{1}{2}{3}{4}", url, PriceInfoKeys.Bid, PriceInfoKeys.Ask, PriceInfoKeys.Open, PriceInfoKeys.PreviousClose); using (WebClient web = new WebClient()) { csvData = web.DownloadString(url); } Prices = YahooFinance.ParsePrice(csvData, Stocks); }
public CompositeScoreResult GetCompositeScore(string symbol) { symbol = symbol.ToUpper(); Security quote = YahooFinance.GetQuoteAsync(symbol).Result; return(Indicators.GetCompositeScoreResult(symbol, quote)); //no indicator API needed }
private void InitializeStocks() { string csvData; if (_symbols == null) { throw new Exception("Failed to retrieve symbols."); } string url = Definitions.YahooFinanceUrl; foreach (var symb in _symbols) { url += symb + "+"; } url = url.TrimEnd('+') + "&f="; url = string.Format("{0}{1}{2}", url, StockInfoKeys.Symbol, StockInfoKeys.Name); using (WebClient web = new WebClient()) { csvData = web.DownloadString(url); } Stocks = YahooFinance.ParseStock(csvData); }
private async void buttonGetLastYearClick(object sender, RoutedEventArgs e) { if (DecideCompany.SelectedItem != null) { List <CompanyValue> stockHistory = new List <CompanyValue>(); stockHistory = await YahooFinance.GetCompanyHistory(3, DecideCompany.SelectedItem as String); changeDatesOnStocks(stockHistory, DATE_WITH_MONTH); (LineChart.Series[0] as LineSeries).ItemsSource = stockHistory; } }
public static HistoricalStockQuotes RetrieveQuotes(DateTime start, DateTime end, String TIDM) { IQuoteProvider provider = new YahooFinance(); HistoricalStockQuotes historicalQuote = null; start = start.Date; end = end.Date; // check for previous occurrence using (var session = DataDocumentStore.DocStore.OpenSession()) { var quotes = from h in session.Query<HistoricalStockQuotes>() where h.TIDM == TIDM select h; if (quotes.Count() == 1) { // previous quote for this symbol historicalQuote = quotes.First(); if(!IsRefreshRequired(historicalQuote, start, end)){ //remove extraneous quotes var x = from c in historicalQuote.Quotes where c.PriceTime >= start && c.PriceTime <= end select c; historicalQuote.Quotes = x.ToList<StockQuote>(); return historicalQuote; } } List<StockQuote> stockQuotes = provider.RetrieveQuotes(start, end, TIDM); if(historicalQuote==null){ historicalQuote = new HistoricalStockQuotes { TIDM = TIDM, Start = start, End = end }; } historicalQuote.Quotes = stockQuotes; session.Store(historicalQuote); session.SaveChanges(); } return historicalQuote; }
//------------------------------------------------------------------------------------------ //updates stock data. private void UpdateFXbtn_Click(object sender, EventArgs e) { //coding that allows the programmer to select securities. var stocksToAdd = new[] { "AAPL", "GOOG", "MSFT", "INTC", "SBUX" }; var csv = GetSymbolPriceCsv(stocksToAdd); List <Price> result = YahooFinance.ParseList(csv); var repo = new TestDb(); foreach (var symbol in result) { repo.Insert(symbol); } this.securityPricesTableAdapter.Fill(this.tradingPlatformDBDataSet.SecurityPrices); }
private static void Main(string[] args) { string csvData; using (WebClient web = new WebClient()) { csvData = web.DownloadString("http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=snbaopl1"); } List <Price> prices = YahooFinance.Parse(csvData); foreach (Price price in prices) { Console.WriteLine(string.Format("{0} ({1}) Bid:{2} Offer:{3} Last:{4} Open: {5} PreviousClose:{6}", price.Name, price.Symbol, price.Bid, price.Ask, price.Last, price.Open, price.PreviousClose)); } Console.Read(); }
public ActionResult HAPScrape() { ViewBag.scrapeStart = "Scraping Please Wait..."; ViewBag.scrapeMethod = "HAP"; YahooFinance webPage = new YahooFinance(); List <List <string> > stockTable = webPage.Login(); //FromFile scrape = new FromFile(); //List<List<string>> stockTable = scrape.ReadFile(); ViewBag.stockTable = stockTable; ViewBag.scrapeDone = "Done"; //FinanceTable.ScrapeToDatabase(stockTable); //int maxId = db.StockTables.Max(p => p.ID); //ViewBag.Message = maxId + " Stocks scraped into Database"; return(View()); }
public void Load_symbol() { var sut = new YahooFinance(); }
static void Main(string[] args) { //Connect to a remote SI Server instance //using (Server server = Server.Connect(new System.ServiceModel.EndpointAddress(@"http://localhost/StreamInsight/default"))) { //Create the Embedded SI Server using (Server server = Server.Create("default")) { //Create a local end point for the server embedded into this program //This exposes SI to allow other applications to read from this SI server var myHost = new ServiceHost(server.CreateManagementService()); myHost.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), "http://localhost/StreamInsight/MyInstance"); myHost.Open(); //Create the SI application Application application = server.CreateApplication("StreamYahooSI"); //Create Stream of YahooQuote Objects //this stream requests a quote per interval TimeSpan specified var inputStream = application.DefineObservable(() => Observable.Interval(TimeSpan.FromSeconds(1))).ToPointStreamable(x => PointEvent <YahooQuote> .CreateInsert(DateTime.Now, YahooFinance.GetSingleQuote("AAPL")), AdvanceTimeSettings.IncreasingStartTime); //Query the stream var myQuery = from evt in inputStream select evt; //setup sink as observer and specify onNext action to write to console var consoleObserver = application.DefineObserver(() => Observer.Create <PointEvent <YahooQuote> >(ConsoleWritePoint)); //bind sink to observe query and run the process using (var proc = myQuery.Bind(consoleObserver).Run("serverProcess")) { Console.WriteLine(); Console.WriteLine("*** Hit Enter to exit after viewing query output ***"); Console.WriteLine(); Console.ReadLine(); } myHost.Close(); Console.WriteLine(); Console.WriteLine("Process Stopped. Hit Enter to quit."); Console.ReadLine(); } }
public CompaniesListYF GetScreenedCompaniesYF(string screenId) { CompaniesListYF companies = YahooFinance.GetAllCompaniesAsync().Result; return(YahooFinance.GetScreenedCompaniesAsync(companies, screenId).Result); }
public CompaniesListYF GetAllCompaniesYF() { return(YahooFinance.GetAllCompaniesAsync().Result); }
public Security GetQuoteYF(string symbol) { return(YahooFinance.GetQuoteAsync(symbol).Result); }
public CompanyStatsYF GetCompanyStatsYF(string symbol) { return(YahooFinance.GetCompanyStatsAsync(symbol).Result); }
public CompositeScoreResult GetCompositeScoreTD(string symbol) { Security quote = YahooFinance.GetQuoteAsync(symbol).Result; return(TwelveData.GetCompositeScoreResult(symbol, quote)); }