Skip to content

Instantly share code, notes, and snippets.

@stucchio
Last active October 20, 2019 01:00
Show Gist options
  • Save stucchio/8849009f02830724f5591a9c83730795 to your computer and use it in GitHub Desktop.
Save stucchio/8849009f02830724f5591a9c83730795 to your computer and use it in GitHub Desktop.
How to compute the valuation of a cash flow in the presence of a wealth tax.
import numpy as np
from numpy.linalg import solve
def vmat(n, discount_rate, tax_rate):
m = np.zeros(shape=(n,n))
discount = tax_rate*np.exp(-1*discount_rate*np.arange(n))
for i in range(n):
m[i, i:n] = discount[0:n-i]
m[i,i] = 1
return m
def remaining_cashflow(cash_flow, discount_rate):
_discount = np.exp(-1*discount_rate*np.arange(len(cash_flow)))
return np.convolve(cash_flow, _discount[::-1])[len(cash_flow)-1:]
def valuation(cash_flow, discount_rate, tax_rate):
"""
Returns the valuation of a cash flow, as well as the current NPV of a cash flow, for a given cash flow sequence given as input.
"""
return solve(vmat(len(cash_flow), discount_rate, tax_rate), remaining_cash_flow(cash_flow, discount_rate))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment