AI For Trading: Trading Strategy-2 (12)
Statistics Analysis
Statistics courses
If you need to learn more about statistics, or brush up on some existing knowledge, check out Udacity's courses on Descriptive Statistics-描述统计学and Inferential Statistics-推论统计学.
描述统计学
统计学是数学的一个重要领域,用于分析、解释和预测数据的结果。描述统计学将让你学会描述数据的基本概念。这是为那些对数据科学、经济学、心理学、机器学习、体育分析学以及其它任何领域感兴趣的人开设的意义重大的入门课程。课程提供中文版本。
推论统计学
推论统计学能让我们从并不明显的数据中作出结论。本课重点是增强你提出假设的能力,并使用常用的检验方法,如 T 检验、ANOVA 检验以及回归来验证你的主张。
The Many Meanings of "Alpha"
Disambiguation of the term “Alpha”
You will hear the term “alpha” throughout this program, so we want to let you know early on that the term “alpha” is used to mean multiple things in the investment industry.
您将在整个计划中听到“alpha”一词,因此我们希望尽早通知您,“alpha”一词用于表示投资行业中的多个事物。
In mathematics, you’ll see alpha refer to the significance level of a hypothesis test. In regression, you’ll see alpha refer to the y-intercept of a straight line.
在数学中,你会看到alpha指的是假设检验的显着性水平。在回归中,您将看到alpha指的是直线的y轴截距。
In finance, alpha refers to multiple distinct but somewhat related ideas. The common thread among these definitions is that alpha is the extra value that an investment professional can add to the performance of an investment.
在金融领域,alpha指的是多个不同但有些相关的想法。这些定义中的共同点是,alpha是投资专业人员可以为投资业绩增加的额外价值。
One specific definition of alpha is the extra return that an actively managed fund can deliver, that exceeds the performance of passively investing (buy and hold) in a portfolio of stocks. Another specific definition of alpha, which we’ll primarily focus on in this course, is that of an alpha vector.
α的一个具体定义是主动管理基金可以提供的额外回报,超过了股票投资组合中被动投资(买入和持有)的表现。我们将主要关注的另一个特定的alpha定义是alpha矢量。
An alpha vector is a list of numbers, one for each stock in a portfolio, that gives us a signal as to the relative future performance of these stocks. You’ll learn more about alpha vectors throughout term 1.
α矢量是一个数字列表,一个是投资组合中每个股票的一个,它给我们一个关于这些股票相对未来表现的信号。您将在第1学期了解有关alpha矢量的更多信息。
Just to be clear, the finance community, both in academia and industry, use alpha to denote multiple ideas.
需要明确的是,学术界和工业界的金融界都使用alpha来表示多种想法。
In this lesson, you may have noticed that we use “alpha” in the statistical sense when we talked about hypothesis testing. We also used when saying that we may “find alpha” in a strategy. This second usage refers to outsized performance, or better-than-passive performance that a finance professional can add to an investment. Later on, we will use it in the sense of an alpha vector, which is a list of numbers that give us a signal about the relative performance of each stock.
在本课中,您可能已经注意到,当我们讨论假设检验时,我们在统计意义上使用“alpha”。我们还说过,我们可能会在策略中“找到alpha”。第二种用法是指财务专业人员可以为投资增加的超大业绩或优于被动业绩。稍后,我们将在alpha矢量的意义上使用它,这是一个数字列表,它给我们一个关于每个股票的相对表现的信号。
Test Returns for Statistical Significance
Complete the function analyze_returns below.
This linkprovides a useful reference on the scipy.stats package. This part is about the t-test.
statistical_test.py
import pandas as pd
import numpy as np
import scipy.stats as stats
def analyze_returns(net_returns):
"""
Perform a t-test, with the null hypothesis being that the mean return is zero.
Parameters
----------
net_returns : Pandas Series
A Pandas Series for each date
Returns
-------
t_value
t-statistic from t-test
p_value
Corresponding p-value
"""
# TODO: Perform one-tailed t-test on net_returns
# Hint: You can use stats.ttest_1samp() to perform the test.
# However, this performs a two-tailed t-test.
# You'll need to divde the p-value by 2 to get the results of a one-tailed p-value.
null_hypothesis = 0.0
return None
def test_run(filename='net_returns.csv'):
"""Test run analyze_returns() with net strategy returns from a file."""
net_returns = pd.Series.from_csv(filename, header=0)
t, p = analyze_returns(net_returns)
print("t-statistic: {:.3f}\np-value: {:.6f}".format(t, p))
if __name__ == '__main__':
test_run()
net_returns.csv
date,return
2014-11-30,0.011635519414351009
2014-12-31,0.021954092308170955
2015-01-31,0.04088726605224263
2015-02-28,-0.0025112428290965105
2015-03-31,0.01725861669076579
2015-04-30,0.04169672034614155
2015-05-31,0.033973104078552634
2015-06-30,0.011808567427224085
2015-07-31,-0.034296712711723694
2015-08-31,-0.018000336527001545
2015-09-30,0.04244859300243494
2015-10-31,0.06048679384582347
2015-11-30,0.004425442647837301
2015-12-31,-0.011128068116992282
2016-01-31,0.03904059055851628
2016-02-29,-0.018534757459136356
2016-03-31,0.051492028368816355
2016-04-30,0.008987284920489497
2016-05-31,0.04030096220308846
2016-06-30,-0.07014813509500822
2016-07-31,-0.03744600404974712
2016-08-31,-0.05765103830475751
2016-09-30,0.05280791013124859
2016-10-31,0.04813615235947365
2016-11-30,0.019069757993200993
2016-12-31,0.02369364599868217
2017-01-31,-0.022749483402672258
2017-02-28,-0.07743936042570741
2017-03-31,0.03324798542019691
2017-04-30,-0.02091584879987623
2017-05-31,-0.06955420357572517
2017-06-30,0.003758874907665249
Quize:Statistical Analysis
The t-Test
Let's say we've calculated a set of monthly returns, and we've calculated their mean. Now, we'll perform a t-test to see if we can infer from our limited data set that our trading strategy is likely to yield positive returns. We'll perform a one-tailed t-test with the null hypothesis that \muμ, the true mean return from our trading strategy, equals 0
假设我们计算了一组月回报,我们计算了它们的均值。现在,我们将进行一次t检验,看看我们是否可以从我们有限的数据集推断出我们的交易策略可能产生正回报。我们将使用零假设进行单尾t检验,即μμ,即我们交易策略的真实均值回报,等于0。
In which situation might we conclude that our trading strategy is likely to yield positive returns (check all that apply)?
Correct! Low p-values tell us that if the true mean is 0, we would be unlikely to observe a mean as or more "extreme" than the mean we observed.
为者常成,行者常至
自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)