Update StockReturn.py

This commit is contained in:
Andrew Dinh 2019-01-17 16:40:42 -08:00
parent 61e0cd0d91
commit 7f675e25ae

View File

@ -81,6 +81,19 @@ class Return:
firstDate = self.firstLastDates[0]
lastDate = self.firstLastDates[1]
finalDates = finalDatesAndClose[0]
finalClose = finalDatesAndClose[1]
for i in range(0, len(finalDates), 1):
if finalDates[i] == str(firstDate):
firstClose = finalClose[i]
elif finalDates[i] == lastDate:
lastClose = finalClose[i]
i = len(finalDates)
print('Close values:', firstClose, '...', lastClose)
unadjustedReturn = float(lastClose/firstClose)
unadjustedReturn = unadjustedReturn * 100
return unadjustedReturn
# def getBeta(self, timeFrame):
@ -89,6 +102,8 @@ class Return:
def main(self, stock):
# Find date to start from and last date
self.timeFrame = []
self.listOfReturn = []
print("\nPlease enter a time frame in years: ", end='')
#timeFrameYear = int(input())
timeFrameYear = 5
@ -107,7 +122,9 @@ class Return:
print('New dates: ', self.firstLastDates)
print('\nGetting unadjusted return')
Return.getUnadjustedReturn(self, stock)
unadjustedReturn = Return.getUnadjustedReturn(self, stock)
self.listOfReturn.append(unadjustedReturn)
print(self.listOfReturn[0], '%')
def main():
stockName = 'spy'