| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- Public Class FormulasBonoCE
- Dim ElementosConsulta As New CargarElementosDAO
- Dim V_CodEmpr = ElementosConsulta.CodEmpr
- 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 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 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 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 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
|