Created
April 25, 2020 03:46
-
-
Save dmtucker/89bb3db5fbc8e8cdc8b89d5e15eddaa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def apy(apr, periods=12): | |
return (((apr / periods) + 1) ** periods) - 1 | |
def apr(apy, periods=12): | |
return (((apy + 1) ** (1 / periods)) - 1) * periods | |
apr_before = 0.12 | |
apr_after = apr(apy=apy(apr=apr_before)) | |
assert apr_after == apr_before, (apr_before, apr_after) | |
apy_before = 0.12 | |
apy_after = apy(apr=apr(apy=apy_before)) | |
assert apy_after == apy_before, (apy_before, apy_after) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment