Skip to content

Instantly share code, notes, and snippets.

View ItsShadowl's full-sized avatar
🎯
Focusing

Hey Yo! ItsShadowl

🎯
Focusing
View GitHub Profile
@sterlu
sterlu / Savings APR-APY conversion.js
Created February 24, 2020 14:54
Convert between APR & APY yearly returns
const SECONDS_PER_YEAR = 365.25 * 24 * 60 * 60;
const BLOCKS_IN_A_YEAR = SECONDS_PER_YEAR / 14;
/**
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
*
* @param interest {Number} APY as percentage (ie. 6)
* @param frequency {Number} Compounding frequency (times a year)
* @returns {Number} APR as percentage (ie. 5.82 for APY of 6%)
*/