示例#1
0
 def append_from_default(self):
     with open(self.filename) as csv_file:
         csv_reader = reader(csv_file, delimiter=',')
         line_count = 0
         for row in csv_reader:
             if line_count >0:#Ignores headers line
                 products=self.mem.data.products.find_all_by_ticker(row[1], eTickerPosition.InvestingCom)
                 print(row[1], len(products))
                 if len(products)==0:
                     print(_(f"Product with InvestingCom ticker {row[1]} wasn't found"))
                 for product in products:
                     if row[7].find(":")==-1:#It's a date
                         try:
                             quote=Quote(self.mem)
                             quote.product=product
                             date_=string2date(row[7], "DD/MM")
                             quote.datetime=dtaware(date_,quote.product.stockmarket.closes,self.mem.localzone_name)#Without 4 microseconds becaouse is not a ohcl
                             quote.quote=string2decimal(row[2])
                             self.append(quote)
                         except:
                             debug("Error parsing "+ str(row))
                     else: #It's an hour
                         try:
                             quote=Quote(self.mem)
                             quote.product=product
                             time_=string2time(row[7], "HH:MM:SS")
                             quote.datetime=dtaware(date.today(), time_, self.mem.localzone_name)
                             quote.quote=string2decimal(row[3])
                             self.append(quote)
                         except:
                             debug("Error parsing "+ str(row))
             line_count += 1
     print("Added {} quotes from {} CSV lines".format(self.length(), line_count))
示例#2
0
    def generate_4_quotes(self):
        from xulpymoney.objects.quote import Quote
        quotes=[]
        datestart=dtaware(self.date,self.product.stockmarket.starts,self.product.stockmarket.zone.name)
        dateends=dtaware(self.date,self.product.stockmarket.closes,self.product.stockmarket.zone.name)
        datetimefirst=datestart-timedelta(seconds=1)
        datetimelow=(datestart+(dateends-datestart)*1/3)
        datetimehigh=(datestart+(dateends-datestart)*2/3)
        datetimelast=dateends+timedelta(microseconds=4)

        quotes.append(Quote(self.mem).init__create(self.product,datetimelast, Decimal(self.close)))#closes
        quotes.append(Quote(self.mem).init__create(self.product,datetimelow, Decimal(self.low)))#low
        quotes.append(Quote(self.mem).init__create(self.product,datetimehigh, Decimal(self.high)))#high
        quotes.append(Quote(self.mem).init__create(self.product, datetimefirst, Decimal(self.open)))#open        
        return quotes
示例#3
0
 def myqtablewidget(self, wdg):
     wdg.table.setColumnCount(6)
     wdg.table.setHorizontalHeaderItem(0, qcenter(self.tr("Year")))
     wdg.table.setHorizontalHeaderItem(1, qcenter(self.tr("Estimation")))
     wdg.table.setHorizontalHeaderItem(2, qcenter(self.tr("PER")))
     wdg.table.setHorizontalHeaderItem(3,
                                       qcenter(self.tr("Estimation date")))
     wdg.table.setHorizontalHeaderItem(4, qcenter(self.tr("Source")))
     wdg.table.setHorizontalHeaderItem(5, qcenter(self.tr("Manual")))
     self.sort()
     wdg.applySettings()
     wdg.table.clearContents()
     wdg.table.setRowCount(len(self.arr))
     for i, e in enumerate(self.arr):
         wdg.table.setItem(i, 0, qcenter(str(e.year)))
         wdg.table.setItem(
             i, 1,
             self.product.money(e.estimation).qtablewidgetitem())
         wdg.table.setItem(
             i, 2,
             qnumber(
                 e.PER(
                     Quote(self.mem).init__from_query(
                         self.product,
                         dtaware_day_end_from_date(
                             date(e.year, 12, 31),
                             self.product.stockmarket.zone.name)))))
         wdg.table.setItem(i, 3, qdate(e.date_estimation))
         wdg.table.setItem(i, 4, qleft(e.source))
         wdg.table.setCellWidget(i, 5, wdgBool(e.manual))
     wdg.table.setCurrentCell(len(self.arr) - 1, 0)
     wdg.table.setFocus()
