python 对数收益率_用python进行风险调整后的收益

本文介绍了如何使用Python来计算对数收益率,并探讨了风险调整后的收益。通过翻译自Medium的文章,读者将学习到利用Python进行金融数据分析的相关技巧。
摘要由CSDN通过智能技术生成

python 对数收益率

(Real-world Analysis of US Equity data between 1926 to 2018)

(1926年至2018年间美国股票数据的真实世界分析)

Return and Risk are like the two sides of a coin. A risk-free return is like a state of utopia and each and every return generated on an asset needs to be looked at with the load of the risk it brings in the fold. The saying goes - higher the return higher the risk which albeit theoretically true when compared to cross-asset classes may not always hold true practically. In fact, there are a plethora of cases where this saying has been defeated in straight sets sometimes adding to the misery or joy of investors.

收益和风险就像硬币的两个面。 无风险收益就像乌托邦一样,资产产生的每笔收益都需要考虑其带来的风险。 俗话说-收益越高,风险越高,尽管与跨资产类别相比在理论上是正确的,但在实践中可能并不总是如此。 事实上,在很多情况下,这句话被直截了当打败了,有时加剧了投资者的痛苦或喜悦。

In a previous article, we have looked at modelling returns using Python. You might want to look at the same which will act a precursor to this analysis.

在上一篇文章中,我们介绍了使用Python建模收益的方法。 您可能想看看可以充当此分析先驱的内容。

“Click here for my article on calculating Returns using Python”

“单击此处获得有关使用Python计算退货的文章”

As a next read one can look at my article on modelling drawdowns with Python…

作为下一个阅读者,可以阅读我有关使用Python建模缩编的文章。

“Click here for my article on Modelling Drawdown with Python”

“单击此处获得有关使用Python进行模型建模的文章”

In the notebook attached at the end of the article, what we have done is that we have taken a sample of price points for two asset classes, compute the returns and then proceeded to compute the Standard deviation and mean using Python provided formulas before doing the computation ourselves and matching them up. The concept of variance is arrived at first by calculating the returns deviation from the mean, squaring the same, make a cumulative sum before dividing it by the number of observations to get the variance:

在本文末尾的笔记本中,我们所做的是,我们对两个资产类别的价格点进行了采样,计算了收益,然后在执行以下操作之前,使用Python提供的公式计算了标准差和均值。自己计算并匹配它们。 首先通过计算均值的收益偏差,对均方差求平方,求出一个累加的总和,然后将其除以观察次数,得出方差的概念:

Standard Deviation next is just the Square root of the variance and is also termed as the volatility of the time series.

接下来的标准偏差只是方差的平方根,也称为时间序列的波动性。

Real World Analysis

现实世界分析

Now we will try to do the analysis on a real set of data. A data set that provides us grouped returns on US stocks based on market capitalisation between 1926 to 2018. In the snapshot below what you see is the monthly returns seen for portfolios of stocks. The portfolios are again based on the market capitalisation of the individual stocks and grouped together.

现在,我们将尝试对一组实际数据进行分析。 一个数据集,可根据1926年至2018年之间的市值为我们提供美国股票的分组收益。在下面的快照中,您看到的是股票投资组合的月度收益。 这些投资组合再次基于单个股票的市值并将它们组合在一起。

Image for post

We take on two portfolios here for our analysis, Lo 10( Lowest 10% stocks based on Market capitalisation)and Hi 10 (Highest 10% stocks based on Market capitalisation) columns for doing our analysis.So we will trim our data set to only show this two columns. A few cleanings here and there and some labelling to reflect Lo 10 as Small Caps and Hi 10 as Large Caps and you have the following plot:

我们在这里进行两个投资组合的分析,分别是Lo 10(基于市值的最低10%的股票)和Hi 10(基于市值的最高10%的股票)列进行分析,因此我们将数据集修整为仅显示这两列。 在这里和那里进行一些清洁,并贴上一些标签以反映Lo 10为小写字母,Hi 10为大写字母,并且您具有以下图表:

Image for post

Evidently the Small Caps are showing more amount of deviations from the mean(volatility) as compared to the large caps in the life span.However, to conclude on the observation we go ahead and calculate the annualised volatility from the standard deviation which is a monthly data point.

显然,与大盘股相比,小盘股与平均(波动率)的偏差更大,然而,总结一下我们可以继续观察并根据标准差计算每月的年波动率数据点。

Image for post

That nails our observation in terms of the deviations exhibited in the plot above.However, the argument does not stop here on which stocks have performed better and to further drill down we would need the annualised return on both series. To achieve the annualised rate of return, first thing is to calculate the return per month for both the series which is then annualised.Details are in the notebook, what we will paste here is the output:

上面的图表显示了我们的观察结果,但我们的观点并不仅限于哪些股票表现更好,而要进一步深入研究,我们需要两个系列的年化收益率。 为了获得年化回报率,首先要计算两个系列的每月回报率,然后将其年化。详细信息在笔记本中,我们将在此处粘贴的是输出:

Image for post

Higher the risks, higher the returns, suits the adage. Seems so.let's look further.

更高的风险,更高的回报,很适合格言。 看来,让我们进一步看。

Return to Risk and Mr. Sharpe

回归风险和夏普先生

Instead of making plain and simple statements by looking at the returns and risk figures generated what we can employ is the Return to Risk ratio which will provide you on the return an investment made per unit of risk taken. So here we have:

相反,通过查看所产生的收益和风险的数字制作简单明了的语句我们可以采用的是回搏率将为您提供每所采取的风险单位的投资取得回报 。 因此,这里有:

Image for post

Large Caps the winner here with a slightly higher Return/Risk value. lets look at another parameter.

大盘赢家的回报/风险值略高。 让我们看看另一个参数。

Mr. William Sharp developed a risk reward ratio taking into cognizance the risk free rate. Well we started off by saying that there is nothing like that but indeed there are some more safer avenues of investment and US T bills are generally referred to as the safest and we can hypothetically consider them to be representing the risk free rate.

威廉·夏普(William Sharp)先生考虑了无风险利率,制定了风险回报率。 好吧,我们从一开始就说没有别的了,但是确实有一些更安全的投资渠道,US T票据通常被认为是最安全的,我们可以假设它们代表无风险利率。

Image for post

The Numerator captures the excess return of the portfolio with respect to the risk free rate and the denominator captures the portfolio volatility.

分子计算相对于无风险利率的投资组合的超额收益,分母反映投资组合的波动性。

I will leave it to you to check on the computation in the notebook(provided in link), but, we can see that the lower market cap stocks showed a higher Sharpe ratio compared to the Large caps. This would mean that in the period 1926 to 2018 the period for which the data set belongs, Small caps have exhibited better performance in returns when compared to the volatility it brings to the table.

我将留给您检查笔记本中的计算(在链接中提供),但是,我们可以看到,与大型股票相比,较低的股票价格显示出更高的夏普比率。 这意味着,在数据集所属的1926年至2018年期间,相比市值波动性,小型股的回报率表现更好。

Click here to look at the notebook uploaded in Github for code.

单击此处查看在Github中上载的笔记本

翻译自: https://medium.com/swlh/risk-adjusted-return-with-python-fd7f5c7d22af

python 对数收益率

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值