public static List <Financials> GetFinancials(this List <ExcelRequestModel> items) { List <Financials> list = new List <Financials>(); for (int j = 1; j <= 8; j++) { Financials financials = new Financials(); for (int i = 0; i < items.Count; i++) { if (i == 0) { items.ElementAt(i).Map("Year", j, ref financials); } if (i == 1) { items.ElementAt(i).Map("Sales", j, ref financials); } if (i == 2) { items.ElementAt(i).Map("Cost", j, ref financials); } if (i == 3) { items.ElementAt(i).Map("Profit", j, ref financials); } } if (financials.Year != 0) { list.Add(financials); } } return(list); }
/// <summary> /// For industrial companies current assets should be at least twice /// current liabilities—a so-called two-to-one current ratio. /// Also, longterm debt should not exceed the net current assets (or “working /// capital”). /// For public utilities the debt should not exceed twice the /// stock equity (at book value). /// </summary> /// <returns></returns> private bool IsFinanciallyStrong() { Financials lastStatement = _stockUnderEvaluation.Financials.Last(); // soem companies have lastStatement.TotalLiabilities = 0 not sure why, therefore ignoring those if (lastStatement.TotalLiabilities * 2 <= lastStatement.TotalAssets) { return(true); } if (lastStatement.LongTermDebt < lastStatement.TotalAssets) { return(true); } if (lastStatement.LongTermDebt < (lastStatement.BookValuePerShare * lastStatement.Shares) * 2) { return(true); } return(false); }
public Financials getFinancials(string symbol) { string IEXTrading_API_PATH = BASE_URL + "stock/" + symbol + "/financials"; string dataFromApi = ""; Financials data = null; httpClient.BaseAddress = new Uri(IEXTrading_API_PATH); HttpResponseMessage response = httpClient.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { dataFromApi = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!dataFromApi.Equals("")) { data = JsonConvert.DeserializeObject <Financials>(dataFromApi, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } return(data); }
public Customer() { Type = "DEB"; //Dimension type of customers is DEB. Beginperiod = 1; Beginyear = 1; Endperiod = 1; Endyear = 1; Financials = new Financials { Matchtype = MatchType.Customersupplier, //Fixed value customersupplier. Accounttype = "inherit", //Fixed value inherit. Subanalyse = Subanalyse.False, //Fixed value false Duedays = 100, Substitutionlevel = 1, //Level of the balancesheet account. Fixed value 1. Payavailable = false, //Determines if direct debit is possible. Ebilling = false, //Determines if the sales invoices will be sent electronically to the customer. Vatobligatory = false, Collectionschema = CollectionSchema.Core, //Collection schema information. Apply this information only when the customer invoices are collected by SEPA direct debit. Collectmandate = new Collectmandate { Id = "1" }, Vatcode = new VatCode() }; Creditmanagement = new Creditmanagement { Sendreminder = SendReminder.False, //Determines if and how a customer will be reminded. Blocked = false, //Indicates if related projects for this customer are blocked in time & expenses. Freetext1 = true, //Right of use Basecreditlimit = 500, //The credit limit amount. }; Banks = new Banks(); Postingrules = new Postingrules(); Addresses = new Addresses(); Paymentconditions = new Paymentconditions(); }
public static void Map(this ExcelRequestModel model, string Label, int columnNo, ref Financials financials) { if (columnNo == 1) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col1); } else if (Label.Equals("Sales")) { financials.Sales = model.Col1; } else if (Label.Equals("Cost")) { financials.Costs = model.Col1; } else if (Label.Equals("Profit")) { financials.Profit = model.Col1; } } if (columnNo == 2) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col2); } else if (Label.Equals("Sales")) { financials.Sales = model.Col2; } else if (Label.Equals("Cost")) { financials.Costs = model.Col2; } else if (Label.Equals("Profit")) { financials.Profit = model.Col2; } } if (columnNo == 3) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col3); } else if (Label.Equals("Sales")) { financials.Sales = model.Col3; } else if (Label.Equals("Cost")) { financials.Costs = model.Col3; } else if (Label.Equals("Profit")) { financials.Profit = model.Col3; } } if (columnNo == 4) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col4); } else if (Label.Equals("Sales")) { financials.Sales = model.Col4; } else if (Label.Equals("Cost")) { financials.Costs = model.Col4; } else if (Label.Equals("Profit")) { financials.Profit = model.Col4; } } if (columnNo == 5) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col5); } else if (Label.Equals("Sales")) { financials.Sales = model.Col5; } else if (Label.Equals("Cost")) { financials.Costs = model.Col5; } else if (Label.Equals("Profit")) { financials.Profit = model.Col5; } } if (columnNo == 6) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col6); } else if (Label.Equals("Sales")) { financials.Sales = model.Col6; } else if (Label.Equals("Cost")) { financials.Costs = model.Col6; } else if (Label.Equals("Profit")) { financials.Profit = model.Col6; } } if (columnNo == 7) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col7); } else if (Label.Equals("Sales")) { financials.Sales = model.Col7; } else if (Label.Equals("Cost")) { financials.Costs = model.Col7; } else if (Label.Equals("Profit")) { financials.Profit = model.Col7; } } if (columnNo == 8) { if (Label.Equals("Year")) { financials.Year = Convert.ToInt32(model.Col8); } else if (Label.Equals("Sales")) { financials.Sales = model.Col8; } else if (Label.Equals("Cost")) { financials.Costs = model.Col8; } else if (Label.Equals("Profit")) { financials.Profit = model.Col8; } } }
/// <summary> /// Update all financial data (currently using morningstar) /// </summary> /// <param name="stock"></param> private void UpdateFinancialData(Stock stock) { try { // only update financials if at least a month has passed if (stock.LastUpdate.Year < DateTime.Now.Year || (stock.LastUpdate.Year == DateTime.Now.Year && stock.LastUpdate.Month < DateTime.Now.Month) || stock.Financials == null || stock.Financials.Count == 0 || stock.FinancialsRawCSV == null || stock.KeyRatiosRawCSV == null || true) { MorningstarLib.Reader morningReader = new MorningstarLib.Reader(); if (!morningReader.GetFinancialData(stock.TickerM, out string keyRatios, out string financialStatement)) { throw new Exception("Acquiring financial data from morningstar-webpage failed"); } if (stock.FinancialsRawCSV == null) { stock.FinancialsRawCSV = new List <string>(); } if (stock.KeyRatiosRawCSV == null) { stock.KeyRatiosRawCSV = new List <string>(); } stock.FinancialsRawCSV.Add(financialStatement); stock.KeyRatiosRawCSV.Add(keyRatios); // transform raw csv to internal financials representation MorningstarCsvToStock csvToStock = new MorningstarCsvToStock(keyRatios, financialStatement); List <Financials> financialData = csvToStock.FinancialData; if (String.IsNullOrWhiteSpace(stock.Company)) { stock.Company = csvToStock.CompanyName; } // make sure stocks financials isn't null if (stock.Financials == null) { stock.Financials = new List <Financials>(); } // iterate over financial data and upadate or add appropriate db-entries foreach (Financials financePerYear in financialData) { // TTM is always overwritten if (financePerYear.IsTTM) { Financials ttmInDb = stock.Financials.Find(x => x.IsTTM); if (ttmInDb != null) { // do not overwrite dividend, may have been altered by user decimal dividend = ttmInDb.Dividends; // in db => overwrite ttmInDb = financePerYear; ttmInDb.Dividends = dividend; } else { // not in db => add stock.Financials.Add(financePerYear); } } else { if (!stock.Financials.Exists(x => x.Date == financePerYear.Date)) { // financial data for selected date isn't in the databse, so we store it stock.Financials.Add(financePerYear); } } } } } catch (Exception x) { Log.Error(x); } }