Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import csv

compound_return = 1.0

with open('test/test-0.csv', 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
previous = None
current = None
for row in reader: # assuming entries are in chronological order, from oldest first to most recent
current = row
if not previous: # init case, if only one row, will return 1.0 since only 1 period
previous = current
continue
else:
sub_rate = (float(current[2]) - float(current[1])) / float(previous[2])
compound_return *= sub_rate


print 'Compound return is ' + str(compound_return - 1)