| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168 |
- Public Class BonosCE
- Private _CodigoInversion As String
- Private _DocumentoBase As String
- Private _TipoBase As String
- Private _CodigoEmpresa As String
- Private _CodigoInstrumentoFinanciero As String = "BONO"
- Private _DescripcionInstrumentoFinanciero As String = "Bonos"
- Private _dtImpuestosYComisiones As DataTable
- Private _SumaImpuestosYComisionesVenta As Double
- Private _dtIngresos As DataTable
- Private _SumaIngresos As Double
- Private _SumaImpuestosIngresos As Double
- Private _SumaliquidoIngresos As Double
- Private Operaciones As New Operaciones
- Public Overridable ReadOnly Property CodigoInstrumentoFinanciero As String
- Get
- Return _CodigoInstrumentoFinanciero
- End Get
- End Property
- Public Overridable ReadOnly Property DescripcionInstrumentoFinanciero
- Get
- Return _DescripcionInstrumentoFinanciero
- End Get
- End Property
- Public Property CodigoEmpresa As String
- Get
- Return _CodigoEmpresa
- End Get
- Set(value As String)
- _CodigoEmpresa = value
- End Set
- End Property
- Public ReadOnly Property SumaIngresos As Double
- Get
- Return _SumaIngresos
- End Get
- End Property
- Public ReadOnly Property SumaImpuestosIngresos As Double
- Get
- Return _SumaImpuestosIngresos
- End Get
- End Property
- Public ReadOnly Property SumaliquidoIngresos As Double
- Get
- Return _SumaliquidoIngresos
- End Get
- End Property
- Public Property Ingresos As DataTable
- Get
- Return _dtIngresos
- End Get
- Set(value As DataTable)
- _dtIngresos = value
- End Set
- End Property
- Private _PeriodicidadCompra As String
- 'Private _CodigoCasaCompra As String
- Private _ValorNominalCompra As Double
- Private _UltimaFechaCuponCompra As Date
- Private _SiguienteFechaCuponCompra As Date
- Private _FechaLiquidacionCompra As Date
- Private _FechaVencimientoCompra As Date
- Private _PorcentajeCuponCompra As Double
- Private _YTMAlVencimientoComisionCompra As Double
- Private _YTMAlVencimientoCompra As Double
- Private _PrecioAlVencimientoCompra As Double
- Private _PrecioCompra As Double
- Private _DiasBaseCompra As Integer
- Private _DiasAcumuladosCompra As Integer
- Private _DiasAlVencimientoCompra As Integer
- Private _PorcentajeInteresAcumuladoCompra As Double
- Private _InteresAcumuladoCompra As Double
- Private _PrecioSucioCompra As Double
- Private _ValorTransadoCompra As Double
- Private _MontoAPagarCompra As Double
- Private _CostoDeTransferenciaCompra As Double
- Private _SumaImpuestosyComisionesCompra As Double
- 'Private _CodigoCasaVenta As String
- Private _ValorNominalVenta As Double
- Private _UltimaFechaCuponVenta As Date
- Private _SiguienteFechaCuponVenta As Date
- Private _FechaLiquidacionVenta As Date
- Private _FechaVencimientoVenta As Date
- Private _PorcentajeCuponVenta As Double
- Private _YTMAlVencimientoComisionVenta As Double
- Private _YTMAlVencimientoVenta As Double
- Private _PrecioAlVencimientoVenta As Double
- Private _PrecioVenta As Double
- Private _DiasBaseVenta As Integer
- Private _DiasAcumuladosVenta As Integer
- Private _DiasAlVencimientoVenta As Integer
- 'Private _PorcentajeInteresAcumuladoVenta As Double
- Private _InteresAcumuladoVenta As Double
- Private _InteresAcumuladoPorcentajeVenta As Double
- Private _PrecioSucioVenta As Double
- Private _ValorTransadoVenta As Double
- Private _MontoARecibirVenta As Double
- Private _PeriodicidadVenta As String
- Private _PorcentajeComisionCasaVenta As Double
- Private _PorcentajeComisionBolsaVenta As Double
- Private _CostoDeTransferenciaVenta As Double
- Private _ComisionBolsaVenta As Double
- Private _ComisionCasaVenta As Double
- Private _ValorNominalRO As Double
- Private _DiasPlazoRO As Integer
- Private _PrecioCompraRO As Double
- Private _PrecioVentaRO As Double
- Private _GananciaPerdidaDeCapital As Double
- Private _IngresoPorInteres As Double
- Private _CostosTotales As Double
- Private _GananciaPerdidaTotal As Double
- Private _RendimientoGananciaPerdida As Double
- Private _RendimientoDeIntereses As Double
- Private _RendimientoAntesImpuestos As Double
- Private _RendimientoDespuesImpuestos As Double
- Public Property CodigoInversion As String
- Get
- Return _CodigoInversion
- End Get
- Set(value As String)
- _CodigoInversion = value
- End Set
- End Property
- Public Property DocumentoBase As String
- Get
- Return _DocumentoBase
- End Get
- Set(value As String)
- _DocumentoBase = value
- End Set
- End Property
- Public Property TipoBase As String
- Get
- Return _TipoBase
- End Get
- Set(value As String)
- _TipoBase = value
- End Set
- End Property
- Public Property ImpuestosYComisiones As DataTable
- Get
- Return _dtImpuestosYComisiones
- End Get
- Set(value As DataTable)
- _dtImpuestosYComisiones = value
- CalcularSumaImpuestosyComisiones()
- End Set
- End Property
- Public Property SumaImpuestosYComisionesVenta As Double
- Get
- Return _SumaImpuestosYComisionesVenta
- End Get
- Set(value As Double)
- _SumaImpuestosYComisionesVenta = value
- End Set
- End Property
- 'COMPRA
- Public Property PeriodicidadCompra As String
- Get
- Return _PeriodicidadCompra
- End Get
- Set(value As String)
- _PeriodicidadCompra = value
- End Set
- End Property
- Public Property ValorNominalCompra As Double
- Get
- Return _ValorNominalCompra
- End Get
- Set(value As Double)
- _ValorNominalCompra = value
- CalcularInteresAcumuladoCompra()
- CalcularPorcentajeInteresAcumuladoCompra()
- CalcularValorTransadoCompra()
- End Set
- End Property
- Public Property UltimaFechaCuponCompra As Date
- Get
- Return _UltimaFechaCuponCompra
- End Get
- Set(value As Date)
- _UltimaFechaCuponCompra = value
- CalcularDiasAcumuladosCompra()
- End Set
- End Property
- Public Property SiguienteFechaCuponCompra As Date
- Get
- Return _SiguienteFechaCuponCompra
- End Get
- Set(value As Date)
- _SiguienteFechaCuponCompra = value
- CalcularDiasAcumuladosCompra()
- CalcularUltimaFechaCuponVenta()
- 'CalcularTablaIngresos()
- End Set
- End Property
- Public Property FechaLiquidacionCompra As Date
- Get
- Return _FechaLiquidacionCompra
- End Get
- Set(value As Date)
- _FechaLiquidacionCompra = value
- CalcularYTMAlVencimientoCompra()
- CalcularDiasAcumuladosCompra()
- CalcularDiasPlazoRO()
- End Set
- End Property
- Public Property FechaVencimientoCompra As Date
- Get
- Return _FechaVencimientoCompra
- End Get
- Set(value As Date)
- _FechaVencimientoCompra = value
- CalcularYTMAlVencimientoCompra()
- End Set
- End Property
- Public Property PorcentajeCuponCompra As Double
- Get
- Return _PorcentajeCuponCompra
- End Get
- Set(value As Double)
- _PorcentajeCuponCompra = value
- CalcularYTMAlVencimientoCompra()
- CalcularInteresAcumuladoCompra()
- End Set
- End Property
- Public ReadOnly Property PorcentajeCuponCompra_x100 As Double
- Get
- Return _PorcentajeCuponCompra * 100
- End Get
- End Property
- Public ReadOnly Property YTMAlVencimientoComisionCompra As Double
- Get
- Return _YTMAlVencimientoComisionCompra
- End Get
- End Property
- Public ReadOnly Property YTMAlVencimientoCompra As Double
- Get
- Return _YTMAlVencimientoCompra
- End Get
- End Property
- Public Property PrecioAlVencimientoCompra As Double
- Get
- Return _PrecioAlVencimientoCompra
- End Get
- Set(value As Double)
- _PrecioAlVencimientoCompra = value
- CalcularYTMAlVencimientoCompra()
- End Set
- End Property
- Public Property PrecioCompra As Double
- Get
- Return _PrecioCompra
- End Get
- Set(value As Double)
- _PrecioCompra = value
- CalcularYTMAlVencimientoCompra()
- CalcularPrecioSucioCompra()
- CalcularValorTransadoCompra()
- End Set
- End Property
- Public Property DiasBaseCompra As Integer
- Get
- Return _DiasBaseCompra
- End Get
- Set(value As Integer)
- _DiasBaseCompra = value
- CalcularInteresAcumuladoCompra()
- CalcularDiasAlVencimientoCompra()
- CalcularDiasAcumuladosCompra()
- CalcularYTMAlVencimientoComisionCompra()
- CalcularPorcentajeInteresAcumuladoCompra()
- CalcularDiasPlazoRO()
- CalcularRendimientoGananciaPerdida()
- CalcularRendimientoDeIntereses()
- CalcularRendimientoDespuesImpuestos()
- End Set
- End Property
- Public ReadOnly Property DiasAcumuladosCompra As Integer
- Get
- Return _DiasAcumuladosCompra
- End Get
- End Property
- Public ReadOnly Property DiasAlVencimientoCompra As Integer
- Get
- Return _DiasAlVencimientoCompra
- End Get
- End Property
- Public ReadOnly Property PorcentajeInteresAcumuladoCompra As Double
- Get
- Return _PorcentajeInteresAcumuladoCompra
- End Get
- End Property
- Public ReadOnly Property InteresAcumuladoCompra As Double
- Get
- Return _InteresAcumuladoCompra
- End Get
- End Property
- Public ReadOnly Property PrecioSucioCompra As Double
- Get
- Return _PrecioSucioCompra
- End Get
- End Property
- Public ReadOnly Property ValorTransadoCompra As Double
- Get
- Return _ValorTransadoCompra
- End Get
- End Property
- Public ReadOnly Property MontoAPagarCompra As Double
- Get
- Return _MontoAPagarCompra
- End Get
- End Property
- Public Property CostoDeTransferenciaCompra As Double
- Get
- Return _CostoDeTransferenciaCompra
- End Get
- Set(value As Double)
- _CostoDeTransferenciaCompra = value
- CalcularMontoAPagarCompra()
- End Set
- End Property
- Public ReadOnly Property SumaImpuestosyComisionesCompra As Double
- Get
- Return _SumaImpuestosyComisionesCompra
- End Get
- End Property
- 'VENTA
- Public Property ValorNominalVenta As Double
- Get
- Return _ValorNominalVenta
- End Get
- Set(value As Double)
- _ValorNominalVenta = value
- CalcularInteresAcumuladoVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- CalcularValorTransadoVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- End Set
- End Property
- Public Property UltimaFechaCuponVenta As Date
- Get
- Return _UltimaFechaCuponVenta
- End Get
- Set(value As Date)
- _UltimaFechaCuponVenta = value
- End Set
- End Property
- Public Property SiguienteFechaCuponVenta As Date
- Get
- Return _SiguienteFechaCuponVenta
- End Get
- Set(value As Date)
- _SiguienteFechaCuponVenta = value
- End Set
- End Property
- Public Property FechaLiquidacionVenta As Date
- Get
- Return _FechaLiquidacionVenta
- End Get
- Set(value As Date)
- _FechaLiquidacionVenta = value
- CalcularDiasAcumuladosVenta()
- CalcularDiasAlVencimientoVenta()
- CalcularYTMAlVencimientoVenta()
- CalcularDiasPlazoRO()
- End Set
- End Property
- Public Property FechaVencimientoVenta As Date
- Get
- Return _FechaVencimientoVenta
- End Get
- Set(value As Date)
- _FechaVencimientoVenta = value
- CalcularDiasAlVencimientoVenta()
- CalcularYTMAlVencimientoVenta()
- End Set
- End Property
- Public Property PorcentajeCuponVenta As Double
- Get
- Return _PorcentajeCuponVenta
- End Get
- Set(value As Double)
- _PorcentajeCuponVenta = value
- CalcularYTMAlVencimientoVenta()
- CalcularInteresAcumuladoVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- End Set
- End Property
- Public ReadOnly Property YTMAlVencimientoComisionVenta As Double
- Get
- Return _YTMAlVencimientoComisionVenta
- End Get
- End Property
- Public ReadOnly Property YTMAlVencimientoVenta As Double
- Get
- Return _YTMAlVencimientoVenta
- End Get
- 'Set(value As Double)
- ' _YTMAlVencimientoVenta = value
- 'End Set
- End Property
- Public Property PrecioAlVencimientoVenta As Double
- Get
- Return _PrecioAlVencimientoVenta
- End Get
- Set(value As Double)
- _PrecioAlVencimientoVenta = value
- CalcularYTMAlVencimientoVenta()
- End Set
- End Property
- Public Property PrecioVenta As Double
- Get
- Return _PrecioVenta
- End Get
- Set(value As Double)
- _PrecioVenta = value
- CalcularYTMAlVencimientoVenta()
- CalcularPrecioSucioVenta()
- CalcularValorTransadoVenta()
- End Set
- End Property
- Public Property DiasBaseVenta As Integer
- Get
- Return _DiasBaseVenta
- End Get
- Set(value As Integer)
- _DiasBaseVenta = value
- CalcularYTMAlVencimientoComisionVenta()
- CalcularDiasAcumuladosVenta()
- CalcularDiasAlVencimientoVenta()
- CalcularInteresAcumuladoVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- End Set
- End Property
- Public ReadOnly Property DiasAcumuladosVenta As Integer
- Get
- Return _DiasAcumuladosVenta
- End Get
- End Property
- Public ReadOnly Property DiasAlVencimientoVenta As Integer
- Get
- Return _DiasAlVencimientoVenta
- End Get
- End Property
- 'Public ReadOnly Property PorcentajeInteresAcumuladoVenta As Double
- ' Get
- ' Return _PorcentajeInteresAcumuladoVenta
- ' End Get
- 'End Property
- Public ReadOnly Property InteresAcumuladoVenta As Double
- Get
- Return _InteresAcumuladoVenta
- End Get
- End Property
- Public ReadOnly Property InteresAcumuladoPorcentajeVenta As Double
- Get
- Return _InteresAcumuladoPorcentajeVenta
- End Get
- End Property
- Public ReadOnly Property PrecioSucioVenta As Double
- Get
- Return _PrecioSucioVenta
- End Get
- End Property
- Public ReadOnly Property ValorTransadoVenta As Double
- Get
- Return _ValorTransadoVenta
- End Get
- End Property
- Public ReadOnly Property MontoARecibirVenta As Double
- Get
- Return _MontoARecibirVenta
- End Get
- End Property
- Public Property CostoDeTransferenciaVenta As Double
- Get
- Return _CostoDeTransferenciaVenta
- End Get
- Set(value As Double)
- _CostoDeTransferenciaVenta = value
- End Set
- End Property
- Public ReadOnly Property ValorNominalRO As Double
- Get
- Return _ValorNominalRO
- End Get
- End Property
- Public ReadOnly Property DiasPlazoRO As Integer
- Get
- Return _DiasPlazoRO
- End Get
- End Property
- Public ReadOnly Property PrecioCompraRO As Double
- Get
- Return _PrecioCompraRO
- End Get
- End Property
- Public ReadOnly Property PrecioVentaRO As Double
- Get
- Return _PrecioVentaRO
- End Get
- End Property
- Public ReadOnly Property GananciaPerdidaDeCapital As Double
- Get
- Return _GananciaPerdidaDeCapital
- End Get
- End Property
- Public ReadOnly Property IngresoPorInteres As Double
- Get
- Return _IngresoPorInteres
- End Get
- End Property
- Public ReadOnly Property CostosTotales As Double
- Get
- Return _CostosTotales
- End Get
- End Property
- Public ReadOnly Property GananciaPerdidaTotal As Double
- Get
- Return _GananciaPerdidaTotal
- End Get
- End Property
- Public ReadOnly Property RendimientoGananciaPerdida As Double
- Get
- Return _RendimientoGananciaPerdida
- End Get
- End Property
- Public ReadOnly Property RendimientoDeIntereses As Double
- Get
- Return _RendimientoDeIntereses
- End Get
- End Property
- Public ReadOnly Property RendimientoAntesImpuestos As Double
- Get
- Return _RendimientoAntesImpuestos
- End Get
- End Property
- Public ReadOnly Property RendimientoDespuesImpuestos As Double
- Get
- Return _RendimientoDespuesImpuestos
- End Get
- End Property
- Public Property PeriodicidadVenta As String
- Get
- Return _PeriodicidadVenta
- End Get
- Set(value As String)
- _PeriodicidadVenta = value
- CalcularYTMAlVencimientoVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- End Set
- End Property
- Public Sub New()
- _ValorNominalCompra = 0
- _UltimaFechaCuponCompra = Date.Now.Date
- _SiguienteFechaCuponCompra = Date.Now.Date
- _FechaLiquidacionCompra = Date.Now.Date
- _FechaVencimientoCompra = Date.Now.Date
- _ValorNominalVenta = 0
- _SiguienteFechaCuponVenta = Date.Now.Date
- _FechaLiquidacionVenta = Date.Now.Date
- _FechaVencimientoVenta = Date.Now.Date
- End Sub
- 'CALCULOS
- Private Sub CalcularYTMAlVencimientoComisionCompra()
- Dim valor As Double
- Try
- valor = _YTMAlVencimientoCompra - (_SumaImpuestosyComisionesCompra * _DiasBaseCompra / _DiasAlVencimientoCompra)
- Catch ex As Exception
- valor = 0
- End Try
- _YTMAlVencimientoComisionCompra = valor
- End Sub
- Private Sub CalcularDiasAcumuladosCompra()
- Dim valor As Integer
- valor = Utilidades.Days360(_UltimaFechaCuponCompra, _FechaLiquidacionCompra)
- _DiasAcumuladosCompra = valor
- CalcularInteresAcumuladoCompra()
- End Sub
- Private Sub CalcularDiasAlVencimientoCompra()
- Dim valor As Integer
- If _DiasBaseCompra = 360 Then
- valor = Utilidades.Days360(_FechaLiquidacionCompra, _FechaVencimientoCompra)
- Else
- valor = DateDiff(DateInterval.Day, _FechaLiquidacionCompra, _FechaVencimientoCompra)
- End If
- _DiasAlVencimientoCompra = valor
- CalcularYTMAlVencimientoComisionCompra()
- CalcularYTMAlVencimientoCompra()
- End Sub
- Private Sub CalcularInteresAcumuladoCompra()
- Dim valor As Double
- Try
- valor = _ValorNominalCompra * _PorcentajeCuponCompra * _DiasAcumuladosCompra / _DiasBaseCompra
- Catch ex As Exception
- valor = 0
- End Try
- _InteresAcumuladoCompra = valor
- 'CalcularDiasAcumuladosCompra()
- CalcularPorcentajeInteresAcumuladoCompra()
- CalcularMontoAPagarCompra()
- End Sub
- Private Sub CalcularPorcentajeInteresAcumuladoCompra()
- Dim valor As Double
- Dim vDiasPeriodo As Integer = Utilidades.DiasDeUnPeriodo(_PeriodicidadCompra)
- Try
- valor = _InteresAcumuladoCompra / _ValorNominalCompra * _DiasBaseCompra / vDiasPeriodo
- Catch ex As Exception
- valor = 0
- End Try
- _PorcentajeInteresAcumuladoCompra = valor
- CalcularPrecioSucioCompra()
- End Sub
- Private Sub CalcularPrecioSucioCompra()
- Dim valor As Double
- Try
- 'valor = _PrecioCompra * 0.01 + _PorcentajeInteresAcumuladoCompra
- valor = _PrecioCompra + _PorcentajeInteresAcumuladoCompra
- Catch ex As Exception
- valor = 0
- End Try
- _PrecioSucioCompra = valor
- End Sub
- Private Sub CalcularValorTransadoCompra()
- Dim valor As Double
- valor = (_PrecioCompra) * _ValorNominalCompra
- _ValorTransadoCompra = valor
- CalcularMontoAPagarCompra()
- CalcularGananciaPerdidaDeCapital()
- CalcularRendimientoGananciaPerdida()
- CalcularRendimientoDeIntereses()
- CalcularRendimientoDespuesImpuestos()
- End Sub
- Private Sub CalcularMontoAPagarCompra()
- Dim valor As Double
- Try
- valor = _ValorTransadoCompra + _SumaImpuestosyComisionesCompra + _InteresAcumuladoCompra + _CostoDeTransferenciaCompra
- Catch ex As Exception
- valor = 0
- End Try
- _MontoAPagarCompra = valor
- End Sub
- 'CALCULOS VENTA
- Private Sub CalcularUltimaFechaCuponVenta()
- Dim valor As Date
- Dim vDiasPeriodo As Integer = Utilidades.DiasDeUnPeriodo(_PeriodicidadVenta)
- Try
- _SiguienteFechaCuponCompra.AddDays(vDiasPeriodo + 1)
- valor = _SiguienteFechaCuponCompra
- Catch ex As Exception
- valor = Date.Now.Date
- End Try
- _UltimaFechaCuponVenta = valor
- CalcularSiguienteFechaCuponVenta()
- CalcularDiasAcumuladosVenta()
- End Sub
- Private Sub CalcularSiguienteFechaCuponVenta()
- Dim valor As Date
- Dim vDiasPeriodo As Integer = Utilidades.DiasDeUnPeriodo(_PeriodicidadVenta)
- valor = _UltimaFechaCuponVenta.AddDays(vDiasPeriodo + 1)
- _SiguienteFechaCuponVenta = valor
- End Sub
- Private Sub CalcularFechaLiquidacionVenta()
- Dim valor As Date
- valor = DateTime.Now.Date + DateTime.Now.AddDays(3)
- _FechaLiquidacionVenta = valor
- End Sub
- Private Sub CalcularYTMAlVencimientoComisionVenta()
- Dim valor As Double
- Try
- valor = _YTMAlVencimientoVenta - (_PorcentajeComisionCasaVenta * _DiasBaseVenta / _DiasAlVencimientoVenta) - (_PorcentajeComisionBolsaVenta * _DiasBaseVenta / _DiasAlVencimientoVenta)
- 'valor = valor * 100
- Catch ex As Exception
- valor = 0
- End Try
- _YTMAlVencimientoComisionVenta = valor
- End Sub
- Private Sub CalcularDiasAcumuladosVenta()
- Dim valor As Integer
- If _DiasBaseVenta = 360 Then
- valor = Utilidades.Days360(_UltimaFechaCuponVenta, _FechaLiquidacionVenta)
- Else
- valor = DateDiff(DateInterval.Day, _UltimaFechaCuponVenta, _FechaLiquidacionVenta)
- End If
- _DiasAcumuladosVenta = valor
- CalcularYTMAlVencimientoVenta()
- CalcularInteresAcumuladoVenta()
- CalcularInteresAcumuladoPorcentajeVenta()
- End Sub
- Private Sub CalcularDiasAlVencimientoVenta()
- Dim valor As Integer
- If _DiasBaseVenta = 360 Then
- valor = Utilidades.Days360(_FechaLiquidacionVenta, _FechaVencimientoVenta)
- Else
- valor = DateDiff(DateInterval.Day, _FechaLiquidacionVenta, _FechaVencimientoVenta)
- End If
- _DiasAlVencimientoVenta = valor
- CalcularYTMAlVencimientoVenta()
- CalcularYTMAlVencimientoComisionVenta()
- End Sub
- Private Sub CalcularInteresAcumuladoVenta()
- Dim valor As Double
- Try
- valor = _ValorNominalVenta * _PorcentajeCuponVenta * _DiasAcumuladosVenta / _DiasBaseVenta
- Catch ex As Exception
- valor = 0
- End Try
- _InteresAcumuladoVenta = valor
- CalcularInteresAcumuladoPorcentajeVenta()
- CalcularMontoARecibirVenta()
- End Sub
- Private Sub CalcularInteresAcumuladoPorcentajeVenta()
- Dim valor As Double
- Dim vDiasPeriodo As Integer = Utilidades.DiasDeUnPeriodo(_PeriodicidadVenta)
- Try
- valor = _InteresAcumuladoVenta / _ValorNominalVenta * _DiasBaseVenta / vDiasPeriodo
- valor = valor * 100
- Catch ex As Exception
- valor = 0
- End Try
- _InteresAcumuladoPorcentajeVenta = valor
- CalcularPrecioSucioVenta()
- End Sub
- Private Sub CalcularPrecioSucioVenta()
- Dim valor As Double
- Try
- valor = _PrecioVenta + _InteresAcumuladoPorcentajeVenta
- valor = valor
- Catch ex As Exception
- valor = 0
- End Try
- _PrecioSucioVenta = valor
- End Sub
- Private Sub CalcularValorTransadoVenta()
- Dim valor As Double
- Try
- valor = _PrecioVenta * _ValorNominalVenta
- Catch ex As Exception
- valor = 0
- End Try
- _ValorTransadoVenta = valor
- CalcularMontoARecibirVenta()
- CalcularGananciaPerdidaDeCapital()
- End Sub
- Private Sub CalcularMontoARecibirVenta()
- Dim valor As Double
- Try
- valor = _ValorTransadoVenta - _ComisionBolsaVenta - _ComisionCasaVenta + _InteresAcumuladoVenta
- Catch ex As Exception
- valor = 0
- End Try
- _MontoARecibirVenta = valor
- End Sub
- Private Sub CalcularDiasPlazoRO()
- Dim valor As Integer
- If _DiasBaseCompra = 360 Then
- valor = Utilidades.Days360(_FechaLiquidacionCompra, _FechaLiquidacionVenta)
- Else
- valor = DateDiff(DateInterval.Day, _FechaLiquidacionCompra, _FechaLiquidacionVenta)
- End If
- _DiasPlazoRO = valor
- CalcularRendimientoGananciaPerdida()
- CalcularRendimientoDeIntereses()
- CalcularRendimientoDespuesImpuestos()
- End Sub
- Private Sub CalcularGananciaPerdidaDeCapital()
- Dim valor As Double
- valor = _ValorTransadoVenta - _ValorTransadoCompra
- _GananciaPerdidaDeCapital = valor
- CalcularGananciaPerdidaTotal()
- CalcularRendimientoGananciaPerdida()
- End Sub
- Private Sub CalcularIngresoPorInteres()
- Dim valor As Double
- 'Dim vCuponesPagados As Double = 0 'FALTA VALOR
- 'Dim vInteresAcumulado As Double = GetInteresAcumuladoCompra()
- 'valor = vCuponesPagados + vInteresAcumulado
- valor = 0
- _IngresoPorInteres = valor
- CalcularGananciaPerdidaTotal()
- CalcularRendimientoDeIntereses()
- End Sub
- Private Sub CalcularGananciaPerdidaTotal()
- Dim valor As Double
- valor = _GananciaPerdidaDeCapital + _IngresoPorInteres
- _GananciaPerdidaTotal = valor
- CalcularRendimientoDespuesImpuestos()
- End Sub
- Private Sub CalcularRendimientoGananciaPerdida()
- Dim valor As Double
- Try
- valor = _GananciaPerdidaDeCapital / _ValorTransadoCompra * _DiasBaseCompra / _DiasPlazoRO
- 'valor = valor * 100
- Catch ex As Exception
- valor = 0
- End Try
- _RendimientoGananciaPerdida = valor
- End Sub
- Private Sub CalcularRendimientoDeIntereses()
- Dim valor As Double
- Try
- valor = _IngresoPorInteres / _ValorTransadoCompra * _DiasBaseCompra / _DiasPlazoRO
- 'valor = valor * 100
- Catch ex As Exception
- valor = 0
- End Try
- _RendimientoDeIntereses = valor
- End Sub
- Private Sub CalcularRendimientoDespuesImpuestos()
- Dim valor As Double
- Try
- valor = _GananciaPerdidaTotal / _ValorTransadoCompra * _DiasBaseCompra / _DiasPlazoRO
- valor = valor * 100
- Catch ex As Exception
- valor = 0
- End Try
- _RendimientoDespuesImpuestos = valor
- End Sub
- Private Sub CalcularSiguienteFechaCuponCompra()
- Dim valor As Date
- Dim vUltimaFechCupon As Date = _UltimaFechaCuponCompra
- Dim vPeriodicidad As String = _PeriodicidadCompra
- Dim vDiasPeriodo As Integer = Utilidades.DiasDeUnPeriodo(vPeriodicidad)
- valor = vUltimaFechCupon.AddDays(vDiasPeriodo + 1)
- _SiguienteFechaCuponCompra = valor
- End Sub
- Private Sub CalcularSumaImpuestosyComisionesCompra()
- _SumaImpuestosyComisionesCompra = 0
- End Sub
- 'Private Sub CalcularPorcentajeInteresAcumuladoVenta()
- ' Dim valor As Double
- ' Try
- ' valor = _ValorNominalVenta * _PorcentajeCuponVenta * _DiasAcumuladosVenta / _DiasBaseVenta
- ' Catch ex As Exception
- ' valor = 0
- ' End Try
- ' _PorcentajeInteresAcumuladoVenta = valor
- ' CalcularPrecioSucioVenta()
- 'End Sub
- Private Sub CalcularComisionBolsaVenta()
- _ComisionBolsaVenta = 0
- CalcularMontoARecibirVenta()
- End Sub
- Private Sub CalcularComisionCasaVenta()
- _ComisionCasaVenta = 0
- CalcularMontoARecibirVenta()
- End Sub
- Private Sub CalcularSumaImpuestosyComisiones()
- If Not Double.TryParse(_dtImpuestosYComisiones.Compute("SUM(MontoImp)", "TipoOper='C'").ToString, _SumaImpuestosyComisionesCompra) Then
- _SumaImpuestosyComisionesCompra = 0
- End If
- If Not Double.TryParse(_dtImpuestosYComisiones.Compute("SUM(MontoImp)", "TipoOper='V'").ToString, _SumaImpuestosYComisionesVenta) Then
- _SumaImpuestosYComisionesVenta = 0
- End If
- End Sub
- Private Sub CalcularSumasIngresos()
- If Not Double.TryParse(_dtIngresos.Compute("SUM(Ingreso)", "").ToString, _SumaIngresos) Then
- _SumaIngresos = 0
- End If
- If Not Double.TryParse(_dtIngresos.Compute("SUM(MontoImpuesto)", "").ToString, _SumaImpuestosIngresos) Then
- _SumaImpuestosIngresos = 0
- End If
- If Not Double.TryParse(_dtIngresos.Compute("SUM(Liquido)", "").ToString, _SumaliquidoIngresos) Then
- _SumaliquidoIngresos = 0
- End If
- End Sub
- Private Sub CalcularYTMAlVencimientoCompra()
- Dim vRedemption As Double = (_PrecioAlVencimientoCompra * 100) 'Amortizacion,Precio al vencimiento
- Dim vRate As Double = _PorcentajeCuponCompra 'Porcentaje de cupon, tasa
- Dim vFrecuency As Integer = 0 'For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.
- Dim vPar As Double = (_PrecioCompra * 100) 'Precio de Compra
- Dim vA As Integer = _DiasAcumuladosCompra 'Dias Acumulados
- Dim vE As Integer = Utilidades.DiasDeUnPeriodo(_PeriodicidadCompra) 'número de días en el período del cupón.
- Dim vDSR As Integer = _DiasAlVencimientoCompra 'número de días desde la fecha de liquidación hasta la fecha de amortización.
- 'If vA = 0 Then vA = 1
- If _PeriodicidadCompra = "A" Then vFrecuency = 1
- If _PeriodicidadCompra = "S" Then vFrecuency = 2
- If _PeriodicidadCompra = "T" Then vFrecuency = 4
- _YTMAlVencimientoCompra = (vRedemption / 100) + (vRate / vFrecuency)
- _YTMAlVencimientoCompra = _YTMAlVencimientoCompra - ((vPar / 100) + ((vA / vE) * (vRate / vFrecuency)))
- _YTMAlVencimientoCompra = _YTMAlVencimientoCompra / ((vPar / 100) + ((vA / vE) * (vRate / vFrecuency)))
- _YTMAlVencimientoCompra = _YTMAlVencimientoCompra * ((vFrecuency * vE) / vDSR)
- End Sub
- Public Function CalcularYTMAl(ByVal PrecioVencimiento As Double, ByVal PorcentajeCupon As Double, ByVal PrecioCompra As Double, ByVal DiasAcumulados As Integer, ByVal Periodicidad As String, ByVal DiasVencimiento As Integer)
- 'Dim vRedemption As Double = (PrecioVencimiento * 100) 'Amortizacion,Precio al vencimiento
- 'Dim vRate As Double = PorcentajeCupon 'Porcentaje de cupon, tasa
- 'Dim vFrecuency As Integer = 0 'For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.
- 'Dim vPar As Double = (PrecioCompra * 100) 'Precio de Compra
- 'Dim vA As Integer = DiasAcumulados 'Dias Acumulados
- 'Dim vE As Integer = Utilidades.DiasDeUnPeriodo(Periodicidad) 'número de días en el período del cupón.
- 'Dim vDSR As Integer = DiasVencimiento 'número de días desde la fecha de liquidación hasta la fecha de amortización.
- 'Dim Vencimiento
- 'If vA = 0 Then vA = 1
- Dim vFrecuency As Integer
- If Periodicidad = "A" Then vFrecuency = 1
- If Periodicidad = "S" Then vFrecuency = 2
- If Periodicidad = "T" Then vFrecuency = 4
- Dim vRedemption As Double = PrecioVencimiento 'Amortizacion,Precio al vencimiento
- Dim vRate As Double = PorcentajeCupon 'Porcentaje de cupon, tasa
- 'Dim vFrecuency As Integer = 'For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.
- Dim vPar As Double = PrecioCompra 'Precio de Compra
- Dim vA As Integer = DiasAcumulados 'Dias Acumulados
- Dim vE As Integer = Utilidades.DiasDeUnPeriodo(Periodicidad) 'número de días en el período del cupón.
- Dim vDSR As Integer = DiasVencimiento 'número de días desde la fecha de liquidación hasta la fecha de amortización.
- Dim Vencimiento
- 'If vA = 0 Then vA = 1
- Vencimiento = (vRedemption / 100) + (vRate / vFrecuency)
- Vencimiento = Vencimiento - ((vPar / 100) + ((vA / vE) * (vRate / vFrecuency)))
- Vencimiento = Vencimiento / ((vPar / 100) + ((vA / vE) * (vRate / vFrecuency)))
- Vencimiento = Vencimiento * ((vFrecuency * vE) / vDSR)
- 'Dim pr = (vRedemption / (1 + Vencimiento / vFrecuency) ^ (50 - 1 + (vDSR / vE))) + (100 * (vRate / vFrecuency)) / (1 + (Vencimiento / vFrecuency)) ^ (vDSR / vE) - (100 * (vRate / vFrecuency) * vA / vE)
- Return Vencimiento
- End Function
- Public Function CalcularYTMComision(ByVal YTMVen As Double, ByVal ComisionCasa As Double, ByVal DiasVencimiento As Integer, ByVal ComisionBolsa As Double, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
- Dim Valor As Double = 0.0
- If (DiasVencimiento <> 0) Then
- If (IndexBase = 0) Then
- Valor = YTMVen - ((ComisionCasa) * 360 / DiasVencimiento) - ((ComisionBolsa) * 360 / DiasVencimiento)
- 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 = ((ComisionCasa) * 366 / DiasPrimeraFecha) - ((ComisionBolsa) * 366 / DiasPrimeraFecha)
- PrOpc2 = ((ComisionCasa) * 365 / DiasSegundaFecha) - ((ComisionBolsa) * 365 / DiasSegundaFecha)
- Valor = YTMVen - PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = YTMVen - ((ComisionCasa) * 365 / DiasSegundaFecha) - ((ComisionBolsa) * 365 / DiasSegundaFecha)
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = YTMVen - ((ComisionCasa) * 366 / DiasPrimeraFecha) - ((ComisionBolsa) * 366 / DiasPrimeraFecha)
- 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 = ((ComisionCasa) * 366 / DiasPrimeraFecha) - ((ComisionBolsa) * 366 / DiasPrimeraFecha)
- PrOpc2 = ((ComisionCasa) * 365 / DiasSegundaFecha) - ((ComisionBolsa) * 365 / DiasSegundaFecha)
- Valor = YTMVen - PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = YTMVen - ((ComisionCasa) * 365 / DiasSegundaFecha) - ((ComisionBolsa) * 365 / DiasSegundaFecha)
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = YTMVen - ((ComisionCasa) * 366 / DiasPrimeraFecha) - ((ComisionBolsa) * 366 / DiasPrimeraFecha)
- 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 = ((ComisionCasa) * 360 / DiasPrimeraFecha) - ((ComisionBolsa) * 360 / DiasPrimeraFecha)
- PrOpc2 = ((ComisionCasa) * 360 / DiasSegundaFecha) - ((ComisionBolsa) * 360 / DiasSegundaFecha)
- Valor = YTMVen - PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = YTMVen - ((ComisionCasa) * 360 / DiasSegundaFecha) - ((ComisionBolsa) * 360 / DiasSegundaFecha)
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = YTMVen - ((ComisionCasa) * 360 / DiasPrimeraFecha) - ((ComisionBolsa) * 360 / DiasPrimeraFecha)
- Else
- Valor = 0
- End If
- Return Valor
- End If
- End If
- Return Valor
- End Function
- Private Sub CalcularYTMAlVencimientoVenta()
- Dim vRedemption As Double = (_PrecioAlVencimientoVenta * 100) 'Amortizacion,Precio al vencimiento
- Dim vRate As Double = _PorcentajeCuponVenta 'Porcentaje de cupon, tasa
- Dim vFrecuency As Integer = 0 'For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.
- Dim vPar As Double = (_PrecioVenta * 100) 'Precio de Compra
- Dim vA As Integer = _DiasAcumuladosVenta 'Dias Acumulados
- Dim vE As Integer = Utilidades.DiasDeUnPeriodo(_PeriodicidadVenta) 'número de días en el período del cupón.
- Dim vDSR As Integer = _DiasAlVencimientoVenta 'número de días desde la fecha de liquidación hasta la fecha de amortización.
- 'If vA = 0 Then vA = 1
- If _PeriodicidadVenta = "A" Then vFrecuency = 1
- If _PeriodicidadVenta = "S" Then vFrecuency = 2
- If _PeriodicidadVenta = "T" Then vFrecuency = 4
- _YTMAlVencimientoVenta = (vRedemption / 100) + (vRate / vFrecuency)
- _YTMAlVencimientoVenta = _YTMAlVencimientoVenta - ((vPar / 100) + ((vA / vE) * (vRate / vFrecuency)))
- _YTMAlVencimientoVenta = _YTMAlVencimientoVenta / ((vPar / 100) + ((vA / vE) * (vRate / vFrecuency)))
- _YTMAlVencimientoVenta = _YTMAlVencimientoVenta * ((vFrecuency * vE) / vDSR)
- End Sub
- End Class
|