仓库源文站点原文


layout: post title: "ML4T笔记 | 01-04 Statistical analysis of time series" date: "2019-01-11 01:11:11" categories: 计算机科学 auth: conge

tags: Machine_Learning Trading OMSCS

01-02 - Are you ready

Lesson outline

Pandas makes it very convenient to compute various statistics on a dataframe:

You will use these functions to analyze stock movement over time.

Specifically, you will compute:

03 - Global statistics

Global statistics: meanmedianstdsum, etc. [more]

Time: 00:01:15

04 - Compute global statistics

df.mean() returns mean of stock prices for each symbol. df.median() returns median of stock prices for each symbol. df.std() returns standard deviation. Mathematically, the standard deviation is the square root of the variance.

Time: 00:01:53

05 - Rolling statistics

Time: 00:03:06

06 - Quiz: Which statistic to use

Given a rolling mean (in red), and the price in blue. what statistics to use to look for a buy signal or a sell signal. In another word, how can we decide that we’re far enough away from the mean that we should consider taking actions?

Rolling statistics: rolling_meanrolling_std, etc. [more]

Time: 00:00:36

07 - Bollinger Bands

Time: 00:02:49

08 - Computing rolling statistics

image.png rm_SPY = pd.rolling_mean(df['SPY'], window=20) is the line calculate the rolling mean. the rest of the cold is to plot the rolling mean and the stock prices together.

Time: 00:02:07

09 - Quiz Calculate Bollinger Bands

It's quiz time. image.png Implement the functions to calculate rolling bands.

My answer

Time: 00:01:17

10 - Daily returns

image.png

Time: 00:03:11

11 - Quiz Compute daily returns

My answer failed

Provided answer

The Panda way!

Time: 00:02:25

12 - Cumulative returns

Time: 00:02:22

Total Time: 00:23:17

First draft: 2019-01-11