示例#4
0
    def on_actionQuoteImport_triggered(self):
        filename = QFileDialog.getOpenFileName(self, "", "",
                                               "LibreOffice Calc (*.ods)")[0]
        got = 0
        if filename != "":
            set = QuoteManager(self.mem)
            ods = ODS_Read(filename)

            for number in range(2, ods.rowNumber(0)):
                date = ods.getCellValue(0, "A" + str(number))
                value = ods.getCellValue(0, "B" + str(number))
                print(date, value)
                try:
                    set.append(
                        Quote(self.mem).init__create(
                            self.product,
                            dtaware(date, self.product.stockmarket.closes,
                                    self.product.stockmarket.zone.name),
                            value))
                    got = got + 1
                except:
                    debug("I couldn't import {} and {} as a quote".format(
                        date, value))
            print("Added {} DPS from {} ODS rows".format(
                got, ods.rowNumber(0)))
            set.save()
            self.mem.con.commit()
            self.product.needStatus(2, downgrade_to=0)
            self.update_due_to_quotes_change()
示例#5
0
    def shares(self):
        resultado = Decimal(0)

        if self.radDes.isChecked():  #DESINVERSION
            perdida = Money(self.mem, self.txtSimulacion.decimal(),
                            self.investment.product.currency
                            )  #Va disminuyendo con las distintas operaciones
            q = Quote(self.mem).init__create(
                self.investment.product,
                datetime.now(timezone(self.mem.localzone_name)),
                self.txtValorAccion.decimal())
            for rec in self.investment.op_actual.arr:
                pendiente = rec.pendiente(q)
                if (perdida + pendiente).isZero():
                    resultado = resultado + rec.shares
                    break
                elif (perdida + pendiente).isGTZero():
                    resultado = resultado + rec.shares
                    perdida = perdida + pendiente
                elif (perdida + pendiente).isLTZero():
                    # Si de tantas shares queda pendiente "pendiente"
                    # X                                queda la perdida
                    shares = abs(
                        int(perdida.amount * rec.shares / pendiente.amount))
                    resultado = resultado + Decimal(
                        shares
                    )  #Se resta porque se debe calcular antes de quitarse el pendiente
                    break
        else:  #REINVERSION
            resultado = Decimal(
                int(self.txtSimulacion.decimal() /
                    self.txtValorAccion.decimal()))
        return resultado
示例#6
0
 def setquotesbasic(self):
     from xulpymoney.objects.quote import Quote, QuoteBasicManager
     last=None
     penultimate=None
     lastyear=None
     if self.length()==0:
         return QuoteBasicManager(self.mem, self.product).init__create(Quote(self.mem).none(self.product), Quote(self.mem).none(self.product),  Quote(self.mem).none(self.product))
     ohcl=self.arr[self.length()-1]#last
     last=Quote(self.mem).init__create(self.product, dtaware(ohcl.date, self.product.stockmarket.closes,  self.product.stockmarket.zone.name), ohcl.close)
     ohcl=self.find(ohcl.date-timedelta(days=1))#penultimate
     if ohcl!=None:
         penultimate=Quote(self.mem).init__create(self.product, dtaware(ohcl.date, self.product.stockmarket.closes,  self.product.stockmarket.zone.name), ohcl.close)
     ohcl=self.find(date(date.today().year-1, 12, 31))#lastyear
     if ohcl!=None:
         lastyear=Quote(self.mem).init__create(self.product, dtaware(ohcl.date, self.product.stockmarket.closes,  self.product.stockmarket.zone.name), ohcl.close)        
     return QuoteBasicManager(self.mem, self.product).init__create(last, penultimate, lastyear)
