[ML] Daily Portfolio Statistics
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
- Normalize the price by devide price of first day.
- Nored * allocation
- * starting value
- 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的更多相关文章
- 一篇文章看懂spark 1.3+各版本特性
Spark 1.6.x的新特性Spark-1.6是Spark-2.0之前的最后一个版本.主要是三个大方面的改进:性能提升,新的 Dataset API 和数据科学功能的扩展.这是社区开发非常重要的一个 ...
- Scoring and Modeling—— Underwriting and Loan Approval Process
https://www.fdic.gov/regulations/examinations/credit_card/ch8.html Types of Scoring FICO Scores V ...
- Stanford机器学习笔记-3.Bayesian statistics and Regularization
3. Bayesian statistics and Regularization Content 3. Bayesian statistics and Regularization. 3.1 Und ...
- FAQ: Automatic Statistics Collection (文档 ID 1233203.1)
In this Document Purpose Questions and Answers What kind of statistics do the Automated tasks ...
- 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 ...
- ML笔记_机器学习基石01
1 定义 机器学习 (Machine Learning):improving some performance measure with experience computed from data ...
- Spark ML 几种 归一化(规范化)方法总结
规范化,有关之前都是用 python写的, 偶然要用scala 进行写, 看到这位大神写的, 那个网页也不错,那个连接图做的还蛮不错的,那天也将自己的博客弄一下那个插件. 本文来源 原文地址:htt ...
- 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 ...
- [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 ...
随机推荐
- Linux系统_Ubuntu中Hadoop常用命令
ctrl+alt+t打开终端窗口sudo useradd -m hadoop -s/bin/bash创建新用户ctrl+alt回到自己的笔记本 创建hadoop用户sudo useradd -m ha ...
- 小学生都能学会的python(深浅拷贝)
小学生都能学会的python(深浅拷贝) join() 把列表中的每一项用字符串拼接起来 # lst = ["汪峰", "吴君如", "李嘉欣&quo ...
- Virtual Box 新建一个虚拟机安装系统(补充:WIN7 64 bit 系统虚拟机无法安装 64 bit 系统问题)
1.安装Virtual Box好后,点击新建 2.配置内存大小,这个根据自己需要配置就好 3.创建虚拟硬盘 这里选择固定分配.动态分配都可以,接下来就分配硬盘大小了 4.新建好后我们点击刚才建立的虚拟 ...
- 随心所欲生成git仓库随意一段commit的专用patch应用小实践
随心所欲生成git仓库随意一段commit的专用patch应用小实践 我们在开发中.时不时的可能要去做一个patch给你的下线,或者你的合作者.在git管理中,我们知道有git format-pat ...
- Android高级控件(一)——ListView绑定CheckBox实现全选,添加和删除等功能
Android高级控件(一)--ListView绑定CheckBox实现全选,添加和删除等功能 这个控件还是挺复杂的.也是项目中应该算是比較经常使用的了,所以写了一个小Demo来讲讲,主要是自己定义a ...
- CSS3可伸缩框属性,可用于等分显示子元素或按比例显示子元素的大小
使用方法跟Android的android:layout_weight属性类似.可类比Android中的使用方法.这样比較好记,因为眼下全部浏览器都不支持大部分的属性,所以全部的属性都须要加上Firef ...
- android 极细线
最后找到一个还算好用的方法:伪类 + transform 原理是把原先元素的 border 去掉,然后利用:before或者:after重做 border ,并 transform 的 scale 缩 ...
- 修改YOLO使其显示自定义类别
基本参考自这篇文章(http://blog.csdn.net/ma3252788/article/details/74659230),主要用来记录下自己遇到的问题 根据@赤战约风 的帖子做如下修改可以 ...
- bzoj3442: 学习小组(费用流好题)
3442: 学习小组 题目:传送门 题解: 超级好题啊大佬们的神题!建图肥肠灵性!感觉自己是星际玩家... 首先呢st直接向每个人连边,容量为min(k,喜欢的小组个数),费用为0 然后每个人再向ed ...
- Redis-3-string类型
Redis-3-string类型 标签(空格分隔): redis set key value [ex 秒数] / [px 毫秒数] [nx] /[xx] mset key value key valu ...