Esempio n. 1
0
 def get_info(self):
     if not self.portfolio:
         return []
     change, percent = self.portfolio.current_change
     change_text = gui_utils.get_string_from_float(percent) + '%' + ' | ' + gui_utils.get_currency_format_from_float(change)
     o_change, o_percent = self.portfolio.overall_change
     o_change_text = gui_utils.get_string_from_float(o_percent) + '%' + ' | ' + gui_utils.get_currency_format_from_float(o_change)
     return [(_('Day\'s gain'), gui_utils.get_green_red_string(change, change_text)),
             (_('Overall gain'), gui_utils.get_green_red_string(o_change, o_change_text)),
             ('Investments', gui_utils.get_currency_format_from_float(self.portfolio.get_current_value())),
             ('# positions', self.portfolio.active_positions_count),
             ('Last update', gui_utils.datetime_format(self.portfolio.last_update, False))
             ]
Esempio n. 2
0
    def add_chart(self):
        self.vbox.remove(self.current_chart)
        date1 = date.today()
        date2 = self.get_date2(self.current_zoom, date1)

        data = self.stock.get_quotations(date2)
        if len(data) == 0:
            if not self.noDataLabelShown:
                self.noDataLabelShown = True
                self.vbox.pack_end(Gtk.Label(label='No historical data found!'), True, True, 0)
                self.show_all()
            return
        controller = chart_controller.StockChartPlotController(data)
        self.current_chart = charts.SimpleLineChart(controller, 600)
        self.vbox.pack_end(self.current_chart, True, True, 0)

        change = controller.y_values[0][1][-1] - controller.y_values[0][1][0]
        if controller.y_values[0][1][0] == 0.1:
            safeDiv = 1
        else:
            safeDiv = controller.y_values[0][1][0]
        change_str = gui_utils.get_green_red_string(change, gui_utils.get_currency_format_from_float(change) + ' (' + str(round(change / safeDiv * 100, 2)) + '%)')
        self.change_label.set_markup(gui_utils.get_date_string(date2) + ' - ' + gui_utils.get_date_string(date1) + '     ' + change_str)

        self.show_all()