Sploe = 2: means that SPY move up 1, ABC move up 2

Correlation: how close those dots close to the line.

def scatter(df):

    plot_data(df, title="Data frame", yLabel="Time")
plt.show() dr = compute_daily_return(df)
plot_data(dr, title="Daily returns", yLabel="Daily returns") dr['GOOG'].hist(bins=20, label="GOOG")
dr['SPY'].hist(bins=20, label="SPY")
plt.legend(loc='upper right') # Scatterplot SPY vs GOOG
dr.plot(kind='scatter', x = 'SPY', y = 'GOOG')
spy = dr['SPY'][:-1] # remove nan value
goog = dr['GOOG'][:-1] # remove nan value
beta_goog, alpha_goog = np.polyfit(spy, goog, 1)
# beta_goog= 1.23719057977
# alpha_goog= -0.000283995818653
plt.plot(dr['SPY'], beta_goog*dr['SPY']+alpha_goog, '-', color='r')
plt.show() print("Correlation", dr.corr(method='pearson')) # Get kurtosis
print("kurtosis=", dr.kurtosis()) if __name__ == '__main__':
df=test_run()
scatter(df[['SPY', 'GOOG']])

[Python] Scatter Plot for daily return的更多相关文章

  1. [Python] Histograms for analysis Daily return

    A histogram is an accurate representation of the distribution of numerical data. Y axis is the occur ...

  2. [D3] Build a Scatter Plot with D3 v4

    Scatter plots, sometimes also known as bubble charts, are another common type of visualization. They ...

  3. python matplotlib plot 数据中的中文无法正常显示的解决办法

    转发自:http://blog.csdn.net/laoyaotask/article/details/22117745?utm_source=tuicool python matplotlib pl ...

  4. python中生成器对象和return 还有循环的区别

    python中生成器对象和return 还有循环的区别 在python中存在这么一个关键字yield,这个关键字在项目中经常被用到,比如我写一个函数不想它只返回一次就结束那我们就不能用return,因 ...

  5. Python Matplotlib.plot Update image Questions

    1. 最近在测试一款设备,采集了一些设备后需要一帧一帧显示图像,经常使用Python,所以选用了Matplotlib进行图像操作 数据结构: timesatamp polar_distance hor ...

  6. [D3] 9. Scatter Plot

    Up until now we've just looked at bar charts. A handy chart, no doubt, but D3 offers a variety of ch ...

  7. python matplotlib.plot画图显示中文乱码的问题

    在matplotlib.plot生成的统计图表中,中文总是无法正常显示.在网上也找了些资料,说是在程序中指定字体文件,不过那样的话需要对plot进行很多设置,而且都是说的设置坐标轴标题为中文,有时候图 ...

  8. Python函数基础--def及return语句地操作

    1·def是可执行的代码 Python的函数是有一个新的语句编写的,即def.不像C这样的编译语言,def 实际上是一个可执行的语句--函数并不存在,直到Python运行了def后才存在.在典型的操作 ...

  9. [python]函数返回多个return值

    python支持函数直接返回多个变量,具体用法如下: >>> def test(): ... a=2 ... b=3 ... return a,b ... >>> ...

随机推荐

  1. LR编写get请求

    LR编写简单Get接口 接口必备信息:接口功能.URL.支持格式.http请求方式.请求参数.返回参数 请求地址 http://api.k780.com:88/?app=life.time 请求方式 ...

  2. Optional是以enum和泛型为基础的高阶类型

    结论:1.optionals使用时需要检查:2.可以通过!+赋值语句转化为非optionals. Optional-Generic Enumeration enum Optional<T> ...

  3. eval-Evaluation

    eval is a function which evaluates a string as though it were an expression and returns a result; in ...

  4. 在vue组件中style scoped中遇到的坑

    在uve组件中我们我们经常需要给style添加scoped来使得当前样式只作用于当前组件的节点.添加scoped之后,实际上vue在背后做的工作是将当前组件的节点添加一个像data-v-1233这样唯 ...

  5. 洛谷P3567 [POI2014]KUR-Couriers 主席树

    挺裸的,没啥可讲的. 不带修改的主席树裸题 Code: #include<cstdio> #include<algorithm> using namespace std; co ...

  6. oracle查询优化之子查询条件优化

    环境:oracle 11g 现有a表与b表通过a01字段关联,要查询出a表的数据在b表没有数据的数据:sql如下 ) ) 因为flag是虚拟字段没有走不了索引导致这条sql执行起来特别慢 310W条数 ...

  7. 学习参考《Flask Web开发:基于Python的Web应用开发实战(第2版)》中文PDF+源代码

    在学习python Web开发时,我们会选择使用Django.flask等框架. 在学习flask时,推荐学习看看<Flask Web开发:基于Python的Web应用开发实战(第2版)> ...

  8. MySQL中将数据库表名修改成大写的存储过程

    原文:MySQL中将数据库表名修改成大写的存储过程 MySQL中将数据库表名修改成大写的存储过程 创建存储过程的代码: DROP PROCEDURE IF EXISTS uppercaseTablen ...

  9. 现代C++ 基于范围的for和for_each语句

    现代C++中强调,使用基于范围的 for 循环(Visual studio 2012之后的),相比于旧版的 for 循环更整洁和易于使用,并且不容易发生意外错误.让我们一睹为快. 当然,使用前需要包含 ...

  10. MD5 加密原理(转)

    MD5的全称是Message-Digest Algorithm 5(信息-摘要算法),在90年代初由MIT Laboratory for Computer Science和RSA Data Secur ...