示例#7
0
    def __calcular(self):
        #Setting self.investmentsoperations variable
        if self.chkPonderanAll.checkState()==Qt.Checked:#Results are in self.mem.localcurrency
            self.investmentsoperations=self.mem.data.investments_active().Investment_merging_current_operations_with_same_product(self.investment.product).op_actual
            self.investmentsoperations.myqtablewidget(self.mqtw)
        else:#Results in account currency
            self.investmentsoperations=InvestmentOperationCurrentHomogeneusManager(self.mem, self.investment)

            if self.chkGainsTime.checkState()==Qt.Checked:
                self.investmentsoperations=self.investment.op_actual.ObjectManager_copy_until_datetime(self.mem.localzone.now()-datetime.timedelta(days=365))
            else:
                self.investmentsoperations=self.investment.op_actual.ObjectManager_copy_until_datetime(self.mem.localzone.now())
            self.investmentsoperations.myqtablewidget(self.mqtw, self.investment.product.result.basic.last,  eMoneyCurrency.Account)
        sumacciones=self.investmentsoperations.shares()
        
        #Calculations
        if sumacciones==Decimal(0):
            self.puntoventa=Money(self.mem, 0, self.investment.account.currency)
        else:
            if self.radTPC.isChecked()==True:
                percentage=Percentage(self.spnGainsPercentage.value(), 100)
                self.puntoventa=self.investmentsoperations.selling_price_to_gain_percentage_of_invested(percentage, eMoneyCurrency.Account)
            elif self.radPrice.isChecked()==True:
                if self.txtPrice.isValid():#Si hay un number bien
                    self.puntoventa=Money(self.mem,  self.txtPrice.decimal(),  self.investment.product.currency)
                    self.cmd.setEnabled(True)
                else:
                    self.puntoventa=Money(self.mem, 0, self.investment.product.currency)
                    self.cmd.setEnabled(False)
            elif self.radGain.isChecked()==True:
                if self.txtGanancia.isValid():#Si hay un number bien
                    self.puntoventa=self.investmentsoperations.selling_price_to_gain_money(Money(self.mem, self.txtGanancia.decimal(), self.investment.product.currency))
                    self.cmd.setEnabled(True)
                else:
                    self.puntoventa=Money(self.mem, 0, self.investment.account.currency)
                    self.cmd.setEnabled(False)

        quote=Quote(self.mem).init__create(self.investment.product, self.mem.localzone.now(), self.puntoventa.amount)
        self.tab.setTabText(1, self.tr("Selling point: {0}".format(self.puntoventa)))
        self.tab.setTabText(0, self.tr("Current state: {0}".format(quote.money())))
        self.investmentsoperations.myqtablewidget(self.mqtwSP, quote, eMoneyCurrency.Account) 
        
        if self.chkPonderanAll.checkState()==Qt.Checked:
            self.cmd.setText(self.tr("Set selling price to all investments  of {0} to gain {1}").format(self.puntoventa, self.investmentsoperations.pendiente(quote, eMoneyCurrency.Account)))
        else:
            self.cmd.setText(self.tr("Set {0} shares selling price to {1} to gain {2}").format(sumacciones, self.puntoventa, self.investmentsoperations.pendiente(quote, eMoneyCurrency.Account)))
