Let's you have $10000, and you inverst 4 stocks. ['SPY', 'IBM', 'XOM', 'GOOG']. The allocation is [0.4, 0.4, 0.1, 0.1] separately.

The way to calculate the daily porfolio is

  1. Normalize the price by devide price of first day.
  2. Nored * allocation
  3. * starting value
  4. Sum up each row

After we can port value, the first thing we can calculate is the daily return.

The important thing to remember that the first value of daily return is alwasy zero, so we need to remove the first value.

daily_rets = daily_rets[1:]

Four statics:

1. Cumulative return:

  Is a just a measure of how much the value of the portfolio has go up from the beginning to the end.

cum_ret = (port_val[-] / port_val[]) -

2. Average daily return:

  The mean value of daily return

avg_daily_ret = daily_rets.mean()

3. Standard deviation of odaily return:

std_daily_ret = daily_rets.std()

4. Sharp ratio:

  The idea for sharp ratio is to consider our return, or rewards in the context of risk.

  All else being equal:

    Lower risk is better

    Higher return is better

  Also considers risk free rate of return, nowadays, risk free return is almost 0. (Put menoy into the bank has very low interests)

Both stocks have similar volatility, so ABC is better due greater returns.

Here both stocks have similar returns, but XYZ has lower volatility (risk).

In this case, we actually do not have a clear picture of which stock is better!

Calculate Shape ratio:

Risk free value can be replace by:

1. LIBOR

2. 3mo T-Bill

3. 0%

Because risk free is so small, noramlly we can just drop it when calculate the sharp raito.

IF we calcualte daily shape ratio: use K = srq(252), monly then srq(12)

[ML] Daily Portfolio Statistics的更多相关文章

  1. 一篇文章看懂spark 1.3+各版本特性

    Spark 1.6.x的新特性Spark-1.6是Spark-2.0之前的最后一个版本.主要是三个大方面的改进:性能提升,新的 Dataset API 和数据科学功能的扩展.这是社区开发非常重要的一个 ...

  2. Scoring and Modeling—— Underwriting and Loan Approval Process

    https://www.fdic.gov/regulations/examinations/credit_card/ch8.html Types of Scoring FICO Scores    V ...

  3. Stanford机器学习笔记-3.Bayesian statistics and Regularization

    3. Bayesian statistics and Regularization Content 3. Bayesian statistics and Regularization. 3.1 Und ...

  4. FAQ: Automatic Statistics Collection (文档 ID 1233203.1)

    In this Document   Purpose   Questions and Answers   What kind of statistics do the Automated tasks ...

  5. oracle internal: VIEW: X$KCBKPFS - PreFetch Statistics - (9.0)

    WebIV:View NOTE:159898.1     Note (Sure) - Note    Mods - Note Refs Error ORA 600 TAR TAR-Info Bug B ...

  6. ML笔记_机器学习基石01

    1  定义 机器学习 (Machine Learning):improving some performance measure with experience computed from data ...

  7. Spark ML 几种 归一化(规范化)方法总结

    规范化,有关之前都是用 python写的,  偶然要用scala 进行写, 看到这位大神写的, 那个网页也不错,那个连接图做的还蛮不错的,那天也将自己的博客弄一下那个插件. 本文来源 原文地址:htt ...

  8. Google's Machine Learning Crash Course #01# Introducing ML & Framing & Fundamental terminology

    INDEX Introducing ML Framing Fundamental machine learning terminology Introducing ML What you learn ...

  9. [ML] I'm back for Machine Learning

    Hi, Long time no see. Briefly, I plan to step into this new area, data analysis. In the past few yea ...

随机推荐

  1. Shell(五)Shell输入/输出重定向

    Shell 输入/输出重定向 大多数 UNIX 系统命令从你的终端接受输入并将所产生的输出发送回​​到您的终端.一个命令通常从一个叫标准输入的地方读取输入,默认情况下,这恰好是你的终端.同样,一个命令 ...

  2. STM32 软件模拟 IIC 代码,标准库、HAL库可用

    #ifndef _IIC_H #define _IIC_H #include "stdio.h" #include "stm32f1xx_hal.h" /* 定 ...

  3. 【Codeforces Round #476 (Div. 2) [Thanks, Telegram!] E】Short Code

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 先建立一棵字典树. 显然,某一些节点上会被打上标记. 问题就转化成求所有标记的深度的和的最小值了. (标记可以上移,但是不能在同一位 ...

  4. SVN学习总结(1)——SVN简介及入门使用

    SVN简介:  为什么要使用SVN?       程序员在编写程序的过程中,每个程序员都会生成很多不同的版本,这就需要程序员有效的管理代码,在需要的时候可以迅速,准确取出相应的版本. Subversi ...

  5. spring boot约定优于配置的这种做法在如今越来越流行了

    约定优于配置的这种做法在如今越来越流行了,它的特点是简单.快速.便捷.但是这是建立在程序员熟悉这些约定的前提上.而 Spring 拥有一个庞大的生态体系,刚开始转到 Spring Boot 完全舍弃 ...

  6. 今天修了一个bug,关于debug日志的问题

    是别人的代码,很诡异. 就是开了debug日志,没问题. 关了debug日志,就出问题. 开始我以为是debug日志拖慢了速度,所以有一些竞态环境的影响. 后来发现是在debug日志里面有一些side ...

  7. Java String内存释放

    Java String内存释放 这是一个坑,Java对于String对象,不进行内存的回收: 处理大数据量的时候,少用String. 与JDK有关系:jdk1.6环境下,内存只占用10M,jdk1.8 ...

  8. BCB使用线程删除目录中的图片

    BCB新建线程DeleteImgThread类.其会默认继承Thread类,然后在Execute函数中编写代码, void __fastcall DeleteImgThread::Execute() ...

  9. PostgreSQL hstore 列性能提升一例

    PostgreSQL 支持hstore 来存放KEY->VALUE这类数据, 事实上也相似于ARRAY或者JSON类型.  要高效的使用这类数据,当然离不开高效的索引.我们今天就来看看两类不同的 ...

  10. Windows身份验证和混合验证的差别

    两个验证方式的不同主要集中在信任连接和非信任连接.         windows 身份验证相对于混合模式更加安全,使用本连接模式时候,sql不推断sapassword.而仅依据用户的windows权 ...