public double GetTotalRevenue(bool fromLocalValue = true) { AmmountCurrency portfolioValue = _analyticsService.GetPortfolioTotalValue(); AmmountCurrency totalValue = _analyticsService.GetTotalValue(fromLocalValue); AmmountCurrency totalCharges = _analyticsService.GetTotalCharges(); double totalRevenue = (portfolioValue.Ammount + totalValue.Ammount + totalCharges.Ammount) ?? 0; return(totalRevenue); }
/// <summary> /// Calcula el total acumulado en concepto de valor en la moneda de la cuenta de DeGiro /// </summary> /// <returns></returns> private AmmountCurrency GetPreCalculatedTotalValue() { AmmountCurrency totalValue = new AmmountCurrency() { Ammount = _transactions.Sum(x => x.Value.Ammount), Currency = _transactions.First(x => x.Value.Ammount != null).Value.Currency }; return(totalValue); }
/// <summary> /// Calcula el total acumulado en concepto de comisiones /// </summary> /// <returns></returns> public AmmountCurrency GetTotalCharges() { //TODO: Asume que todas las transacciones de Charge tienen la misma divisa AmmountCurrency totalCharges = new AmmountCurrency() { Ammount = _transactions.Sum(x => x.Charge.Ammount), Currency = _transactions.First(x => x.Charge.Ammount != null).Charge.Currency }; return(totalCharges); }
/// <summary> /// Calcula el valor absoluto de capital movido en concepto de valor de las operaciones /// </summary> /// <returns></returns> public AmmountCurrency GetAbsoluteOperatedVolume() { //TODO: Asume que todas las transacciones de Value tienen la misma divisa AmmountCurrency absoluteOperatedVolume = new AmmountCurrency() { Ammount = _transactions.Sum(x => Math.Abs(x.Value.Ammount.Value)), Currency = _transactions.First().Value.Currency }; return(absoluteOperatedVolume); }
private AmmountCurrency ParseLocalValue(string rawLocalValue) { string[] localValueParts = rawLocalValue.Split(); AmmountCurrency localValue = new AmmountCurrency() { Currency = localValueParts[0], Ammount = double.Parse(localValueParts[1]) }; return(localValue); }
/// <summary> /// Obtener el valor total del portfolio en la moneda de la cuenta de DeGiro /// </summary> /// <returns></returns> public AmmountCurrency GetPortfolioTotalValue() { //TODO: Depende de los tipos de cambio de divisa actuales para poder calcularse. //en el futuro podrían listarse los tipos ausentes y legar al usuario la responsabilidad //de alimentarlos. AmmountCurrency totalValue = new AmmountCurrency() { Ammount = _portfolio.Where(x => x.Quantity > 0).Sum(x => ToEUR(x.LocalValue)), Currency = "EUR" }; return(totalValue); }
public double?ToEUR(AmmountCurrency value) { switch (value.Currency) { case "EUR": return(value.Ammount); case "USD": return(value.Ammount / _eurUsd); default: throw new NotImplementedException("No es posible convertir la divisa " + value.Currency); } }
/// <summary> /// Calcula el total acumulado en concepto de valor (en la moneda de la cuenta de DeGiro, presumiblemente EUR) /// </summary> /// <param name="fromLocalValue">Realiza el cálculo empleando el tipo de cambio</param> /// <returns></returns> public AmmountCurrency GetTotalValue(bool fromLocalValue = true) { if (!fromLocalValue) { return(GetPreCalculatedTotalValue()); } AmmountCurrency totalValue = new AmmountCurrency() { Ammount = _transactions.Sum(x => x.ForeignExchangeRate.HasValue ? x.LocalValue.Ammount / x.ForeignExchangeRate : x.LocalValue.Ammount), Currency = _transactions.First(x => x.Value.Ammount != null).Value.Currency }; return(totalValue); }
public string GetCharges() { AmmountCurrency charges = _analyticsService.GetTotalCharges(); return(charges.Readable); }