You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defmoduleXirrdodefmoduleVolatilitydodefcalculate_volatility(daily_prices)do# pairs of prices using zippairs=Enum.zip(daily_prices,Enum.drop(daily_prices,1))# pct change for each pairpct_changes=Enum.map(pairs,fn{a,b}->(b-a)/aend)# standard deviation of pct changesmean=Enum.sum(pct_changes)/Enum.count(pct_changes)# sum of squared differencesvariance=Enum.sum(Enum.map(pct_changes,fnx->(x-mean)*(x-mean)end))# standard deviationstddev=:math.sqrt(variance/(Enum.count(pct_changes)-1))# annualizestddev*:math.sqrt(252)endendend
The text was updated successfully, but these errors were encountered:
Hi bro
The text was updated successfully, but these errors were encountered: