def amount(self, type=eMoneyCurrency.Product): money = Money( self.mem, self.shares * self.price * self.investment.product.real_leveraged_multiplier(), self.investment.product.currency) if type == eMoneyCurrency.Product: return money elif type == eMoneyCurrency.Account: dt = dtaware_day_end_from_date(self.date, self.mem.localzone_name) return money.convert(self.investment.account.currency, dt) elif type == eMoneyCurrency.User: dt = dtaware_day_end_from_date(self.date, self.mem.localzone_name) return money.convert(self.investment.account.currency, dt).convert(self.mem.localcurrency, dt)
def update_tables(self): #Actualiza el indice de referencia porque ha cambiado self.investment.op_actual.get_valor_benchmark(self.mem.data.benchmark) self.on_chkOperaciones_stateChanged(self.chkOperaciones.checkState()) self.chkOperaciones.setEnabled(True) self.investment.op_actual.myqtablewidget( self.mqtwInvestmentCurrent, self.investment.product.result.basic.last, type=1) self.investment.op_historica.myqtablewidget( self.mqtwInvestmentHistorical, type=1) if self.investment.product.currency == self.investment.account.currency: #Multidivisa self.grpCurrentAccountCurrency.hide() self.grpHistoricalAccountCurrency.hide() else: m = Money(self.mem, 1, self.investment.account.currency) self.grpCurrentAccountCurrency.setTitle( self.tr("Current status in account currency ( {} = {} at {} )" ).format( m.string(6), m.convert(self.investment.product.currency, self.mem.localzone.now()).string(6), m.conversionDatetime( self.investment.product.currency, self.mem.localzone.now()))) self.investment.op_actual.myqtablewidget( self.mqtwInvestmentCurrentAccountCurrency, self.investment.product.result.basic.last, type=2) self.investment.op_historica.myqtablewidget( self.mqtwInvestmentHistoricalAccountCurrency, type=2) self.lblAge.setText( self.tr("Current operations average age: {0}".format( days2string(self.investment.op_actual.average_age())))) if self.investment != None: #We are adding a new investment self.on_chkHistoricalDividends_stateChanged( self.chkHistoricalDividends.checkState()) self.chkHistoricalDividends.setEnabled(True)