Exemplo n.º 1
0
    def form_image(self, prices, screen_draw):
        screen_draw.rectangle((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                              fill="#ffffff")
        screen_draw = self.screen_draw
        if self.mode == "candle":
            Plot.candle(prices,
                        size=(SCREEN_WIDTH - 45, 93),
                        position=(41, 0),
                        draw=screen_draw)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices,
                      size=(SCREEN_WIDTH - 42, 93),
                      position=(42, 0),
                      draw=screen_draw)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices,
                           FONT_SMALL, (0, 0), (38, 89),
                           draw=screen_draw)
        screen_draw.line([(10, 98), (240, 98)])
        screen_draw.line([(39, 4), (39, 94)])
        screen_draw.line([(60, 102), (60, 119)])
        Plot.caption(flatten_prices[len(flatten_prices) - 1], 95, SCREEN_WIDTH,
                     FONT_LARGE, screen_draw)
Exemplo n.º 2
0
    def form_image(self, prices):
        self.draw_black.rectangle((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                                  fill="white")
        screen_draw = self.draw_black
        if self.mode == "candle":
            Plot.candle(prices,
                        size=(SCREEN_WIDTH - 38, 79),
                        position=(35, 0),
                        draw=screen_draw)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices,
                      size=(SCREEN_WIDTH - 36, 79),
                      position=(36, 0),
                      draw=screen_draw)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices,
                           FONT_SMALL, (0, 0), (32, 76),
                           draw=screen_draw)
        screen_draw.line([(9, 83), (204, 83)])
        screen_draw.line([(33, 3), (33, 80)])
        screen_draw.line([(51, 87), (51, 101)])
        Plot.caption(flatten_prices[len(flatten_prices) - 1], 81, SCREEN_WIDTH,
                     FONT_LARGE, screen_draw)
Exemplo n.º 3
0
    def form_image(self, prices, screen_draw):
        screen_draw.rectangle((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                              fill="#ffffff")
        screen_draw = self.screen_draw
        if self.mode == "candle":
            Plot.candle(prices,
                        size=(SCREEN_WIDTH - 45, 130),
                        position=(41, 2),
                        draw=screen_draw)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices,
                      size=(SCREEN_WIDTH - 42, 130),
                      position=(42, 2),
                      draw=screen_draw)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices,
                           FONT_SMALL, (0, 2), (38, 126),
                           draw=screen_draw)

        screen_draw.line([(39, 4), (39, 129)])
        screen_draw.line([(65, SCREEN_HEIGHT - 30), (65, SCREEN_HEIGHT - 5)])
        screen_draw.line([(5, SCREEN_HEIGHT - 40), (255, SCREEN_HEIGHT - 40)])
        Plot.caption(flatten_prices[len(flatten_prices) - 1],
                     SCREEN_HEIGHT - 35, SCREEN_WIDTH, FONT_LARGE, screen_draw)
Exemplo n.º 4
0
    def update(self, prices):
        image = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
        screen_draw = ImageDraw.Draw(image)
        if self.mode == "candle":
            Plot.candle(prices,
                        size=(SCREEN_WIDTH - 45, 93),
                        position=(41, 0),
                        draw=screen_draw)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices,
                      size=(SCREEN_WIDTH - 42, 93),
                      position=(42, 0),
                      draw=screen_draw)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices,
                           FONT_SMALL, (0, 0), (38, 89),
                           draw=screen_draw)
        screen_draw.line([(10, 98), (240, 98)])
        screen_draw.line([(39, 4), (39, 94)])
        screen_draw.line([(60, 102), (60, 119)])
        Plot.caption(flatten_prices[len(flatten_prices) - 1], 95, SCREEN_WIDTH,
                     FONT_LARGE, screen_draw)
        image.save(self.filename)
Exemplo n.º 5
0
    def form_image(self, prices, screen_draw):
        screen_draw.rectangle((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                              fill="#ffffff")
        if self.mode == "candle":
            Plot.candle(prices,
                        size=(SCREEN_WIDTH - 45, SCREEN_HEIGHT - 27),
                        position=(41, 0),
                        draw=screen_draw)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices,
                      size=(SCREEN_WIDTH - 42, SCREEN_HEIGHT - 27),
                      position=(42, 0),
                      draw=screen_draw)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices,
                           FONT_SMALL, (0, 0), (38, SCREEN_HEIGHT - 34),
                           draw=screen_draw,
                           labels_number=5)
        screen_draw.line([(10, SCREEN_HEIGHT - 25), (470, SCREEN_HEIGHT - 25)])
        screen_draw.line([(39, 4), (39, SCREEN_HEIGHT - 27)])
        screen_draw.line([(60, SCREEN_HEIGHT - 23), (60, SCREEN_HEIGHT - 1)])
        # screen_draw.text((-1, SCREEN_HEIGHT - 27), "XXX"[:3], font=FONT_LARGE, fill=None)
        Plot.caption(flatten_prices[len(flatten_prices) - 1],
                     SCREEN_HEIGHT - 27,
                     SCREEN_WIDTH - 45,
                     FONT_LARGE,
                     screen_draw,
                     price_offset=0)
        Plot.percentage(prices, SCREEN_WIDTH - 56, SCREEN_HEIGHT - 27,
                        FONT_LARGE, screen_draw)

        screen_draw.line([(366, SCREEN_HEIGHT - 23), (366, SCREEN_HEIGHT - 1)])
Exemplo n.º 6
0
    def form_image(self, prices):
        WHITE = self.inky_display.WHITE
        RED = self.inky_display.RED
        BLACK = self.inky_display.BLACK
        screen_draw = ImageDraw.Draw(self.image)
        screen_draw.rectangle([0,0,SCREEN_WIDTH,SCREEN_HEIGHT],fill=WHITE)
        if self.mode == "candle":
            Plot.candle(prices, size=(SCREEN_WIDTH - LEFT_MARGIN, SCREEN_HEIGHT - BOTTOM_MARGIN), position=(LEFT_MARGIN, 0), draw=screen_draw, fill_neg=RED, fill_pos=BLACK)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices, size=(SCREEN_WIDTH - LEFT_MARGIN, SCREEN_HEIGHT - BOTTOM_MARGIN), position=(LEFT_MARGIN, 0), draw=screen_draw, fill=BLACK)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices, FONT_SMALL, (0, 0), (LEFT_MARGIN, SCREEN_HEIGHT - BOTTOM_MARGIN - SMALL_FONT_SIZE - 3), draw=screen_draw, fill=BLACK)
        screen_draw.line([(0, SCREEN_HEIGHT - BOTTOM_MARGIN), (SCREEN_WIDTH, SCREEN_HEIGHT - BOTTOM_MARGIN)], fill=BLACK)
        screen_draw.line([(LEFT_MARGIN, 0), (LEFT_MARGIN, SCREEN_HEIGHT - BOTTOM_MARGIN)], fill=BLACK)
        Plot.caption(flatten_prices[len(flatten_prices) - 1], SCREEN_HEIGHT - BOTTOM_MARGIN, SCREEN_WIDTH, FONT_LARGE, screen_draw, fill=BLACK, currency_offset=LEFT_MARGIN, price_offset=LEFT_MARGIN)