示例#8
0
    def append_from_portfolio(self):
        with open(self.filename) as csv_file:
            csv_reader = reader(csv_file, delimiter=',')
            line_count = 0
            for row in csv_reader:
                if line_count > 0:  #Ignores headers line
                    for product in self.mem.data.products.find_all_by_ticker(
                            row[1], eTickerPosition.InvestingCom):
                        ## Casos especiales por ticker repetido se compara con más información.
                        if row[1] == "DE30" and row[2] == "DE":
                            product = self.mem.data.products.find_by_id(
                                78094)  #DAX 30
                            print("DAX30")
                        elif row[1] == "DE30" and row[2] == "Eurex":
                            product = self.mem.data.products.find_by_id(
                                81752)  #CFD DAX 30
                            print("CDFDAX")

                        if row[16].find(":") == -1:  #It's a date
                            try:
                                quote = Quote(self.mem)
                                quote.product = product
                                date_ = string2date(row[16], "DD/MM")
                                quote.datetime = dtaware(
                                    date_, quote.product.stockmarket.closes,
                                    quote.product.stockmarket.zone.name
                                )  #Without 4 microseconds becaouse is not a ohcl
                                quote.quote = string2decimal(row[3])
                                self.append(quote)
                            except:
                                debug("Error parsing " + str(row))
                        else:  #It's an hour
                            try:
                                quote = Quote(self.mem)
                                quote.product = product
                                quote.datetime = string2dtaware(
                                    row[16], "%H:%M:%S",
                                    self.mem.localzone_name)
                                quote.quote = string2decimal(row[3])
                                self.append(quote)
                            except:
                                debug("Error parsing " + str(row))
                line_count += 1
        print("Added {} quotes from {} CSV lines".format(
            self.length(), line_count))
示例#9
0
 def on_buttonbox_accepted(self):
     if not self.txtQuote.isValid():
         qmessagebox(self.tr("Incorrect data. Try again."))
         return
     if self.quote == None:  #insert
         if self.chkCanBePurged.checkState(
         ) == Qt.Unchecked:  #No puede ser purgado
             self.wdgDT.teMicroseconds.setValue(5)
         self.quote = Quote(self.mem).init__create(self.product,
                                                   self.wdgDT.datetime(),
                                                   self.txtQuote.decimal())
         self.quote.save()
     else:  #update
         self.quote.quote = self.txtQuote.decimal()
         self.quote.save()
     self.product.needStatus(1, downgrade_to=0)
     self.mem.con.commit()
     self.accept()
示例#10
0
 def on_mqtwInvestments_cellDoubleClicked(self, row, column):
     if column == 8:  #TPC Venta
         qmessagebox(
             self.tr("Shares number: {0}").format(
                 self.mqtwInvestments.selected.shares()) + "\n" +
             self.tr("Purchase price average: {0}").format(
                 self.mqtwInvestments.selected.op_actual.average_price(
                 ).local()) + "\n" + self.tr("Selling point: {}").format(
                     self.mqtwInvestments.selected.selling_price) + "\n" +
             self.tr("Selling all shares you get {}").format(
                 self.mqtwInvestments.selected.op_actual.pendiente(
                     Quote(self.mem).init__create(
                         self.mqtwInvestments.selected.product,
                         self.mem.localzone.now(), self.mqtwInvestments.
                         selected.selling_price)).local()))
     else:
         self.on_actionInvestmentReport_triggered()
示例#11
0
 def show_investments_status(self, date):
     """Shows investments status in a date"""
     datet = dtaware(date, time(22, 00), self.mem.localzone_name)
     sumbalance = 0
     print("{0:<40s} {1:>15s} {2:>15s} {3:>15s}".format(
         "Investments at {0}".format(date), "Shares", "Price", "Balance"))
     for inv in self.mem.data.investments.arr:
         balance = inv.balance(date)
         sumbalance = sumbalance + balance
         shares = inv.shares(date)
         price = Quote(self.mem).init__from_query(inv.product, datet)
         if shares != 0:
             print("{0:<40s} {1:>15f} {2:>15s} {3:>15s}".format(
                 inv.name, shares, self.mem.localmoney(price.quote),
                 self.mem.localmoney(balance)))
     print("{0:>40s} {1:>15s} {2:>15s} {3:>15s}".format(
         "Total balance at {0}".format(date), "", "",
         self.mem.localmoney(sumbalance)))
