Posts

Showing posts from December 16, 2018

Moderate return-low risk vs high returns-high risk investments

Image
up vote 0 down vote favorite To quantify Buffet's #1 rule of investing, "Don't lose money", I take the assumption that % returns of an investment follow a Normal distribution. Now a high return high risk investment might follow N(mu=50%, sigma=70%) while low return low risk investment follow N(mu=20%, sigma=10%). from operator import mul from functools import reduce from random import gauss from statistics import median from typing import List def avg_cagr(percents: List[int]) -> float: '''Given (successive) % annual growth rates, returns average Compound Annual Growth Rate''' amount = reduce(mul, [1+p/100 for p in percents]) amount = amount if amount > 0 else 0 # at worst, complete amount can be lost but can't go negative return (amoun...

Promises & TypeScript

Image
up vote 1 down vote favorite I have a method that I must implement through an abstract class, which has a signature like this: isAuthenticated(path: string): boolean In the implementation I'm calling a promise from an authorization server isAuthenticated(path: string): boolean { this.authorization.isAuthenticated().then((res) => { if(res == true) { return true; } return false; }); } But the method gives me a error/warning like this: A function whose type is neither declared type is neither 'void' nor 'any' must return a value typescript promise angular6 share | improve this question asked Nov 20 at 14:57 ...