[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 ...
随机推荐
- Python笔记(2)
Python 一些常用的运算符: 1.算术运算符:+(加).-(减).*(乘)./(除).//(取整).%(取余).**(乘方): 2.比较运算符:>(大于).<(小于).>=(大于 ...
- rpm方式在centos7中安装mysql
.安装MySQL server 首先下载好mysql的rpm安装包 使用rpm命令安装: rpm -ivh MySQL-server--.glibc23.i386.rpm #rpm -ivh MySQ ...
- POJ2142 The Balance (扩展欧几里德)
本文为博主原创文章,欢迎转载,请注明出处 www.cnblogs.com/yangyaojia The Balance 题目大意 你有一个天平(天平左右两边都可以放砝码)与重量为a,b(1<= ...
- javaWeb web.xml 配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http:// ...
- 怎样用批处理来执行多个exe文件
怎样用批处理来运行多个exe文件 @echo off start *****.exe start *****.exe start *****.exe start *****.exe 接着我们就能够运行 ...
- hdu1213 How Many Tables(并查集)
How Many Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdoj--4325--Flowers(线段树+二分)
Flowers Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- git相关整理
title: git相关整理 toc: false date: 2018-09-24 20:42:55 git merge 和 git merge --no--ff有什么区别? git merge命令 ...
- POJ 3261 后缀数组+二分
思路: 论文题- 二分+对后缀分组 这块一开始不用基数排序 会更快的(其实区别不大) //By SiriusRen #include <cstdio> #include <cstri ...
- SPSS学习小记
2013年1月8日 最近一直在SPSS中处理数据,涉及到函数部分,不是太懂,特记录于此,以便翻阅. SPSS判断字符变量中是否含有某字符串的表示方式: (INDEX(url,'ad')>0 ...