示例#12
0
 def run(self):
     self.__generateCommandsFile()
     quotes = QuoteManager(self.mem)
     system("xulpymoney_run_client")
     cr = open("{}/clients_result.txt".format(self.mem.dir_tmp), "r")
     for line in cr.readlines():
         if line.find("OHCL") != -1:
             ohcl = OHCLDaily(self.mem).init__from_client_string(line[:-1])
             if ohcl != None:
                 for quote in ohcl.generate_4_quotes():
                     if quote != None:
                         quotes.append(quote)
         if line.find("PRICE") != -1:
             quote = Quote(self.mem).init__from_client_string(line[:-1])
             if quote != None:
                 quotes.append(quote)
     cr.close()
     self.commands = []
     return quotes
示例#13
0
    def load_information(self):
        def row_mqtwTPV(quote, row):
            if quote == None:
                return
            self.tblTPC.setItem(
                row, 0, qdatetime(quote.datetime, self.mem.localzone_name))
            self.tblTPC.setItem(
                row, 1,
                self.product.money(quote.quote).qtablewidgetitem(
                    self.product.decimals))

            try:
                tpc = Percentage(
                    self.product.result.basic.last.quote - quote.quote,
                    quote.quote)
                days = (datetime.now(timezone(self.mem.localzone_name)) -
                        quote.datetime).days + 1
                self.tblTPC.setItem(row, 2, tpc.qtablewidgetitem())
                self.tblTPC.setItem(row, 3,
                                    (tpc * 365 / days).qtablewidgetitem())
                if self.investment:
                    self.grpHistoricos.setTitle(
                        self.
                        tr('Report of historic prices. You have {} shares valued at {}.'
                           ).format(self.investment.shares(),
                                    self.investment.balance()))
                    self.tblTPC.setItem(
                        row, 4,
                        self.product.money(
                            self.investment.shares() *
                            (self.product.result.basic.last.quote -
                             quote.quote)).qtablewidgetitem())
            except:
                self.tblTPC.setItem(row, 2, Percentage().qtablewidgetitem())
                self.tblTPC.setItem(row, 3, Percentage().qtablewidgetitem())
                self.tblTPC.setItem(row, 3, qcurrency(None))

        # ---------------------------------
        if len(self.product.result.ohclDaily.arr) != 0:
            now = self.mem.localzone.now()
            penultimate = self.product.result.basic.penultimate
            iniciosemana = Quote(self.mem).init__from_query(
                self.product,
                dt_day_end(now - timedelta(days=date.today().weekday() + 1)))
            iniciomes = Quote(self.mem).init__from_query(
                self.product,
                dtaware(date(now.year, now.month, 1), time(0, 0),
                        self.product.stockmarket.zone.name))
            inicioano = Quote(self.mem).init__from_query(
                self.product,
                dtaware(date(now.year, 1, 1), time(0, 0),
                        self.product.stockmarket.zone.name))
            docemeses = Quote(self.mem).init__from_query(
                self.product, dt_day_end(now - timedelta(days=365)))
            unmes = Quote(self.mem).init__from_query(
                self.product, dt_day_end(now - timedelta(days=30)))
            unasemana = Quote(self.mem).init__from_query(
                self.product, dt_day_end(now - timedelta(days=7)))

            self.tblTPC.setItem(
                0, 0,
                qdatetime(self.product.result.basic.last.datetime,
                          self.mem.localzone_name))
            self.tblTPC.setItem(
                0, 1,
                self.product.money(
                    self.product.result.basic.last.quote).qtablewidgetitem(6))

            row_mqtwTPV(penultimate, 2)
            row_mqtwTPV(iniciosemana, 3)  ## Para que sea el domingo
            row_mqtwTPV(iniciomes, 4)
            row_mqtwTPV(inicioano, 5)
            row_mqtwTPV(unasemana, 7)
            row_mqtwTPV(unmes, 8)
            row_mqtwTPV(docemeses, 9)
