-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstock.py
36 lines (29 loc) · 1.1 KB
/
stock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from Robinhood import Robinhood
#########################################################
##Holds information about stocks you would like to save##
#########################################################
class stock:
ticker = None
current_ask_price = None
prev_close = None
valid = None
def __init__(self, ticker):
robinhood = Robinhood()
self.ticker = ticker
try:
self.current_ask_price = float(str(robinhood.ask_price(ticker)))
self.prev_close = float(str(robinhood.previous_close(ticker)))
except NameError:
print ('Invalid Symbol: %s' % ticker)
raw_input("Press Enter to continue...")
self.valid = False
def get_ask_price(self):
return self.current_ask_price
def get_prev_close(self):
return self.prev_close
def get_ticker(self):
return self.ticker
def update_price(self):
robinhood = Robinhood()
self.current_ask_price = float(str(robinhood.ask_price(self.ticker)))
self.prev_close = float(str(robinhood.previous_close(self.ticker)))