Public Class FormulasBonoCE Dim ElementosConsulta As New CargarElementosDAO Dim V_CodEmpr = ElementosConsulta.CodEmpr 'Dim V_CodIF = ElementosConsulta.CodIF Dim V_CodEmis = ElementosConsulta.CodEmis Dim V_CodECalRi = ElementosConsulta.CodECalRi Dim V_CodPais = ElementosConsulta.CodPais Dim V_ListaPlazo = ElementosConsulta.ListaPlazosFactor Dim V_ListaTiposMercados = ElementosConsulta.ListaTiposMercado Dim V_ListaPeriodos = ElementosConsulta.ListaPeriodos Dim V_ListaTipoTasa = ElementosConsulta.ListaTipoTasa Dim V_ListaTipoRenta = ElementosConsulta.ListaTipoRenta Dim V_ListaEstado = ElementosConsulta.ListaEstado Dim Operaciones As New Operaciones Dim V_ListaCasasCorredoras = ElementosConsulta.ListaCasasCorredoras Public ReadOnly Property ListaCasasCorredoras Get Return V_ListaCasasCorredoras End Get End Property Public ReadOnly Property ListaEstado Get Return V_ListaEstado End Get End Property Public ReadOnly Property ListaTipoRenta Get Return V_ListaTipoRenta End Get End Property Public ReadOnly Property ListaTipoTasa Get Return V_ListaTipoTasa End Get End Property Public ReadOnly Property ListaPeriodos Get Return V_ListaPeriodos End Get End Property Public ReadOnly Property CodPais Get Return V_CodPais End Get End Property Public ReadOnly Property CodEmpr Get Return V_CodEmpr End Get End Property Public ReadOnly Property ListaTiposMercados Get Return V_ListaTiposMercados End Get End Property Public ReadOnly Property ListaPlazo Get Return V_ListaPlazo End Get End Property Public ReadOnly Property CodEmis Get Return V_CodEmis End Get End Property Public ReadOnly Property CodECalRi Get Return V_CodECalRi End Get End Property Public Function DiasVencimiento(ByVal fecha1 As DateTime, ByVal fecha2 As DateTime, ByVal Base As Integer) fecha1 = Format(fecha1, "dd/MM/yyyy") fecha2 = Format(fecha2, "dd/MM/yyyy") Dim Total As Integer If (Base = 0 Or Base = 2) Then Total = Base360(fecha1, fecha2) ElseIf (Base = 1 Or Base = 3) Then Total = Base365(fecha1, fecha2) Else Total = 0 End If Return Total End Function Public Function DiasAcumulados(ByVal fecha1 As DateTime, ByVal fecha2 As DateTime, ByVal Base As Integer) Dim Total As Integer If (Base = 0 Or Base = 2) Then Total = Base360(fecha1, fecha2) ElseIf (Base = 1 Or Base = 3) Then Total = Base365(fecha1, fecha2) Else Total = 0 End If Return Total End Function Public Function InteresAcumulado(ByVal ValorNominal As Double, ByVal Cupon As Double, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal DiasAcumulados As Double, ByVal IndexBase As Integer) Dim Valor As Double = 0 If (IndexBase = 0) Then Valor = ValorNominal * Cupon * DiasAcumulados / 360 Return Valor ElseIf (IndexBase = 1) Then Dim PrOpc1 = 0.0, PrOpc2 = 0.0 Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then PrOpc1 = ValorNominal * Cupon * DiasPrimeraFecha / 366 PrOpc2 = ValorNominal * Cupon * DiasSegundaFecha / 365 Valor = PrOpc1 + PrOpc2 ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then Valor = ValorNominal * Cupon * DiasSegundaFecha / 365 ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then Valor = ValorNominal * Cupon * DiasPrimeraFecha / 366 Else Valor = 0 End If Return Valor ElseIf (IndexBase = 2) Then Dim PrOpc1 = 0.0, PrOpc2 = 0.0 Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2) DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2) If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then PrOpc1 = ValorNominal * Cupon * DiasPrimeraFecha / 366 PrOpc2 = ValorNominal * Cupon * DiasSegundaFecha / 365 Valor = PrOpc1 + PrOpc2 ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then Valor = ValorNominal * Cupon * DiasSegundaFecha / 365 ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then Valor = ValorNominal * Cupon * DiasPrimeraFecha / 366 Else Valor = 0 End If Return Valor Else Dim PrOpc1 = 0.0, PrOpc2 = 0.0 Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then PrOpc1 = ValorNominal * Cupon * DiasPrimeraFecha / 360 PrOpc2 = ValorNominal * Cupon * DiasSegundaFecha / 360 Valor = PrOpc1 + PrOpc2 ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then Valor = ValorNominal * Cupon * DiasSegundaFecha / 360 ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then Valor = ValorNominal * Cupon * DiasPrimeraFecha / 360 Else Valor = 0 End If Return Valor End If End Function Public Function InteresAcumuladoPor(ByVal InteresAcumulado As Double, ByVal ValorNominal As Double, ByVal Periodicidad As Double, ByVal IndexBase As Integer) Dim Valor As Double = 0 If (IndexBase = 0 Or IndexBase = 2) Then Valor = ((InteresAcumulado / ValorNominal) * 360) / (Periodicidad * 30) Return Valor ElseIf (IndexBase = 1 Or IndexBase = 3) Then Valor = ((InteresAcumulado / ValorNominal) * 365) / (Periodicidad * 30) Return Valor End If Return Valor End Function Public Function PrecioSucio(ByVal PrecioCompra As Double, ByVal InteresAcumulado As Double) Dim Proceso = (PrecioCompra * 0.01 + InteresAcumulado) * 100 Return Proceso End Function Public Function ValorTrasado(ByVal PrecioCompra As Double, ByVal ValorNominal As Double) Dim Proceso = (PrecioCompra / 100) * ValorNominal Return Proceso End Function Public Function Comisiones(ByVal Comision As Double, ByVal ValorTrasado As Double) Dim Valor = CDec(Comision) * CDec(ValorTrasado) Return Valor / 100 End Function Public Function MontoPagar(ByVal ValorTrasado As Double, ByVal ComisionBolsa As Double, ByVal ComisionCasa As Double, ByVal InteresAcumulado As Double, ByVal CostoTransferencias As Double) Dim Valor = ValorTrasado + ComisionBolsa + ComisionCasa + InteresAcumulado + CostoTransferencias Return Valor End Function Public Function MontoRecibir(ByVal ValorTrasado As Double, ByVal ComisionBolsa As Double, ByVal ComisionCasa As Double, ByVal InteresAcumulado As Double) Dim Valor = ValorTrasado - ComisionBolsa - ComisionCasa + InteresAcumulado Return Valor End Function Public Function MontoRecibir(ByVal ValorTrasado As Double, ByVal ComisionBolsa As Double, ByVal ComisionCasa As Double, ByVal InteresAcumulado As Double, ByVal InteresGenerado As Double) Dim Valor = ValorTrasado - ComisionBolsa - ComisionCasa + InteresAcumulado + InteresGenerado Return Valor End Function Public Function Base360(ByVal Fecha1 As Date, ByVal Fecha2 As Date) Dim dia As Integer Dim dias31 As Integer Dim febreros As Integer Dim bisiesto As Integer While (Fecha1 < Fecha2) dia = dia + 1 If (Fecha1.Day = 31) Then dias31 = dias31 + 1 End If If (Fecha1.Month = 2 And Fecha1.Day = 28) Then febreros = febreros + 2 End If If (Fecha1.Month = 2 And Fecha1.Day = 29) Then bisiesto = bisiesto + 1 End If Fecha1 = Fecha1.AddDays(1) End While Dim Total = dia - dias31 + febreros - bisiesto Return Total End Function Public Function Base365(ByVal Fecha1 As Date, ByVal Fecha2 As Date) Dim dias = DateDiff(DateInterval.Day, Fecha1, Fecha2) Return dias End Function End Class