示例#14
0
class frmQuotesIBM(QDialog, Ui_frmQuotesIBM):
    def __init__(self, mem, product, quote=None, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.product = product
        self.mem = mem
        self.lblInvestment.setText("{0} ({1})".format(self.product.name,
                                                      self.product.id))
        self.quote = quote

        if quote == None:  #Insert
            if self.product.type.id in (eProductType.Fund,
                                        eProductType.PensionPlan):
                self.chkNone.setCheckState(Qt.Checked)
            else:
                self.wdgDT.setLocalzone(self.mem.localzone_name)
                if self.product.type.id in (
                        eProductType.CFD, eProductType.Future
                ) and self.mem.localzone.now(
                ) >= self.product.stockmarket.dtaware_today_closes_futures():
                    self.wdgDT.set(
                        self.product.stockmarket.dtaware_today_closes_futures(
                        ), self.mem.localzone_name)
                elif self.product.type.id not in (
                        eProductType.CFD,
                        eProductType.Future) and self.mem.localzone.now(
                        ) >= self.product.stockmarket.dtaware_today_closes(
                        ):  #Si ya ha cerrado la bolsa
                    self.wdgDT.set(
                        self.product.stockmarket.dtaware_today_closes(),
                        self.mem.localzone_name)
                else:
                    self.wdgDT.set()
        else:  #Update
            self.wdgDT.set(quote.datetime, self.mem.localzone_name)
            if self.quote.datetime.microsecond != 5:
                self.chkCanBePurged.setCheckState(Qt.Unchecked)
            self.wdgDT.setEnabled(False)
            self.chkNone.setEnabled(False)

    def on_chkNone_stateChanged(self, state):
        if state == Qt.Checked:
            self.wdgDT.set(
                dtaware(self.wdgDT.date(), self.product.stockmarket.closes,
                        self.product.stockmarket.zone.name),
                self.product.stockmarket.zone.name)
            self.wdgDT.teTime.setEnabled(False)
            self.wdgDT.cmbZone.setEnabled(False)
            self.wdgDT.cmdNow.setEnabled(False)
            self.wdgDT.teMicroseconds.setEnabled(False)
        else:
            self.wdgDT.teTime.setEnabled(True)
            self.wdgDT.cmbZone.setEnabled(True)
            self.wdgDT.cmdNow.setEnabled(True)
            self.wdgDT.teMicroseconds.setEnabled(True)

    @pyqtSlot()
    def on_buttonbox_accepted(self):
        if not self.txtQuote.isValid():
            qmessagebox(self.tr("Incorrect data. Try again."))
            return
        if self.quote == None:  #insert
            if self.chkCanBePurged.checkState(
            ) == Qt.Unchecked:  #No puede ser purgado
                self.wdgDT.teMicroseconds.setValue(5)
            self.quote = Quote(self.mem).init__create(self.product,
                                                      self.wdgDT.datetime(),
                                                      self.txtQuote.decimal())
            self.quote.save()
        else:  #update
            self.quote.quote = self.txtQuote.decimal()
            self.quote.save()
        self.product.needStatus(1, downgrade_to=0)
        self.mem.con.commit()
        self.accept()

    @pyqtSlot()
    def on_buttonbox_rejected(self):
        self.reject()  #No haría falta pero para recordar que hay buttonbox
示例#15
0
    def cmbPrices_reload(self):
        if self.cmbPrices.currentIndex() >= 0:
            index = self.cmbPrices.currentIndex()
        else:
            index = 10

        #quotes
        quote_current = self.investment.product.result.basic.last
        quote_simulation = Quote(self.mem).init__create(
            self.investment.product, datetime.now(),
            self.txtValorAccion.decimal())
        moneybefore_0 = self.investment.op_actual.average_price()
        quotebefore_0 = Quote(self.mem).init__create(self.investment.product,
                                                     datetime.now(),
                                                     moneybefore_0.amount)
        moneybefore_2_5 = self.investment.op_actual.average_price_after_a_gains_percentage(
            Percentage(2.5, 100))
        quotebefore_2_5 = Quote(self.mem).init__create(self.investment.product,
                                                       datetime.now(),
                                                       moneybefore_2_5.amount)
        moneybefore_5 = self.investment.op_actual.average_price_after_a_gains_percentage(
            Percentage(5, 100))
        quotebefore_5 = Quote(self.mem).init__create(self.investment.product,
                                                     datetime.now(),
                                                     moneybefore_5.amount)
        moneybefore_7_5 = self.investment.op_actual.average_price_after_a_gains_percentage(
            Percentage(7.5, 100))
        quotebefore_7_5 = Quote(self.mem).init__create(self.investment.product,
                                                       datetime.now(),
                                                       moneybefore_7_5.amount)
        moneybefore_10 = self.investment.op_actual.average_price_after_a_gains_percentage(
            Percentage(10, 100))
        quotebefore_10 = Quote(self.mem).init__create(self.investment.product,
                                                      datetime.now(),
                                                      moneybefore_10.amount)
        moneybefore_15 = self.investment.op_actual.average_price_after_a_gains_percentage(
            Percentage(15, 100))
        quotebefore_15 = Quote(self.mem).init__create(self.investment.product,
                                                      datetime.now(),
                                                      moneybefore_15.amount)

        moneyafter_0 = self.investment_simulated.op_actual.average_price()
        quoteafter_0 = Quote(self.mem).init__create(self.investment.product,
                                                    datetime.now(),
                                                    moneyafter_0.amount)
        moneyafter_2_5 = self.investment_simulated.op_actual.average_price_after_a_gains_percentage(
            Percentage(2.5, 100))
        quoteafter_2_5 = Quote(self.mem).init__create(self.investment.product,
                                                      datetime.now(),
                                                      moneyafter_2_5.amount)
        moneyafter_5 = self.investment_simulated.op_actual.average_price_after_a_gains_percentage(
            Percentage(5, 100))
        quoteafter_5 = Quote(self.mem).init__create(self.investment.product,
                                                    datetime.now(),
                                                    moneyafter_5.amount)
        moneyafter_7_5 = self.investment_simulated.op_actual.average_price_after_a_gains_percentage(
            Percentage(7.5, 100))
        quoteafter_7_5 = Quote(self.mem).init__create(self.investment.product,
                                                      datetime.now(),
                                                      moneyafter_7_5.amount)
        moneyafter_10 = self.investment_simulated.op_actual.average_price_after_a_gains_percentage(
            Percentage(10, 100))
        quoteafter_10 = Quote(self.mem).init__create(self.investment.product,
                                                     datetime.now(),
                                                     moneyafter_10.amount)
        moneyafter_15 = self.investment_simulated.op_actual.average_price_after_a_gains_percentage(
            Percentage(15, 100))
        quoteafter_15 = Quote(self.mem).init__create(self.investment.product,
                                                     datetime.now(),
                                                     moneyafter_15.amount)

        #Combobox update
        self.cmbPrices.blockSignals(True)
        self.cmbPrices.clear()
        self.cmbPrices.addItem(
            self.tr("Before simulation: current price ({})").format(
                quote_current.money()))
        self.cmbPrices.addItem(
            self.tr("Before simulation: simulation price ({})").format(
                quote_simulation.money()))
        self.cmbPrices.addItem(
            self.tr("Before simulation: selling price to gain 0 % ({})").
            format(moneybefore_0))
        self.cmbPrices.addItem(
            self.tr("Before simulation: selling price to gain 2.5 % ({})").
            format(moneybefore_2_5))
        self.cmbPrices.addItem(
            self.tr("Before simulation: selling price to gain 5.0 % ({})").
            format(moneybefore_5))
        self.cmbPrices.addItem(
            self.tr("Before simulation: selling price to gain 7.5 % ({})").
            format(moneybefore_7_5))
        self.cmbPrices.addItem(
            self.tr("Before simulation: selling price to gain 10.0 % ({})").
            format(moneybefore_10))
        self.cmbPrices.addItem(
            self.tr("Before simulation: selling price to gain 15.0 % ({})").
            format(moneybefore_15))
        self.cmbPrices.insertSeparator(8)
        self.cmbPrices.addItem(
            self.tr("After simulation: current price ({})").format(
                quote_current.money()))
        self.cmbPrices.addItem(
            self.tr("After simulation: simulation price ({})").format(
                quote_simulation.money()))
        self.cmbPrices.addItem(
            self.tr("After simulation: selling price to gain 0 % ({})").format(
                moneyafter_0))
        self.cmbPrices.addItem(
            self.tr("After simulation: selling price to gain 2.5 % ({})").
            format(moneyafter_2_5))
        self.cmbPrices.addItem(
            self.tr("After simulation: selling price to gain 5.0 % ({})").
            format(moneyafter_5))
        self.cmbPrices.addItem(
            self.tr("After simulation: selling price to gain 7.5 % ({})").
            format(moneyafter_7_5))
        self.cmbPrices.addItem(
            self.tr("After simulation: selling price to gain 10.0 % ({})").
            format(moneyafter_10))
        self.cmbPrices.addItem(
            self.tr("After simulation: selling price to gain 15.0 % ({})").
            format(moneyafter_15))
        self.cmbPrices.setCurrentIndex(index)
        self.cmbPrices.blockSignals(False)

        #Show tables
        if index == 0:  #Before current price
            self.investment.op.myqtablewidget(self.mqtwOps, quote_current)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quote_current)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 1:  # Before simulation simulation price
            self.investment.op.myqtablewidget(self.mqtwOps, quote_simulation)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quote_simulation)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 2:  # Before current price to gain 0
            self.investment.op.myqtablewidget(self.mqtwOps, quotebefore_0)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quotebefore_0)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 3:  # Before current price to gain 2.5%
            self.investment.op.myqtablewidget(self.mqtwOps, quotebefore_2_5)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quotebefore_2_5)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 4:  # Before current price to gain 5%
            self.investment.op.myqtablewidget(self.mqtwOps, quotebefore_5)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quotebefore_5)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 5:  # Before current price to gain 7.5%
            self.investment.op.myqtablewidget(self.mqtwOps, quotebefore_7_5)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quotebefore_7_5)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 6:  # Before current price to gain 10%
            self.investment.op.myqtablewidget(self.mqtwOps, quotebefore_10)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quotebefore_10)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 7:  # Before current price to gain 15%
            self.investment.op.myqtablewidget(self.mqtwOps, quotebefore_15)
            self.investment.op_actual.myqtablewidget(self.mqtwCurrentOps,
                                                     quotebefore_15)
            self.investment.op_historica.myqtablewidget(self.mqtwHistoricalOps)
        elif index == 9:  # After current price
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quote_current)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quote_current)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 10:  # After simulation price
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quote_simulation)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quote_simulation)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 11:  # After current price to gain 0
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quoteafter_0)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quoteafter_0)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 12:  # After current price to gain 2.5%
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quoteafter_2_5)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quoteafter_2_5)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 13:  # After current price to gain 5%
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quoteafter_5)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quoteafter_5)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 14:  # After current price to gain 7.5%
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quoteafter_7_5)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quoteafter_7_5)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 15:  # After current price to gain 10%
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quoteafter_10)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quoteafter_10)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)
        elif index == 16:  # After current price to gain 15%
            self.investment_simulated.op.myqtablewidget(
                self.mqtwOps, quoteafter_15)
            self.investment_simulated.op_actual.myqtablewidget(
                self.mqtwCurrentOps, quoteafter_15)
            self.investment_simulated.op_historica.myqtablewidget(
                self.mqtwHistoricalOps)