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()
def update_labels(self): quotations = self.asset.quotations self.count = len(quotations) self.count_label.set_text(str(self.count)) if self.count == 0: self.first_label.set_text('n/a') self.last_label.set_text('n/a') else: self.first_label.set_text(gui_utils.get_date_string(quotations[0].date)) self.last_label.set_text(gui_utils.get_date_string(quotations[-1].date))
def on_pick_end(self, entry, *args): dialog = common_dialogs.CalendarDialog(self.range_end, parent=self.widget.get_toplevel()) if dialog.date: self.range_end = dialog.date self.update_ui() self.end_entry.set_text(gui_utils.get_date_string(self.range_end))
def format_days(days, step): if step == "daily": return map(lambda d: gui_utils.get_date_string(d), days) elif step == 'monthly': formatstring = "%b %y" elif step == 'yearly': formatstring = "%Y" elif step == 'weekly': formatstring = "%U" return map(lambda d: d.strftime(formatstring), days)
def get_info(self): return [('# transactions', self.portfolio.transaction_count), ('Last transaction', gui_utils.get_date_string(self.portfolio.date_of_last_transaction))]
def start_price_markup(column, cell, model, iterator, column_id): pos = model.get_value(iterator, 0) markup = "%s\n<small>%s</small>" % (gui_utils.get_currency_format_from_float(model.get_value(iterator, column_id)), gui_utils.get_date_string(pos.date)) cell.set_property('markup', markup)
def get_info(self): return [('# dividends', self.portfolio.get_dividends_count()), ('Sum', gui_utils.get_currency_format_from_float(self.portfolio.get_dividends_sum())), ('Last dividend', gui_utils.get_date_string(self.portfolio.date_of_last_dividend))]
def __init__(self, quotations): self.y_values = [(_("close"), [d.close for d in quotations])] self.x_values = [gui_utils.get_date_string(q.date) for q in quotations]