Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/axes_candlestick' into team-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandy Kopelke authored and Mandy Kopelke committed Sep 7, 2019
2 parents e6169e4 + 61bbd93 commit 89ecacc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
21 changes: 18 additions & 3 deletions axes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


def draw_x_axis(screen, x, y, w, start_date, end_date):
"""Draws the x axis
"""Draws the x axis
* screen
* x - origin x
Expand All @@ -13,14 +13,29 @@ def draw_x_axis(screen, x, y, w, start_date, end_date):
note that (end_date - start_date) is the number of days
in that period
"""



def draw_y_axis(screen, x, y, h, min_price, max_price):
"""Draws the y axis
"""Draws the y axis
* screen
* x - origin x
* y - origin y
* h - width
* h - height
* min_price - in USD
* max_price - in USD
"""
pygame.draw.lines(screen, BLACK , False, [(x,y),(x,h)], 2)
text_snippet_min = my_font.render(f"{min_price}", True, BLACK)
screen.blit(text_snippet_min, ((x-50), (y+h)))
text_snippet_max = my_font.render(f"{max_price}", True, BLACK)
screen.blit(text_snippet_max, ((x-50), (y+5)))

spread = max_price - min_price

text_snippet_mid = my_font.render(f"{max_price-spread/2}", True, BLACK)
screen.blit(text_snippet_mid



29 changes: 20 additions & 9 deletions candlestick.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@

def draw_candlestick(screen, x, y, h, cs_w, stock_info):
"""Draws a candlestick
* screen
* screen
* x - x co-ordinate of candlestick centre
* y - origin y
* h - height of chart
* h - height of candlestick - changed to the height of the candlestick
* cs_w - candlestick_width
* stock_info - {
'open': usd,
'close': usd,
'low': usd,
'high': usd,
}
"""
'open': usd,
'close': usd,
'low': usd,
'high': usd,
}
"""
#methodlogy - change stock_info dict in list then take the high and low as a perecentage of the height and width of the candlestick
rect_color = (255, 255, 255)
list_cords = [stock_info[open], stock_info[close], stock_info[low], stock_info[high]]
price_difference = list_cords[3] - list_cords[2] / h
if list_cords[0] > list_cords[1]:
pass
elif list_cords[0] < list_cords[1]:
pass
elif list_cords[0] = list_cords[1]:
pass
pygame.draw.line(screen, (BLACK), (start_pos), (end_pos), 2)
pygame.draw.rect(screen, (rect_color), (rect_x, rect_y, rect_w, rect_h), 2)

0 comments on commit 89ecacc

Please sign in to comment.