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. ActiveMQ学习笔记(5)----Broker的启动方式

    Broker:相当于一个ActiveMQ服务器实例,在实际的开发中我们可以启动多个Broker. 命令行启动参数示例如下: 1. activemq start 使用默认的activemq.xml来启动 ...

  2. pandaboy玩pandas

    基于python的三方库pandas的excel表二次开发 import numpy as np import pandas as pd import time from pandas import ...

  3. js的onclick和jq的click以及on和bind的区别

    onclick和click,只能静态绑定点击事件:bind的可以一次绑定多个事件(click/onmouseover等):on可以动态的绑定事件,当页面加载完成调用on即可

  4. MVC 单元测试xUnit初探

    对于.NET项目 Web Api的业务逻辑后台开发[特别是做Web Api接口]而言,编写单元测试用例,会极大的减轻代码帮助与运行的方式.然而使用测试框架,相对于自带的,我更加推荐是用xUnit.ne ...

  5. 影像服务——加载CESIUM自带的影像服务

    1.加载arcgis数据——ArcGisMapServerImageryProvider var viewer = new Cesium.Viewer("cesiumDiv",{ ...

  6. fwupdate-efi 与 grub2-common 冲突

    在CentOS-7Minimal系统中使用命令如下命令yum groupinstall -y "GNOME Desktop"安装 图形界面时提示:fwupdate-efi 与 gr ...

  7. 越努力越幸运--动态数组vector

    最近回忆山哥写的stl,觉得很好用,也写了一份. 感谢群里的大佬帮忙review,还是很多的问题的. code:https://github.com/HellsingAshen/vector_c.gi ...

  8. 每一个人都懂得敏捷开发 (软件project), 为何产品开发的效率与质量还是这么的烂?

    敏捷开发(软件project)是 "设计" 出来的.不是 "学" 来的-- 很多人都一直在质疑敏捷开发能否提高效率与质量? 更有不少人以嘲讽.不屑的口吻看待软件 ...

  9. Android Camera+SurfaceView实现自己定义拍照

    对Activity强制横屏,保证预览方向正确. 使用OrientationEventListener监听设备方向.推断竖拍时,旋转照片后再保存.保证竖拍时预览图片和保存后的图片方向一致. 执行效果: ...

  10. 51nod-1310: Chandrima and XOR

    [传送门:51nod-1310] 简要题意: 有一个数组S,保证里面的数是从小到大的,而且每一个数的二进制中都没有连续的1,如:1,2,4,5,8... 给出n,然后给出n个位置,求出S数组中n个位置 ...