1

how to calculate monlthy std diviatoin of daily returns in google sheets using google finance api? I think we need to use QUERY()but I am not sure how to form single data set in QUERY() by calling googlefinance() two times So far : My stock symbols are in Column A in sheet . I want to calculate monthly volatility as mentioned in https://www.investopedia.com/articles/investing/102715/computing-historical-volatility-excel.asp

I want have a colum that has monthly history volatility against the symbol in colum A :

=QUERY(QUERY( { ARRAY_CONSTRAIN(GOOGLEFINANCE("NSE:"&A2, "close", workday.intl(TODAY(),-5), workday.intl(TODAY(),-1), "daily"), 4, 2), ARRAY_CONSTRAIN(GOOGLEFINANCE("NSE:"&A2, "close", workday.intl(TODAY(),-6), workday.intl(TODAY(),-2), "daily"), 4, 2) }, "select Col2", 1), "offset 1",0)

With above query, I am able.to get data range which has last N day price in 1st colum and prev day price in colum 2. I would like to use and extend this to calculate monthly volatility. I am not sure how to use this price data range to calculate logarithm and and next calculation.

Thanks

2
  • Can you give an example of what you're looking for? Or a sample sheet? Commented May 19, 2021 at 12:09
  • there is no shortcut way to do this. you have to do a lot of math. Commented May 19, 2021 at 12:34

1 Answer 1

0

This may be an over-simplification of what you're trying to achieve, but can you use the STDEV function on a range of closing values during a month?

=stdev(query(googlefinance("NSE:"&A2, "close", MonthStartDate, eomonth(MonthStartDate,0), "daily"),"select Col2 offset 1",0))

MonthStartDate would be your cell 'named range' containing your month start. Obviously, days, where the markets are closed, would not bring back a value and the STDEV would reflect this.

If the closing price is too simplistic and you need other attributes, then you could combine them in the query.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks but this is not my goal. I want to follow the same calculation as mentioned in that link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.