All,
I have I think a simple question, I've checked other older posts but still I'm not sure I understand how to achieve the following.
Just to avoid misunderstanding, assuming today is say Feb 15,2006, for daily percent return I mean the price change from yesterday's (Feb 14) to today's close price.
Checking online historical data I can see the historical daily returns are:
Feb 13, 2006 daily return = -0.18%
Feb 14, 2006 daily return = 1.06%
Feb 15, 2006 daily return = 0.35%
My goal is to have the average of the last 3 daily returns. In this case I would want to schedule a function, run it one minute before the market close and on Feb 15, 2006 see something very very close to (-0.18% + 1.06% + 0.35%) / 3 = 0.41%
I tried to use what discussed in:
https://www.quantopian.com/posts/calculate-daily-returns-for-the-past-x-days
but I get really wrong results.
Basically I'm trying to implement a strategy that needs to enter a trade at the end of the day if the average of the 3 most recent daily returns is above or below a specific value.
As easy as it sound, I'm so bad I can't figure out how to get the right data :(
Any chance somebody could help me?
Many thanks,
Angel