Skip to content

Instantly share code, notes, and snippets.

@peterfabakker
peterfabakker / welford.py
Created March 12, 2018 06:53 — forked from hamx0r/welford.py
Python Welford Algorithm
import math
class Welford(object):
""" Implements Welford's algorithm for computing a running mean
and standard deviation as described at:
http://www.johndcook.com/standard_deviation.html
can take single values or iterables
Properties:
mean - returns the mean
@peterfabakker
peterfabakker / RiskAdjustedReturnMetrics.py
Last active June 30, 2017 01:43 — forked from StuartGordonReid/RiskAdjustedReturnMetrics.py
Measured of Risk-adjusted Return
import math
import numpy
import numpy.random as nrand
"""
Note - for some of the metrics the absolute value is returns. This is because if the risk (loss) is higher we want to
discount the expected excess return from the portfolio by a higher amount. Therefore risk should be positive.
"""