Public Class FuturosCE
    Private _TipoOperacion As String
    Private _IdDelContrato As String
    Private _CantidadContratos As Integer
    Private _Unidades As Integer
    Private _ValorUnitario As Double
    Private _ValorTransado As Double
    Private _ComisionBroker As Double
    Private _ValorDeLaOperacion As Double
    Private _FechaOperacion As Date
    Private _FechaLiquidacion As Date
    Private _FechaVencimiento As Date
    Private _ValorTransadoCompra As Double
    Private _Ganancia As Double
    Private _Rendimiento As Double



    Public Property CantidadContratos As Integer
        Get
            Return _CantidadContratos
        End Get
        Set(value As Integer)
            _CantidadContratos = value
            CalcularValorTransado()
            CalcularValorDeLaOperacion()
        End Set
    End Property
    Public Property Unidades As Integer
        Get
            Return _Unidades
        End Get
        Set(value As Integer)
            _Unidades = value
            CalcularValorTransado()
        End Set
    End Property
    Public Property ValorUnitario As Double
        Get
            Return _ValorUnitario
        End Get
        Set(value As Double)
            _ValorUnitario = value
            CalcularValorTransado()
        End Set
    End Property
    Public Property ValorTransado As Double
        Get
            Return _ValorTransado
        End Get
        Set(value As Double)
            _ValorTransado = value
            CalcularValorDeLaOperacion()
        End Set
    End Property
    Public Property ComisionBroker As Double
        Get
            Return _ComisionBroker
        End Get
        Set(value As Double)
            _ComisionBroker = value
            CalcularValorDeLaOperacion()
        End Set
    End Property
    Public Property ValorDeLaOperacion As Double
        Get
            Return _ValorDeLaOperacion
        End Get
        Set(value As Double)
            _ValorDeLaOperacion = value
            CalcularGanancia()
        End Set
    End Property

    Public Property ValorTransadoCompra As Double
        Get
            Return _ValorTransadoCompra
        End Get
        Set(value As Double)
            _ValorTransadoCompra = value
            CalcularGanancia()
        End Set
    End Property
    Public Property Ganancia As Double
        Get
            Return _Ganancia
        End Get
        Set(value As Double)
            _Ganancia = value
        End Set
    End Property

    Private Sub CalcularValorTransado()
        Dim valor As Double
        Dim vCantidad As Integer = CantidadContratos
        Dim vUnidades As Integer = Unidades
        Dim vValorUnitario As Double = ValorUnitario

        Try
            valor = vCantidad * vUnidades * vValorUnitario
        Catch ex As Exception
            valor = 0
        End Try
        ValorTransado = valor
    End Sub

    Private Sub CalcularValorDeLaOperacion()
        Dim valor As Double
        Dim vCantidad As Integer = CantidadContratos
        Dim vValorTransado As Double = ValorTransado
        Dim vComisionBroker As Double = ComisionBroker

        Try
            valor = vCantidad + vValorTransado + vComisionBroker
        Catch ex As Exception
            valor = 0
        End Try
        ValorDeLaOperacion = valor
    End Sub
    Private Sub CalcularGanancia()
        Dim valor As Double
        Dim vValorTransadoCompra As Double = ValorTransadoCompra
        Dim vValorDeOperacion As Double = ValorDeLaOperacion
        Try
            valor = vValorTransadoCompra - vValorDeOperacion
        Catch ex As Exception
            valor = 0
        End Try
        Ganancia = valor
    End Sub


End Class
