Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Dollar Cost Averaging

Pardon my ignorance as this is my first post and I only just got interested in Quant Trading. I was trying to see the returns of dollar cost averaging (buying SPY at the start of each month). However, for some reason, my four line code is not behaving as expected. There are lots of missing transactions if you look at the transaction log. Can someone please point out where am I making a mistake ?

Thanks

4 responses

You're trying to invest $100 a month in a security that costs over $200. :)

Here's what you could do: increase the investment amount and/or carry over the left over amount to the next month.

Thank you very much. Rookie mistake, but learned a lot :)

Hello,

I am a newbie and have coded additionally in the Dollar Cost Averaging algorithm posted here as I personally calculate.

Please help me include the dividend event in the algorithm. My intention is to add dividend re-investment in the dollar cost averaging algorithm:
Add units in PF = (Dividend per unit * No. of units in PF)/Price per unit

If this is going to be very complicated or not supported, please inform how to add an investment amount every 3 months or year. For example lets say:
Add units in PF every 3 months or year) = (Total PF value * %dividend)/Price per unit

Thanks.