Skip to content

Instantly share code, notes, and snippets.

@SubhrajyotiSen
Created March 12, 2019 10:47
Show Gist options
  • Save SubhrajyotiSen/25d1e722b4cd96bca6b65bc849385536 to your computer and use it in GitHub Desktop.
Save SubhrajyotiSen/25d1e722b4cd96bca6b65bc849385536 to your computer and use it in GitHub Desktop.
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