| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973 |
- 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 Ingresos As DataTable
- Get
- Return _dtIngresos
- End Get
- Set(value As DataTable)
- _dtIngresos = value
- End Set
- End Property
- Private _PeriodicidadCompra 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 _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 _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 ImpuestosYComisiones As DataTable
- Get
- Return _dtImpuestosYComisiones
- End Get
- Set(value As DataTable)
- _dtImpuestosYComisiones = value
- CalcularSumaImpuestosyComisiones()
- 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 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
- '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
- 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 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 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
- 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 CalcularYTMAlVencimientoComisionVenta()
- Dim valor As Double
- Try
- valor = _YTMAlVencimientoVenta - (_PorcentajeComisionCasaVenta * _DiasBaseVenta / _DiasAlVencimientoVenta) - (_PorcentajeComisionBolsaVenta * _DiasBaseVenta / _DiasAlVencimientoVenta)
- 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 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
- 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
- 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 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 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 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
|