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. QNX多线程同步之Barrier(屏障)

    之前和大家介绍过QNX上的线程同步方法metux和semophore,通过这两种方法可以对一个或者几个资源进行加锁,避免资源使用上的冲突.在另一种情况下,某个线程需要在其它线程完成工作后才继续执行,这 ...

  2. 优动漫PAINT-草地教程

    非常实用的草地教程,是场景控们绝对要学会的绘画技巧~更有配套草地笔刷~让场景绘画更简易~ 教程是简单,呃.... 没有优动漫PAINT软件肿么办? 别着急,╭(╯^╰)╮ 小编给你送来了 齐全的哟? ...

  3. HDU 2196 Computer(经典树形DP)

    题意自己看(猜) 题解 这题很经典,就是记录dp[i][0/1/2]分别代表,从i点向下最大和次大深度,和向上最大深度. 然后转移就行了. 我的写法可能太丑了.死活调不出来,写了一个漂亮的 #incl ...

  4. springboot --> web 应用开发-CORS 支持

    一.Web 开发经常会遇到跨域问题,解决方案有:jsonp,iframe,CORS 等等 CORS 与 JSONP 相比 1. JSONP 只能实现 GET 请求,而 CORS 支持所有类型的 HTT ...

  5. salt 安装kubernetes集群3节点

    [root@linux-node1 k8s]# tree .├── etcd.sls├── files│   ├── cfssl-1.2│   │   ├── cfssl-certinfo_linux ...

  6. php7 memcache和memcached.so扩展

    php7安装memcache和memcached扩展 https://github.com/websupport-sk/pecl-memcache https://github.com/php-mem ...

  7. docker mysql 文件挂载和MySQL字符集设置

    原文:docker mysql 文件挂载和MySQL字符集设置 docker run -p 3306:3306 --name mysql -v /usr/local/mysql/my.cnf:/etc ...

  8. How to enable wire logging for a java HttpURLConnection traffic?

    https://stackoverflow.com/questions/1445919/how-to-enable-wire-logging-for-a-java-httpurlconnection- ...

  9. Tomcat连HBase报错: HTTP Status 500 - java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext

    Tomcat中连接HBase数据库,启动的时候报错: HTTP Status 500 - java.lang.AbstractMethodError: javax.servlet.jsp.JspFac ...

  10. CG 内置函数 和 HLSL 内置函数

    CG 内置函数  英伟达官网链接: http://http.developer.nvidia.com/Cg/index_stdlib.html absacosallanyasinatan2atanbi ...