Skip to content

Instantly share code, notes, and snippets.

@mrecachinas
Last active November 28, 2016 22:02
Show Gist options
  • Save mrecachinas/372b5e4c7969e728f24991897c022480 to your computer and use it in GitHub Desktop.
Save mrecachinas/372b5e4c7969e728f24991897c022480 to your computer and use it in GitHub Desktop.
Comparison of Trump's Tax Plan vs Current Tax Plan (with 0 deductions)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim:sw=4:sts=4:et
import math
import locale
def calc_taxes(annual_salary, plan, filing):
filing_plan = plan[filing]
taxes = 0
for salary_range in filing_plan:
range_min, range_max = salary_range
if annual_salary > range_max:
taxes += (range_max - range_min) * filing_plan[salary_range]
elif range_min < annual_salary <= range_max:
taxes += (annual_salary - range_min) * filing_plan[salary_range]
return taxes, annual_salary - taxes
def trump(annual_salary, filing):
plan = {
"single": {
(0, 37500): 0.12,
(37500, 112500): 0.25,
(112500, float('inf')): 0.33,
},
"married_filing_jointly": {
(0, 75000): 0.12,
(75000, 225000): 0.25,
(225000, float('inf')): 0.33,
},
}
return calc_taxes(annual_salary, plan, filing)
def current(annual_salary, filing):
plan = {
"single": {
(0, 9275): 0.10,
(9275, 37650): 0.15,
(37650, 91150): 0.25,
(91150, 190150): 0.28,
(190150, 413350): 0.33,
(413350, 415050): 0.35,
(415050, float('inf')): 0.4,
},
"married_filing_jointly": {
(0, 18550): 0.10,
(18550, 75300): 0.15,
(75300, 151900): 0.25,
(151900, 231450): 0.28,
(231450, 413350): 0.33,
(413350, 466950): 0.35,
(466950, float('inf')): 0.4,
},
}
return calc_taxes(annual_salary, plan, filing)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("annual_salary",
type=int,
help="annual salary in USD")
parser.add_argument("-f", "--filing",
choices=("single", "married_filing_jointly"),
help="how you're filing (either single or married_filing_jointly)",
required=True)
parser.add_argument("-c", "--currency",
choices=("USD",),
help="Currency (only USD is supported)")
args = parser.parse_args()
locale.setlocale(locale.LC_ALL, "")
trump_tax, trump_after = trump(args.annual_salary, args.filing)
current_tax, current_after = current(args.annual_salary, args.filing)
diff_cost = trump_after - current_after
diff = diff_cost / current_after
verb = "save" if diff > 0 else "cost"
print u"Given an annual salary of {annual_salary} and filing status of \"{filing}\":".format(
annual_salary=locale.currency(args.annual_salary),
filing=args.filing,
)
print u"➜ In the current tax plan, after tax, you net {current_after_tax}.".format(
current_after_tax=locale.currency(current_after),
)
print u"➜ In Trump's tax plan, after tax, you net {current_after_tax}.".format(
current_after_tax=locale.currency(trump_after),
)
print u"➜ Trump's proposal will {verb} you {diff_cost} ({diff:.3}%) in taxes".format(
verb=verb,
diff_cost=locale.currency(abs(diff_cost)),
diff=abs(diff),
)
#!/usr/bin/env python
# vim:sw=4:sts=4:et
import tax
import matplotlib.pyplot as plt
def plot(lower, upper, skip, filing):
delta = []
x = range(lower, upper, skip)
for i in x:
single_trump_tax, single_trump_after = tax.trump(i, filing)
single_current_tax, single_current_after = tax.current(i, filing)
delta_tax, delta_after = single_trump_tax - single_current_tax, single_trump_after - single_current_after
delta.append(delta_tax)
plt.plot(x, delta)
plt.xlabel('Taxable Income (USD)')
plt.ylabel('Difference between Trump\'s plan and the current')
plt.grid('on')
plt.show()
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--lower", type=int, default=0)
parser.add_argument("--upper", type=int, default=1000000)
parser.add_argument("--skip", type=int, default=10000)
parser.add_argument("--filing", default="single", choices=("single", "married_filing_jointly"))
args = parser.parse_args()
plot(args.lower, args.upper, args.skip, args.filing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment