Created
November 9, 2021 02:12
-
-
Save JohannSuarez/ef199111477dadf53d00d7c9237caa47 to your computer and use it in GitHub Desktop.
Incrementing Continuous Compound Interest
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
''' | |
Suppose I spend $20,000 on a mining rig, and it mines $120 worth of crypto each day. | |
We then consistently stake its daily revenue into a yield farming platform at a rate of 12% per year, | |
with the yield immediately claimed and restaked. | |
How much money would we make after n days? | |
At what day do we break even? (Assuming we're not paying for maintenance or electric bill) | |
''' | |
from typing import List | |
import pandas as pd | |
def incremental_continuous_compound(daily_mine_revenue: float, days_elapsed: int): | |
''' | |
Each day I get daily_mine_revenue and | |
I stake it to a pool at 12% per annum. | |
''' | |
interest_rate: float = 0.12 # 12 percent | |
compound_frequency: int = 365 # number of times interest applied per time period per annum (so that's daily) | |
balance: float = 0 # This is supposed to be the principal, but we add to it daily. | |
pure_yield_profit: float = 0 # Amount earned solely from the yield farming activity | |
# These lists will be ever-expanding. | |
pure_yield_profit_log: List[float] = [] | |
staking_yield_by_day: List[float] = [] | |
total_balance_log: List[float] = [] | |
for i in range(days_elapsed): | |
day_yield = balance * ( interest_rate / compound_frequency) | |
pure_yield_profit += day_yield | |
balance += daily_mine_revenue + day_yield | |
# Building the dataframe columns | |
pure_yield_profit_log.append(pure_yield_profit) | |
staking_yield_by_day.append(day_yield) | |
total_balance_log.append(balance) | |
return pd.DataFrame(zip(pure_yield_profit_log, | |
staking_yield_by_day, | |
total_balance_log), | |
columns=['Yield Profit Total', 'Yield Amount of The Day', 'Total Profit']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment