Created
March 12, 2019 10:47
-
-
Save SubhrajyotiSen/25d1e722b4cd96bca6b65bc849385536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var amount = 100.0 | |
val installment = 100.0 | |
entryList.add(Entry(0f, 100f)) // initial investment | |
for (i in 1 until dataPoints.size) { | |
val diff = (dataPoints[i].price - dataPoints[i - 1].price) / dataPoints[i - 1].price | |
amount += (amount * diff) | |
if (i != dataPoints.size - 1) | |
amount += installment | |
entryList.add(Entry(i.toFloat(), amount.toFloat())) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment