mirror of
https://github.com/andrewkdinh/fund-indicators.git
synced 2024-11-21 14:44:20 -08:00
Update StockReturn.py
This commit is contained in:
parent
61e0cd0d91
commit
7f675e25ae
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user