public async Task <IHttpActionResult> UpdateQuotes(string ticker) { var company = await _companyService.GetAsync(ticker); if (company != null) { var update = new CompanyQuotesModel { Ticker = company.Ticker, LastUpdated = company.LastUpdated, HistoryQuotes = _companyService.GetQuotes(ticker) }; if (!update.HistoryQuotes.Any()) { update.LastUpdated = DateTime.Today.AddYears(-5); } var request = new GetStockHistoryRequest(update.Ticker, update.LastUpdated); var csvQuotes = await _stockClient.GetStockHistory(request); var quotes = _fileReader.Read(csvQuotes); if (quotes.Any()) { var qmodels = quotes.Select(q => new QuotesModel(q)).ToList(); qmodels = qmodels.Merge(update.HistoryQuotes).Where(q => q.Date > DateTime.Today.AddYears(-1)).ToList(); _companyService.UpdateQuotes(new UpdateQuotesRequest(company.Ticker, qmodels)); } } return(Ok()); }
private string BuildMessageContent(GetStockHistoryRequest request) { var timeFrame = "y"; switch (request.TimeFrame) { case QuoteTimeFrame.Month: timeFrame = "m"; break; case QuoteTimeFrame.Day: timeFrame = "d"; break; case QuoteTimeFrame.Year: break; default: throw new ArgumentOutOfRangeException(); } return //$@"__VIEWSTATE=XZrs0K3CLAQik%2B9%2FBOhqgzAu7AhSyzuIPlnviIYDraD9QdIJSo66MxkIWaIalgteK%2FjHBtc7rDr30HU44miTqa1z8cjPBNrr3CqxTGaT0xhET3TsmEh6o8AE2YMCXPwKzly0FhTZeZmrLT%2B%2BJ%2BBv%2F3dBBodNYSRs4HGe37Xny3GBMQ5qJ8lwJhyxMiybjfrblSClVGt8DjPJEJfLcPSJoCE2uSjSv24XMTS32CRhmmSen%2F00EQDWPNwa2xP1Drjt%2BznOhnR1x%2FPZUcCZq6rH8C5kOmczDyErER38S7BJLOoPDa78bIEFeE3nPXln8EPyKq9354xTTw4u2u3kklYdXYkz7V9QWLjSIRv4r15Hq5MpB02i9xE%2FFLZUk6Rx94W4E0p7J1WpHAh%2B9gMdafOhhNdmojnG94sy7YWTz1nbm5oTjwsj0cf5yA8Ol27huS%2BvYNwDCBbEezuNvwLed%2Fcd4%2FLt0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B0BKkKZRJKV%2FICdIt&__VIEWSTATEGENERATOR=87BE3BDB&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=VEkuZo2SeOu%2FnD6j9HLbGqFRgn64%2FASvJe4A%2F2bBQZJEYAvhmTKtRI8ZzltP4OFS9mbehJ4lK5HMuQEndw4xLqGpg1FlBvG7W9hqdK6FM4c2DB7QgSr0nj1a58AwdlnR&ctl00%24quotes_content_left%24submitString={ // request.TimeFrameValue}{timeFrame}%7Ctrue%7C{request.Ticker.ToUpper().Trim()}"; ($@"__VIEWSTATE=E5DobozXYrdj58HU93ksquh4MD%2Bd%2FZBuR0I8BfnpDeCpW3RPQ8etJGiHe6hdsh9CAjPdKanibM3Fk5Xh9oL8Kin7%2FFlVwcnufsZ32g4kEwZiBogFkZw6OqxfIFnjW4po%2Fkts46kKSiJLttQGnL%2BZyI2CvD9jxfpJJJcLTu833Ji5ESSy69M3aEcrGIrSj8AbLqs09q9J1Fy0X036a8F5bdpi89DvqJcsdPXW3pmghH%2BulwAPHxEyxNBNntlRZLsSar0Oq1I%2BKn5VtwTrm7gtBBj0R0Ar5rBdeVtSEUg630qUXXRsx94cCTxl%2Bgzw27Cir%2B2jUD2Pu%2BboZaL6uDzSuPUpzV%2FIuDDCAXoQlLTOcrIr7VLnyrU6F2pavnfP4DzzKpfOHPtovT6XK5pPMLCHnhgUVdQLFwiFdoWXiJLEM5rXUdgdETJo%2B2jXYItksZwLe3km4RzEN4Is8YNgRNaAQWb1w8Xge22yPCV0Uy03xxW4HZJdEBNj6Jo%2BiL6B0tNe7%2FKCf525jmQ%2FbSBE5Rdr8ANsUdn2aHAOIFX7604kkbz5LwRkNLvXWNTgdlic5IUZdrfW05Z5TdhCOhhyIjDk6nUb%2BhYUTZxOh60tvDgwBhfuy8pWq74qDPqcCA6FFAtGp4RGTWiZa2%2FoZJiJ58yPxQkLnd4aGo8uuvYsVoQOXTbw9823xTzMP3Kx8LpFs244O75T0nQTBEUX7Qm1M4mq9PqjGbAlFrc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87BE3BDB&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=UPs8VIdhlea9dT%2FDpO3mTlwoIAcD63vAYZdzknfkltijyWVQPKltGNwyAiJjkshWc4OsyYtw8IsMcMhO%2BgCSuN2m70N%2FYULIPCSI6eMgw%2F2CTBgrX%2FC8ixAAK5CrzEVh&ctl00%24quotes_content_left%24submitString=1y%7Ctrue%7C{request.Ticker.ToUpper().Trim()}"); }
public async Task <string> GetStockHistory(GetStockHistoryRequest request) { var message = BuildRequestMessage(request); var response = await _client.SendAsync(message); var content = await response.Content.ReadAsStringAsync(); return(content); }
private HttpRequestMessage BuildRequestMessage(GetStockHistoryRequest request) { string resourceUrl = BuildResourseUrl(request); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, resourceUrl); requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/csv")); return(requestMessage); }
private HttpRequestMessage BuildRequestMessage(GetStockHistoryRequest request) { var resourceUrl = "Market/ECProxy/ChartData"; HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, resourceUrl); requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-GB")); string content = BuildMessageContent(request); requestMessage.Content = new StringContent(content, Encoding.UTF8, "application/x-www-form-urlencoded"); return(requestMessage); }
private HttpRequestMessage BuildRequestMessage(GetStockHistoryRequest request) { var resourceUrl = $"symbol/{request.Ticker.ToLower()}/historical"; HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, resourceUrl); requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html")); requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xhtml+xml")); requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*")); requestMessage.Headers.Referrer = new Uri(Path.Combine(_client.BaseAddress.AbsoluteUri, resourceUrl)); requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-GB", 0.8)); requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue("ru", 0.8)); requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-US", 0.5)); requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue("en", 0.3)); string content = BuildMessageContent(request); requestMessage.Content = new StringContent(content); requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); return(requestMessage); }
private string BuildResourseUrl(GetStockHistoryRequest request) { return($"table.csv?s={request.Ticker.ToUpper()}&d={DateTime.Today.Month-1}&e={DateTime.Today.Day.ToString("00")}&f={DateTime.Today.Year}&g=d&a={request.FromDate.Month-1}&b={request.FromDate.Day.ToString("00")}&c={request.FromDate.Year}&ignore=.csv"); }
private string BuildMessageContent(GetStockHistoryRequest request) { return($@"freq=1mi&time=1dy&Symbol=US%3A{request.Ticker.ToUpper()}&Width=325&XAxisUnit=&Flavor=&EntitlementToken=cecc4267a0194af89ca343805a3e57af"); }
private void UpdateQuotes(CompanyQuotesModel company) { var log = new Logger(); if (!company.HistoryQuotes.Any()) { company.LastUpdated = DateTime.Today.AddYears(-10); company.HistoryQuotes = new List <QuotesModel>(); } var historyRequest = new GetStockHistoryRequest(company.Ticker, company.LastUpdated); var quotes = new List <QuotesModel>(); var errorMessage = string.Empty; try { var csvQuotes = Task.Run(() => _marketStockClient.GetStockHistory(historyRequest)).Result; var squotes = _quotesFileReader.Read(csvQuotes); if (squotes.Any()) { var qmodels = squotes.Select(q => new QuotesModel(q)).ToList(); quotes = qmodels.Merge(company.HistoryQuotes); } } catch (AggregateException ex) { log.Error($"Failed to read Company quotes: {company.Ticker}", ex); foreach (var exception in ex.InnerExceptions) { errorMessage += exception.Message + " "; } } catch (Exception ex) { log.Error($"Failed to read Company quotes: {company.Ticker}", ex); errorMessage = ex.Message; } try { _companyService.UpdateQuotes(new UpdateQuotesRequest(company.Ticker, quotes) { ErrorMessage = errorMessage }); //_indicatorProcessor.Calculate(quotes, company.Ticker); if (string.IsNullOrEmpty(errorMessage)) { log.Info($"Company quotes updated successfully: {company.Ticker}"); } else { log.Error($"Failed to update Company: {company.Ticker}", new Exception(errorMessage)); } } catch (Exception ex) { errorMessage = $"Failed to update Company: {company.Ticker}"; log.Error(errorMessage, ex); } }
protected override Task Execute(ScheduledJob job, List <CompanyQuotesModel> companies) { foreach (var company in companies) { if (!company.HistoryQuotes.Any()) { company.LastUpdated = DateTime.Today.AddYears(-10); company.HistoryQuotes = new List <QuotesModel>(); } var historyRequest = new GetStockHistoryRequest(company.Ticker, company.LastUpdated); var errorMessage = string.Empty; var quotes = new List <QuotesModel>(); try { var csvQuotes = Task.Run(() => _marketStockClient.GetStockHistory(historyRequest)).Result; var squotes = _quotesFileReader.Read(csvQuotes); if (squotes.Any()) { var qmodels = squotes.Select(q => new QuotesModel(q)).ToList(); quotes = qmodels.Merge(company.HistoryQuotes); } } catch (AggregateException ex) { errorMessage = ex.Message; foreach (var exception in ex.InnerExceptions) { errorMessage += ". " + exception.Message; } Logger.Error(new ProcessorInfo { JobId = job.JobId, JobType = job.JobType, JobState = JobStatus.Error, ProcessName = JobType.ToString() }, $"Failed to read Company quotes: {company.Ticker}. {errorMessage}", ex); } catch (Exception ex) { Logger.Error(new ProcessorInfo { JobId = job.JobId, JobType = job.JobType, JobState = JobStatus.Error, ProcessName = JobType.ToString() }, $"Failed to read Company quotes: {company.Ticker}. {ex.Message}", ex); } try { CompanyService.UpdateQuotes(new UpdateQuotesRequest(company.Ticker, quotes) { ErrorMessage = errorMessage }); } catch (Exception ex) { Logger.Error(new ProcessorInfo { JobId = job.JobId, JobType = job.JobType, JobState = JobStatus.Error, ProcessName = JobType.ToString() }, $"Failed to update Company: {company.Ticker}. {ex.Message}", ex); } } return(Task.FromResult(0)); }