/// <summary> /// Оформляет заказ. Если у клиента нет долга за прошлую неделю: /// записывает пиццы из корзины в новый заказ, сохраняет его в бд, /// переадресует на страницу Спасибо за заказ. /// Если долг есть, отправляет на страницу ошибка, где сообщаетя о долге и /// предлагается оплатить долг. /// </summary> /// <returns></returns> public async Task <IActionResult> Checkout() { ShoppingCart = SessionHelper.GetObjectFromJson <List <Pizza> >(HttpContext.Session, "cart"); string customerId = User.Claims.Where(c => c.Type == "Id").FirstOrDefault().Value; var weeklyFinanceData = await FinanceHelper.GetWeeklyData(_context, customerId); long orderId; if (weeklyFinanceData.ContainsKey(FinanceHelper.GetWeekKey(DateTime.Now))) { orderId = await CreateNewOrder(ShoppingCart, customerId); HttpContext.Session.Remove("cart"); return(RedirectToAction("ThankYou", "Cart", new { orderId = orderId })); } string lastWeekThatHasData = FinanceHelper.GetLastWeekThatHasData(weeklyFinanceData.Keys); double debt = lastWeekThatHasData == "" ? 0 : weeklyFinanceData[lastWeekThatHasData].delta; if (debt > 0) { return(RedirectToAction("Error", "Cart", new { debt = debt })); } orderId = await CreateNewOrder(ShoppingCart, customerId); HttpContext.Session.Remove("cart"); return(RedirectToAction("ThankYou", "Cart", new { orderId = orderId })); }
private ExchangeRateResponse ToResponse(YahooManaged.Base.Response <HistQuotesResult> resp, YCurrencyID[] currencies) { List <ExchangeRateData> lst = new List <ExchangeRateData>(); if (resp.Result != null) { foreach (HistQuotesDataChain hqc in resp.Result.Chains) { if (hqc.Count > 0) { YCurrencyID cur = FinanceHelper.YCurrencyIDFromString(hqc.ID); if (cur != null) { QuotesData q = new QuotesData(); q.SetID(hqc.ID); HistQuotesData hqd = (HistQuotesData)hqc[0]; q.Change = hqd.Close - hqd.PreviousClose; q.LastTradePriceOnly = hqd.Close; q.LastTradeDate = hqd.TradingDate; q.Volume = hqd.Volume; lst.Add(new ExchangeRateData(cur.BaseCurrency, cur.DepCurrency, q)); } } } } return(new ExchangeRateResponse(resp.Connection, new ExchangeRateResult(lst.ToArray(), currencies))); }
/// <summary> /// Downloads a list of historical currency exchange rates /// </summary> /// <param name="currencies"></param> /// <param name="tradeDate"></param> /// <returns></returns> /// <remarks></remarks> public ExchangeRateResponse Download(YCurrencyID[] currencies, DateTime tradeDate) { if (currencies == null) { throw new ArgumentNullException("currencies", "The passed currencies have no values."); } return(this.ToResponse(mHistQuotesDownload.Download(FinanceHelper.IIDsToStrings(currencies), tradeDate, tradeDate, HistQuotesInterval.Daily), currencies)); }
/// <summary> /// Downloads a list of actual currency exchange rates /// </summary> /// <param name="currencies">List of all currency-pairs</param> /// <returns></returns> /// <remarks></remarks> public ExchangeRateResponse Download(YCurrencyID[] currencies) { if (currencies == null) { throw new ArgumentNullException("currencies", "The passed currencies have no values."); } return(this.ToResponse(mQuotesBaseDownload.Download(FinanceHelper.IIDsToStrings(currencies)), currencies)); }
public FastWidgetController(IDataStorage storage, ISettingsStorage settings, FinanceHelper financeHelper, ConvertHelper converter, ICurrencyClient currency, UsersHelper usersHelper) { _storage = storage; _settings = settings; _financeHelper = financeHelper; _converter = converter; _currency = currency; _usersHelper = usersHelper; }
/// <summary> /// Starts an asynchronous download of historic currency exchange rates /// </summary> /// <param name="currencies">List of all currency-pairs</param> /// <param name="tradeDate">The trade date of exchange rates</param> /// <param name="userArgs">Individual user argument</param> /// <remarks></remarks> public void DownloadAsync(YCurrencyID[] currencies, DateTime tradeDate, object userArgs = null) { if (currencies == null) { throw new ArgumentNullException("currencies", "The passed currencies have no values."); } else { AsyncDownloadArgs args = new AsyncDownloadArgs(userArgs, currencies); mHistQuotesDownload.DownloadAsync(FinanceHelper.IIDsToStrings(args.Currencies), tradeDate, tradeDate, HistQuotesInterval.Daily, args); } }
/// <summary> /// Starts an asynchronous download of actual currency exchange rates /// </summary> /// <param name="currencies">List of all currency-pairs</param> /// <param name="userArgs">Individual user argument</param> /// <remarks></remarks> public void DownloadAsync(YCurrencyID[] currencies, object userArgs = null) { if (currencies == null) { throw new ArgumentNullException("currencies", "The passed currencies have no values."); } else { AsyncDownloadArgs args = new AsyncDownloadArgs(userArgs, currencies); mQuotesBaseDownload.DownloadAsync(FinanceHelper.IIDsToStrings(args.Currencies), args); } }
private string DownloadUrl(string[] ids, IEnumerable <StockCriteriaDefinition> criterias) { System.Text.StringBuilder sb = new System.Text.StringBuilder(this.DownloadUrl(criterias)); sb.Replace("&ln=-1", ""); sb.Append("&9w="); foreach (string id in ids) { sb.Append(FinanceHelper.CleanIndexID(id).ToUpper() + "_"); } sb.Remove(sb.Length - 1, 1); return(sb.ToString()); }
/// <summary> /// Overloaded constructor /// </summary> /// <param name="id"></param> /// <remarks></remarks> public YCurrencyID(string id) { YCurrencyID newRel = FinanceHelper.YCurrencyIDFromString(id); if (newRel != null) { this.BaseCurrency = newRel.BaseCurrency; this.DepCurrency = newRel.DepCurrency; } else { throw new ArgumentException("The id is not valid", "id"); } }
private ExchangeRateResponse ToResponse(YahooManaged.Base.Response <QuotesResult> resp, YCurrencyID[] currencies) { List <ExchangeRateData> lst = new List <ExchangeRateData>(); if (resp.Result != null) { foreach (QuotesData q in resp.Result.Items) { YCurrencyID cur = FinanceHelper.YCurrencyIDFromString(q.ID); if (cur != null) { lst.Add(new ExchangeRateData(cur.BaseCurrency, cur.DepCurrency, q)); } } } return(new ExchangeRateResponse(resp.Connection, new ExchangeRateResult(lst.ToArray(), currencies))); }
public override string GetUrl() { if (this.IDs == null || this.IDs.Length == 0) { throw new NotSupportedException("An empty id list will not be supported."); } else { System.Text.StringBuilder ids = new System.Text.StringBuilder(); foreach (string s in this.IDs) { ids.Append(MyHelper.CleanYqlParam(s)); ids.Append('+'); } String url = UrlStr + Uri.EscapeDataString(ids.ToString()) + "&f=" + FinanceHelper.CsvQuotePropertyTags(this.Properties) + "&e=.csv"; return(url); } }
public async Task <IActionResult> Index() { _customerId = User.Claims.Where(c => c.Type == "Id").FirstOrDefault().Value; var orders = await FinanceHelper.GetOrdersData(_context, _customerId); ViewBag.TotalOrdersCost = FinanceHelper.GetTotalOrdersCost(orders); var payments = await FinanceHelper.GetPaymentsData(_context, _customerId); ViewBag.TotalAmountPaid = FinanceHelper.GetTotalAmountPaid(payments); ViewBag.CustomerPayments = payments; ViewBag.WeeklyData = FinanceHelper.GetWeeklyData(orders, payments); // словарь с суммами закаов и платежей за сгруппированными по неделям ViewBag.CurrentWeekKey = FinanceHelper.GetWeekKey(DateTime.Now); // номер текущей недели, чтобы выводить инфоормационно клиенту return(View(orders)); }
public WebController(FinanceHelper financeHelper, ISettingsStorage settings, IDataStorage storage) { _financeHelper = financeHelper; _settings = settings; _storage = storage; }
protected override StockScreenerResult ConvertResult(Base.ConnectionInfo connInfo, System.IO.Stream stream, Base.SettingsBase settings) { StockScreenerDownloadSettings set = (StockScreenerDownloadSettings)settings; List <StockScreenerData> results = new List <StockScreenerData>(); string result = MyHelper.StreamToString(stream, set.TextEncoding); List <string> lines = new List <string>(result.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); if (lines.Count > 0) { System.Globalization.CultureInfo convCulture = new System.Globalization.CultureInfo("en-US"); List <QuoteProperty> quoteProps = new List <QuoteProperty>(); List <StockScreenerProperty> screenerProps = new List <StockScreenerProperty>(); foreach (StockCriteriaDefinition crit in set.Criterias) { foreach (QuoteProperty qp in crit.ProvidedQuoteProperties) { if (!quoteProps.Contains(qp)) { quoteProps.Add(qp); } } foreach (StockScreenerProperty sp in crit.ProvidedScreenerProperties) { if (!screenerProps.Contains(sp)) { screenerProps.Add(sp); } } } string[] propertySymbols = new string[-1 + 1]; string[] propertyNames = new string[-1 + 1]; int startIndex = 0; if (!set.Comparing) { startIndex = 2; propertySymbols = lines[0].Split('|'); propertyNames = lines[1].Split('|'); } else { startIndex = 0; List <string> lstSymbols = new List <string>(); lstSymbols.Add(""); lstSymbols.Add(""); lstSymbols.Add("b"); lstSymbols.Add(""); lstSymbols.Add("c"); lstSymbols.Add("8o"); lstSymbols.Add("9c"); lstSymbols.Add("9t"); foreach (StockCriteriaDefinition crt in set.Criterias) { if (crt.ProvidedQuoteProperties.Length > 5 | crt.ProvidedScreenerProperties.Length > 3) { lstSymbols.Add(crt.CriteriaTag); } } propertySymbols = lstSymbols.ToArray(); List <string> lstNames = new List <string>(); lstNames.Add("Ticker"); lstNames.Add("Company Name"); lstNames.Add("Last Trade"); lstNames.Add("Trade Time"); lstNames.Add("Mkt Cap"); lstNames.Add("Return On Equity"); lstNames.Add("Return On Assets"); lstNames.Add("Forward PE"); foreach (StockCriteriaDefinition crt in set.Criterias) { if (crt.ProvidedQuoteProperties.Length > 5 | crt.ProvidedScreenerProperties.Length > 3) { switch (crt.CriteriaTag) { case "f": case "g": if (crt is PriceGainerLosersCriteria) { PriceGainerLosersCriteria mngCrt = (PriceGainerLosersCriteria)crt; if (mngCrt.ValueRelativeTo == StockTradingAbsoluteTimePoint.TodaysOpen) { lstNames.Add("(open)"); } else { lstNames.Add("(close)"); } } break; case "h": case "i": if (crt is PriceMomentumCriteria) { PriceMomentumCriteria mngCrt = (PriceMomentumCriteria)crt; lstNames.Add("(" + mngCrt.RelativeTimeSpanInMinutes.ToString().Replace("_", "") + "m)"); } break; default: lstNames.Add(""); break; } } } propertyNames = lstNames.ToArray(); } for (int i = startIndex; i <= lines.Count - 1; i++) { string[] values = lines[i].Split('|'); if (propertySymbols.Length >= 4 & values.Length == propertySymbols.Length & values.Length == propertyNames.Length) { string id = values[0]; string name = values[1]; double lastTradePriceOnly = 0; double.TryParse(values[2], System.Globalization.NumberStyles.Any, convCulture, out lastTradePriceOnly); DateTime tradeTime = new DateTime(); DateTime.TryParse(values[3], convCulture, System.Globalization.DateTimeStyles.None, out tradeTime); tradeTime = tradeTime.AddHours(tradeTime.Hour).AddMinutes(tradeTime.Minute); StockScreenerData res = new StockScreenerData(id, name, lastTradePriceOnly, tradeTime, quoteProps.ToArray(), screenerProps.ToArray()); if (values.Length >= 5) { for (int p = 4; p <= values.Length - 1; p++) { if (values[p] != string.Empty & values[p] != "N/A") { double dblValue = 0; if (double.TryParse(values[p], System.Globalization.NumberStyles.Any, convCulture, out dblValue) || FinanceHelper.GetMillionValue(values[p]) != 0) { switch (propertySymbols[p]) { case "c": res[QuoteProperty.MarketCapitalization] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; //case "c": //res.AdditionalValues[(int)StockScreenerProperty.RevenueEstimate_ThisYear] = dblValue; //break; case "8o": res.AdditionalValues[(int)StockScreenerProperty.ReturnOnEquity] = dblValue; break; case "9c": res.AdditionalValues[(int)StockScreenerProperty.ReturnOnAssets] = dblValue; break; case "9t": res.AdditionalValues[(int)StockScreenerProperty.ForwardPriceToEarningsRatio] = dblValue; break; case "9o": res.AdditionalValues[(int)StockScreenerProperty.NumberOfEmployees] = dblValue; break; case "f": double absoluteChange = dblValue; double absolutePreviousValue = res.LastTradePriceOnly - absoluteChange; double changeInPercent = absoluteChange / absolutePreviousValue; res[QuoteProperty.ChangeInPercent] = changeInPercent * 100; res[QuoteProperty.Change] = absoluteChange; if (propertyNames[p].EndsWith("(open)")) { res[QuoteProperty.Open] = absolutePreviousValue; } else { res[QuoteProperty.PreviousClose] = absolutePreviousValue; } break; case "g": changeInPercent = dblValue; absolutePreviousValue = (res.LastTradePriceOnly / (100 + changeInPercent)) * 100; absoluteChange = res.LastTradePriceOnly - absolutePreviousValue; res[QuoteProperty.ChangeInPercent] = changeInPercent; res[QuoteProperty.Change] = absoluteChange; if (propertyNames[p].EndsWith("(open)")) { res[QuoteProperty.Open] = absolutePreviousValue; } else { res[QuoteProperty.PreviousClose] = absolutePreviousValue; } break; case "h": if (set.Criterias != null) { PriceMomentumCriteria context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is PriceMomentumCriteria && ((PriceMomentumCriteria)crit).PercentValues == false) { context = (PriceMomentumCriteria)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { if (propertyNames[p].EndsWith("(" + context.RelativeTimeSpanInMinutes.ToString().Replace("_", "") + "m)")) { TemporaryPriceChangeInfo info = new TemporaryPriceChangeInfo(); info.ChangeRelativeTimePoint = context.TimeSpanRelativeTo; info.ChangeTimeSpan = context.RelativeTimeSpanInMinutes; info.Change = dblValue * Convert.ToInt32((context.GainOrLoss == StockPriceChangeDirection.Gain ? 1 : -1)); info.ChangeInPercent = info.Change / (res.LastTradePriceOnly - info.Change); res.TemporaryLimitedChange = info; } } } break; case "i": if (set.Criterias != null) { PriceMomentumCriteria context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is PriceMomentumCriteria && ((PriceMomentumCriteria)crit).PercentValues == true) { context = (PriceMomentumCriteria)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { if (propertyNames[p].EndsWith("(" + context.RelativeTimeSpanInMinutes.ToString().Replace("_", "") + "m)")) { TemporaryPriceChangeInfo info = new TemporaryPriceChangeInfo(); info.ChangeRelativeTimePoint = context.TimeSpanRelativeTo; info.ChangeTimeSpan = context.RelativeTimeSpanInMinutes; info.ChangeInPercent = dblValue * Convert.ToInt32((context.GainOrLoss == StockPriceChangeDirection.Gain ? 1 : -1)); info.Change = res.LastTradePriceOnly - ((res.LastTradePriceOnly / (100 + info.ChangeInPercent)) * 100); res.TemporaryLimitedChange = info; } } } break; case "j": if (set.Criterias != null) { ExtremePriceCriteria context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is ExtremePriceCriteria && ((ExtremePriceCriteria)crit).PercentValues == false) { context = (ExtremePriceCriteria)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { absoluteChange = dblValue * Convert.ToInt32((context.LessGreater == LessGreater.Greater ? 1 : -1)); absolutePreviousValue = res.LastTradePriceOnly - absoluteChange; changeInPercent = absoluteChange / absolutePreviousValue; switch (context.ExtremeParameter) { case StockExtremeParameter.TodaysHigh: res[QuoteProperty.DaysHigh] = absolutePreviousValue; break; case StockExtremeParameter.TodaysLow: res[QuoteProperty.DaysLow] = absolutePreviousValue; break; case StockExtremeParameter.YearsHigh: res[QuoteProperty.YearHigh] = absolutePreviousValue; res[QuoteProperty.ChangeInPercentFromYearHigh] = changeInPercent; res[QuoteProperty.ChangeFromYearHigh] = absoluteChange; break; case StockExtremeParameter.YearsLow: res[QuoteProperty.YearLow] = absolutePreviousValue; res[QuoteProperty.PercentChangeFromYearLow] = changeInPercent; res[QuoteProperty.ChangeFromYearLow] = absoluteChange; break; } } } break; case "k": if (set.Criterias != null) { ExtremePriceCriteria context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is ExtremePriceCriteria && ((ExtremePriceCriteria)crit).PercentValues == true) { context = (ExtremePriceCriteria)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { changeInPercent = dblValue * Convert.ToInt32((context.LessGreater == LessGreater.Greater ? 1 : -1)); absolutePreviousValue = (res.LastTradePriceOnly / (100 + changeInPercent)) * 100; absoluteChange = res.LastTradePriceOnly - absolutePreviousValue; switch (context.ExtremeParameter) { case StockExtremeParameter.TodaysHigh: res[QuoteProperty.DaysHigh] = absolutePreviousValue; break; case StockExtremeParameter.TodaysLow: res[QuoteProperty.DaysLow] = absolutePreviousValue; break; case StockExtremeParameter.YearsHigh: res[QuoteProperty.YearHigh] = absolutePreviousValue; res[QuoteProperty.ChangeInPercentFromYearHigh] = changeInPercent; res[QuoteProperty.ChangeFromYearHigh] = absoluteChange; break; case StockExtremeParameter.YearsLow: res[QuoteProperty.YearLow] = absolutePreviousValue; res[QuoteProperty.PercentChangeFromYearLow] = changeInPercent; res[QuoteProperty.ChangeFromYearLow] = absoluteChange; break; } } } break; case "l": if (set.Criterias != null) { GapVsPreviousClose context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is GapVsPreviousClose && ((GapVsPreviousClose)crit).PercentValues == false) { context = (GapVsPreviousClose)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { res.AdditionalValues[(int)StockScreenerProperty.Gap] = dblValue; } } break; case "m": if (set.Criterias != null) { GapVsPreviousClose context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is GapVsPreviousClose && ((GapVsPreviousClose)crit).PercentValues == true) { context = (GapVsPreviousClose)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { res.AdditionalValues[(int)StockScreenerProperty.GapInPercent] = dblValue; } } break; case "o": if (set.Criterias != null) { PriceToMovingAverageRatioCriteria context = null; foreach (StockCriteriaDefinition crit in set.Criterias) { if (crit != null && crit is PriceToMovingAverageRatioCriteria) { context = (PriceToMovingAverageRatioCriteria)crit; break; // TODO: might not be correct. Was : Exit For } } if (context != null) { changeInPercent = dblValue; double maValue = (dblValue / (100 + changeInPercent)) * 100; absoluteChange = res.LastTradePriceOnly - maValue; if (context.MovingAverage == MovingAverageType.FiftyDays) { res[QuoteProperty.FiftydayMovingAverage] = maValue; res[QuoteProperty.ChangeFromFiftydayMovingAverage] = absoluteChange; res[QuoteProperty.PercentChangeFromFiftydayMovingAverage] = changeInPercent; } else { res[QuoteProperty.TwoHundreddayMovingAverage] = maValue; res[QuoteProperty.ChangeFromTwoHundreddayMovingAverage] = absoluteChange; res[QuoteProperty.PercentChangeFromTwoHundreddayMovingAverage] = changeInPercent; } } } break; case "7": res.AdditionalValues[(int)StockScreenerProperty.Beta] = dblValue; break; case "v": res[QuoteProperty.PriceSales] = dblValue; break; case "e": res.AdditionalValues[(int)StockScreenerProperty.PriceEarningsRatio] = dblValue; break; case "u": res[QuoteProperty.PEGRatio] = dblValue; break; case "9p": res.AdditionalValues[(int)StockScreenerProperty.EntityValue] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "9q": res.AdditionalValues[(int)StockScreenerProperty.EntityValueToRevenueRatio] = dblValue; break; case "9r": res.AdditionalValues[(int)StockScreenerProperty.EntityValueToOperatingCashFlowRatio] = dblValue; break; case "9s": res.AdditionalValues[(int)StockScreenerProperty.EntityValueToFreeCashFlowRatio] = dblValue; break; case "x": res[QuoteProperty.EPSEstimateNextQuarter] = dblValue; break; case "y": res[QuoteProperty.EPSEstimateCurrentYear] = dblValue; break; case "z": res[QuoteProperty.EPSEstimateNextYear] = dblValue; break; case "8e": res.AdditionalValues[(int)StockScreenerProperty.EPS_NYCE] = dblValue; break; case "9v": res.AdditionalValues[(int)StockScreenerProperty.SalesGrowthEstimate_ThisQuarter] = dblValue; break; case "8h": res.AdditionalValues[(int)StockScreenerProperty.EarningsGrowthEstimate_ThisYear] = dblValue; break; case "9b": res.AdditionalValues[(int)StockScreenerProperty.EarningsGrowthEstimate_NextYear] = dblValue; break; case "9u": res.AdditionalValues[(int)StockScreenerProperty.EarningsGrowthEstimate_Next5Years] = dblValue; break; case "1": res.AdditionalValues[(int)StockScreenerProperty.SharesOutstanding] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "2": res[QuoteProperty.SharesFloat] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "3": res[QuoteProperty.ShortRatio] = dblValue; break; case "8g": res.AdditionalValues[(int)StockScreenerProperty.SharesShortPriorMonth] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8m": res.AdditionalValues[(int)StockScreenerProperty.SharesShort] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "9d": res.AdditionalValues[(int)StockScreenerProperty.HeldByInsiders] = dblValue; break; case "9n": res.AdditionalValues[(int)StockScreenerProperty.HeldByInstitutions] = dblValue; break; case "4": res[QuoteProperty.TrailingAnnualDividendYield] = dblValue; break; case "5": res[QuoteProperty.TrailingAnnualDividendYieldInPercent] = dblValue; break; case "8a": res.AdditionalValues[(int)StockScreenerProperty.OperatingMargin] = dblValue; break; case "8r": res.AdditionalValues[(int)StockScreenerProperty.ProfitMargin_ttm] = dblValue; break; case "9f": res.AdditionalValues[(int)StockScreenerProperty.EBITDAMargin_ttm] = dblValue; break; case "9k": res.AdditionalValues[(int)StockScreenerProperty.GrossMargin_ttm] = dblValue; break; case "8f": res[QuoteProperty.PriceBook] = dblValue; break; //case "8f": //res.AdditionalValues[(int)StockScreenerProperty.CashPerShare] = dblValue; //break; case "8l": res.AdditionalValues[(int)StockScreenerProperty.TotalCash] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "6": res[QuoteProperty.BookValuePerShare] = dblValue; break; case "9e": res.AdditionalValues[(int)StockScreenerProperty.TotalDebt] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "9g": res.AdditionalValues[(int)StockScreenerProperty.TotalDebtToEquityRatio] = dblValue; break; case "9h": res.AdditionalValues[(int)StockScreenerProperty.CurrentRatio] = dblValue; break; case "9i": res.AdditionalValues[(int)StockScreenerProperty.LongTermDebtToEquityRatio] = dblValue; break; case "9l": res.AdditionalValues[(int)StockScreenerProperty.QuickRatio] = dblValue; break; case "w": res[QuoteProperty.DilutedEPS] = dblValue; break; case "8i": res.AdditionalValues[(int)StockScreenerProperty.EPS_mrq] = dblValue; break; case "0": res.AdditionalValues[(int)StockScreenerProperty.Sales_ttm] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "t": res[QuoteProperty.EBITDA] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8n": res.AdditionalValues[(int)StockScreenerProperty.GrossProfit] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8p": res.AdditionalValues[(int)StockScreenerProperty.NetIncome] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "9j": res.AdditionalValues[(int)StockScreenerProperty.OperatingIncome] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8v": res.AdditionalValues[(int)StockScreenerProperty.EarningsGrowth_Past5Years] = dblValue; break; case "9a": res.AdditionalValues[(int)StockScreenerProperty.RevenueEstimate_ThisQuarter] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8q": res.AdditionalValues[(int)StockScreenerProperty.RevenueEstimate_NextQuarter] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8s": res.AdditionalValues[(int)StockScreenerProperty.SalesGrowthEstimate_NextQuarter] = dblValue; break; case "8t": res.AdditionalValues[(int)StockScreenerProperty.SalesGrowthEstimate_ThisYear] = dblValue; break; case "8k": res.AdditionalValues[(int)StockScreenerProperty.SalesGrowthEstimate_NextYear] = dblValue; break; case "8y": res.AdditionalValues[(int)StockScreenerProperty.FreeCashFlow] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; case "8z": res.AdditionalValues[(int)StockScreenerProperty.OperatingCashFlow] = Convert.ToInt64(FinanceHelper.GetMillionValue(values[p]) * (Math.Pow(10, 6))); break; } } } } } results.Add(res); } } } return(new StockScreenerResult(results.ToArray())); }
public void DownloadAsync(IEnumerable <IID> ids, IEnumerable <StockCriteriaDefinition> criterias, object userArgs) { this.DownloadAsync(FinanceHelper.IIDsToStrings(ids), MyHelper.EnumToArray(criterias), userArgs); }
/// <summary> /// Creates a new instance by an ID /// </summary> /// <param name="id"></param> /// <remarks></remarks> public YID(string id) { this.SetID(FinanceHelper.CleanIndexID(id)); }
public override string GetUrl(string ticker) { String url = UrlStr + Uri.EscapeDataString(ticker) + "&f=" + FinanceHelper.CsvQuotePropertyTags(this.Properties) + "&e=.csv"; return(url); }
async Task <(Model.Bill, Model.Payment)> GenerateBillPayment(DbContext dbContext) { var gst = await FinanceHelper.GetGST(dbContext); var gstAmount = _param.Amount * gst; var amount = _param.Amount - gstAmount; var code = await dbContext.Transactioncode.GetTransactionCodeByCode( TransactionCodes.CompositionSum); if (code == null) { throw new BadRequestException("Composition sum code not setup. Please contact administrator."); } await dbContext.Account.InsertOrReplace(new Account { ID = _param.PayerID, Name = _param.PayerName }); // Insert/replace contact peron await PersonHelper.InsertOrReplace(dbContext, _param.ContactPerson); var bill = new Model.Bill { Status = BillStatus.Pending, Type = BillType.CompositionSum, RefNo = _param.RefID, Amount = amount, GSTAmount = gstAmount, GST = gst, RefID = _param.RefID, CustomerID = _param.PayerID, CustomerName = _param.PayerName, IssuedOn = DateTime.UtcNow, LineItems = new List <BillLineItem> { new BillLineItem { SectionIndex = 0, Section = "Item Details", Index = 1, CodeID = code.ID, Descr = code.Text, Amount = amount, GSTAmount = gstAmount, GST = gst, WillRecord = true } } }; bill.ID = await dbContext.Bill.InsertBill(bill); var payment = new Model.Payment { AltID = _param.BankAccountName, RefNo = _param.RefNo, Status = PaymentStatus.Pending, Mode = _param.Mode, Method = _param.Method, TransactionNo = Guid.NewGuid().ToString(), AccountID = _param.PayerID, Name = _param.PayerName, Amount = amount, GSTAmount = gstAmount, GST = gst, PaidOn = DateTime.UtcNow, ContactPersonID = _param.ContactPerson?.ID ?? null, ContactPerson = _param.ContactPerson, Bills = new List <Model.Bill> { bill } }; payment.ID = await dbContext.Payment.Insert(payment); await dbContext.Payment.MapBill(payment.ID, bill.ID); if (_param.Mode == PaymentMode.Offline) { Model.Bank bank = null; var banks = await dbContext.Bank.Query( new BankFilter { AccountName = _param.BankAccountName }); if ((banks?.Count() ?? 0) == 1) { bank = banks.First(); await dbContext.Payment.MapBank(payment.ID, bank.ID); } } return(bill, payment); }
protected override CompanyStatisticsAggregate ConvertResult(string contentStr, string ticker = "") { CompanyStatisticsData result = null; XParseDocument doc = MyHelper.ParseXmlDocument(contentStr); XParseElement resultNode = XPath.GetElement("//table[@id=\"yfncsumtab\"]/tr[2]", doc); if (resultNode != null) { XParseElement tempNode = null; XParseElement vmNode = XPath.GetElement("/td[1]/table[2]/tr/td/table", resultNode); double[] vmValues = new double[9]; if (vmNode != null) { tempNode = XPath.GetElement("/tr[1]/td[2]/span", vmNode); if (tempNode != null) { vmValues[0] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[2]/td[2]", vmNode); if (tempNode != null) { vmValues[1] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", vmNode); if (tempNode != null) { vmValues[2] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[4]/td[2]", vmNode); if (tempNode != null) { vmValues[3] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[5]/td[2]", vmNode); if (tempNode != null) { vmValues[4] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[6]/td[2]", vmNode); if (tempNode != null) { vmValues[5] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[7]/td[2]", vmNode); if (tempNode != null) { vmValues[6] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[8]/td[2]", vmNode); if (tempNode != null) { vmValues[7] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[9]/td[2]", vmNode); if (tempNode != null) { vmValues[8] = FinanceHelper.ParseToDouble(tempNode.Value); } } CompanyValuationMeasures vm = new CompanyValuationMeasures(vmValues); XParseElement fyNode = XPath.GetElement("/td[1]/table[4]/tr/td/table", resultNode); XParseElement profitNode = XPath.GetElement("/td[1]/table[5]/tr/td/table", resultNode); XParseElement meNode = XPath.GetElement("/td[1]/table[6]/tr/td/table", resultNode); XParseElement isNode = XPath.GetElement("/td[1]/table[7]/tr/td/table", resultNode); XParseElement bsNode = XPath.GetElement("/td[1]/table[8]/tr/td/table", resultNode); XParseElement cfsNode = XPath.GetElement("/td[1]/table[9]/tr/td/table", resultNode); DateTime fiscalYEnds = new DateTime(); DateTime mostRecQutr = new DateTime(); double[] fhValues = new double[20]; if (fyNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", fyNode); if (tempNode != null) { fiscalYEnds = FinanceHelper.ParseToDateTime(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", fyNode); if (tempNode != null) { mostRecQutr = FinanceHelper.ParseToDateTime(tempNode.Value); } } if (profitNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", profitNode); if (tempNode != null) { fhValues[0] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", profitNode); if (tempNode != null) { fhValues[1] = FinanceHelper.ParseToDouble(tempNode.Value); } } if (meNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", meNode); if (tempNode != null) { fhValues[2] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", meNode); if (tempNode != null) { fhValues[3] = FinanceHelper.ParseToDouble(tempNode.Value); } } if (isNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", isNode); if (tempNode != null) { fhValues[4] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", isNode); if (tempNode != null) { fhValues[5] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[4]/td[2]", isNode); if (tempNode != null) { fhValues[6] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[5]/td[2]", isNode); if (tempNode != null) { fhValues[7] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[6]/td[2]", isNode); if (tempNode != null) { fhValues[8] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[7]/td[2]", isNode); if (tempNode != null) { fhValues[9] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[8]/td[2]", isNode); if (tempNode != null) { fhValues[10] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[9]/td[2]", isNode); if (tempNode != null) { fhValues[11] = FinanceHelper.ParseToDouble(tempNode.Value); } } if (bsNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", bsNode); if (tempNode != null) { fhValues[12] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", bsNode); if (tempNode != null) { fhValues[13] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[4]/td[2]", bsNode); if (tempNode != null) { fhValues[14] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[5]/td[2]", bsNode); if (tempNode != null) { fhValues[15] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[6]/td[2]", bsNode); if (tempNode != null) { fhValues[16] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[7]/td[2]", bsNode); if (tempNode != null) { fhValues[17] = FinanceHelper.ParseToDouble(tempNode.Value); } } if (cfsNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", cfsNode); if (tempNode != null) { fhValues[18] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", cfsNode); if (tempNode != null) { fhValues[19] = FinanceHelper.GetMillionValue(tempNode.Value); } } CompanyFinancialHighlights fh = new CompanyFinancialHighlights(fiscalYEnds, mostRecQutr, fhValues); XParseElement sphNode = XPath.GetElement("/td[3]/table[2]/tr/td/table", resultNode); XParseElement stNode = XPath.GetElement("/td[3]/table[3]/tr/td/table", resultNode); XParseElement dsNode = XPath.GetElement("/td[3]/table[4]/tr/td/table", resultNode); double[] ctiValues = new double[23]; DateTime exDivDate = new DateTime(); DateTime divDate = new DateTime(); DateTime splitDate = new DateTime(); SharesSplitFactor sf = null; if (sphNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", sphNode); if (tempNode != null) { ctiValues[0] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", sphNode); if (tempNode != null) { ctiValues[1] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[4]/td[2]", sphNode); if (tempNode != null) { ctiValues[2] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[5]/td[2]", sphNode); if (tempNode != null) { ctiValues[3] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[6]/td[2]", sphNode); if (tempNode != null) { ctiValues[4] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[7]/td[2]", sphNode); if (tempNode != null) { ctiValues[5] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[8]/td[2]", sphNode); if (tempNode != null) { ctiValues[6] = FinanceHelper.ParseToDouble(tempNode.Value); } } if (stNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", stNode); if (tempNode != null) { ctiValues[7] = FinanceHelper.ParseToDouble(tempNode.Value) / 1000; } tempNode = XPath.GetElement("/tr[3]/td[2]", stNode); if (tempNode != null) { ctiValues[8] = FinanceHelper.ParseToDouble(tempNode.Value) / 1000; } tempNode = XPath.GetElement("/tr[4]/td[2]", stNode); if (tempNode != null) { ctiValues[9] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[5]/td[2]", stNode); if (tempNode != null) { ctiValues[10] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[6]/td[2]", stNode); if (tempNode != null) { ctiValues[11] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[7]/td[2]", stNode); if (tempNode != null) { ctiValues[12] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[8]/td[2]", stNode); if (tempNode != null) { ctiValues[13] = FinanceHelper.GetMillionValue(tempNode.Value); } tempNode = XPath.GetElement("/tr[9]/td[2]", stNode); if (tempNode != null) { ctiValues[14] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[10]/td[2]", stNode); if (tempNode != null) { ctiValues[15] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[11]/td[2]", stNode); if (tempNode != null) { ctiValues[16] = FinanceHelper.GetMillionValue(tempNode.Value); } } if (dsNode != null) { tempNode = XPath.GetElement("/tr[2]/td[2]", dsNode); if (tempNode != null) { ctiValues[17] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[3]/td[2]", dsNode); if (tempNode != null) { ctiValues[18] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[4]/td[2]", dsNode); if (tempNode != null) { ctiValues[19] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[5]/td[2]", dsNode); if (tempNode != null) { ctiValues[20] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[6]/td[2]", dsNode); if (tempNode != null) { ctiValues[21] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[7]/td[2]", dsNode); if (tempNode != null) { ctiValues[22] = FinanceHelper.ParseToDouble(tempNode.Value); } tempNode = XPath.GetElement("/tr[8]/td[2]", dsNode); if (tempNode != null) { divDate = FinanceHelper.ParseToDateTime(tempNode.Value); } tempNode = XPath.GetElement("/tr[9]/td[2]", dsNode); if (tempNode != null) { exDivDate = FinanceHelper.ParseToDateTime(tempNode.Value); } tempNode = XPath.GetElement("/tr[10]/td[2]", dsNode); if (tempNode != null) { string[] txt = tempNode.Value.Split(':'); int from, to; if (int.TryParse(txt[0], out to) && int.TryParse(txt[1], out from)) { sf = new SharesSplitFactor(to, from); } } tempNode = XPath.GetElement("/tr[11]/td[2]", dsNode); if (tempNode != null) { splitDate = FinanceHelper.ParseToDateTime(tempNode.Value); } } CompanyTradingInfo cti = new CompanyTradingInfo(ctiValues, divDate, exDivDate, splitDate, sf); result = new CompanyStatisticsData(ticker, vm, fh, cti); } return(new CompanyStatisticsAggregate(result)); }