private async Task <InvestimentosResponse> Investimentos() { DateTime dataConsulta = DateTime.Now; TesouroDiretoResponse tesouro = await _tesouroDiretoService.Get(); RendaFixaResponse rendaFixa = await _rendaFixaService.Get(); FundosResponse fundos = await _fundosService.Get(); InvestimentosResponse investimentos = new InvestimentosResponse(); PopulaTsouro(dataConsulta, tesouro, investimentos); PopulaRendaFixa(dataConsulta, rendaFixa, investimentos); PopulaFundos(dataConsulta, fundos, investimentos); return(investimentos); }
private static void PopulaRendaFixa(DateTime dataConsulta, RendaFixaResponse rendaFixa, InvestimentosResponse response) { foreach (var investimento in rendaFixa.Lcis) { decimal taxa = VerificaTaxaPeriodo(dataConsulta, investimento.DataOperacao, investimento.Vencimento); decimal valorResgate = CalcularValorMenosTaxa(investimento.CapitalAtual, taxa); response.ValorTotal += investimento.CapitalAtual; response.Investimentos.Add(new Investimento() { Nome = investimento.Nome, ValorInvestido = investimento.CapitalInvestido, ValorTotal = investimento.CapitalAtual, Vencimento = investimento.Vencimento, Ir = CalcularIr(investimento.CapitalInvestido, investimento.CapitalAtual, taxaInvestimentoRendaFixa), ValorResgate = valorResgate }); } }