Skip to content

Instantly share code, notes, and snippets.

@TechDufus
Last active December 21, 2021 20:31
Show Gist options
  • Save TechDufus/f54fd10141b6fd7e0e60a297e09ef432 to your computer and use it in GitHub Desktop.
Save TechDufus/f54fd10141b6fd7e0e60a297e09ef432 to your computer and use it in GitHub Desktop.
Basic LVT Profit Compound Calculator

Hello!

I spent a minute creating this VERY BASIC LVT Compounding calculator.

This is written in PowerShell, which is installed on all Windows computers by default (Search: Windows PowerShell)

The most convienient way to use this function is to add this function to your PowerShell Profile, which is basically a script that runs everytime you launch PowerShell. Any customization or special things you want loaded (like this function) will be available to you at all times.

Locate your Profile

In PowerShell, type $profile and it will give you a file path. This PROBABLY doesn't exist, but you can easily create this .ps1 file in the exact place shown

NOTE: My favorite profile to use is $profile.CurrentUserAllHosts, but that's just preference.

Add Function to Profile

Then all you need to do is simply add the Get-LVTCompoundInterest function code into this .ps1 file, save, and re-open PowerShell. You will then be able to call this function whenever and however you'd like.

FAQ

Any errors you come across trying to set this up, please google, or reach out. Or google. :)

<#
.SYNOPSIS
Quickly calculate your compounding profits for LVT.
.DESCRIPTION
This function will show you an esitmate profit amount based on the values you provide.
This function currently does not get a live reading of the current LVT price, you will need to manually provide the current price yourself.
.PARAMETER LVT
Provide the amount of LVT in your portfolio that is generating interest.
.PARAMETER Days
Provide the number of days you are investing in LVT.
This will caluclate the amount of LVT you will have after the number of days you have provided.
.PARAMETER CurrentPrice
Provide the current price of LVT, or at least the price you want to see data for.
.PARAMETER IncludeChart
If you want to see a chart of the results, provide this parameter. This will display each day's profit in a chart.
.PARAMETER Rate
Provide the interest rate you would like to see data for.
This defaults to LVT's current default rate of 7% daily.
.EXAMPLE
Get-LVTCompoundInterest -LVT 10000 -Days 30 -CurrentPrice .025 -IncludeChart
Description
-----------
This will show you an estimate of how much LVT you will have in your portfolio after 30 days.
Since -IncludeChart is provided, this will also show you a chart of the results.
.EXAMPLE
Get-LVTCompoundInterest -LVT 10000 -Days 30 -CurrentPrice .025 -Rate .1
Description
-----------
This will show you an estimate of how much LVT you will have in your portfolio after 30 days.
Since -IncludeChart is not provided, this will not show you a chart of the results. but will only show you stats for the final day.
.NOTES
Author: Matthew DeGarmo
GitHub: https://github.com/matthewjdegarmo
Sponsor: https://github.com/sponsors/matthewjdegarmo
#>
Function Get-LVTCompoundInterest() {
[CmdletBinding()]
Param(
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
$LVT,
[Parameter()]
$Days = 1,
[Switch]$IncludeChart,
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
$CurrentPrice,
$CurrentBonusPercent,
[ValidateRange(0, 6)]
$CompoundsPerDay = 6
)
Begin {
#Region Get-APICurrentPrice
Function Get-APICurrentPrice() {
[CmdletBinding()]
Param()
#Placeholder function for realtime api price call
}
#EndRegion Get-APICurrentPrice
#Region Get-BonusPercentIncrease
Function Get-BonusPercentIncrease() {
[CmdletBinding()]
Param(
$Rate
)
[decimal]$CurrentBonus = [math]::Round(($Rate - 0.07), 6)
Switch ($CurrentBonus) {
# its the % bonus of 7 + 7 e.g. 40% of 7 is 2.8 + 7% = 9.8% on omega tier.
#1-5% increases by 1%
{ $_ -ge 0 -AND $_ -le 0.0035 } { [decimal]$BonusIncrease = .001 }
#5-10% increases by 0.5%
{ $_ -gt 0.0035 -AND $_ -le 0.007 } { [decimal]$BonusIncrease = .0005 }
#10-20% increases by 0.1%
{ $_ -gt 0.007 -AND $_ -le 0.014 } { [decimal]$BonusIncrease = .0001 }
#20-30% increases by 0.05%
{ $_ -gt 0.014 -AND $_ -le 0.021 } { [decimal]$BonusIncrease = .00005 }
#30-40% increases by 0.01%
{ $_ -gt 0.021 -AND $_ -lt 0.028 } { [decimal]$BonusIncrease = .00001 }
#If someone reaches limit, OR some value is weird, 0% will be added.
DEFAULT { [decimal]$BonusIncrease = 0 }
}
Write-Verbose "Bonus Increase: $BonusIncrease | Current Bonus: $CurrentBonus | Rate: $Rate | New Rate: $([decimal]$Rate + [decimal]$BonusIncrease)"
[decimal]$Rate + [decimal]$BonusIncrease
}
#EndRegion Get-BonusPercentIncrease
#Region Variable Setup
$BaseRate = 0.07
$Rate = 0.07
If ($CurrentBonusPercent) {
If ($CurrentBonusPercent -ge 1) {
Write-Host "$CurrentBonusPercent greater than 1"
$Rate = $Rate + ($CurrentBonusPercent / 1000)
Write-Host "New Rate: $Rate"
} Else {
$Rate = $Rate + $CurrentBonusPercent
}
}
#EndRegion Variable Setup
}
Process {
If ($IncludeChart.IsPresent) {
# Loop through days
For ($i = 1; $i -le $Days; $i++) {
For ($r = 1; $r -le $CompoundsPerDay; $r++) {
$Rate = (Get-BonusPercentIncrease -Rate $Rate)
$CompoundStart++
}
$Increase = ($LVT * $Rate)
$IncreaseUSD = "{0:c}" -f ($Increase * $CurrentPrice)
If ($CompoundsPerDay -ne 0) {
$LVT = $Increase + $LVT
}
$USD = "{0:c}" -f ($LVT * $CurrentPrice)
$Day = $i
$30DayProfit = "{0:c}" -f (($LVT * $BaseRate * $CurrentPrice) * 30)
$FormattedRate = [math]::Round(($Rate * 100), 4)
$FormattedIncrease = [math]::Round($Increase, 0)
[PSCustomObject]@{
LVT = [math]::round($LVT, 0)
CurrentPrice = [math]::round($CurrentPrice, 5)
TotalUSD = $USD
DailyUSD = "{0:c}" -f $IncreaseUSD
DailyLVT = $FormattedIncrease
'30DayProfit' = $30DayProfit
Day = $Day
Rate = "$FormattedRate`%"
}
}
}
Else {
For ($i = 1; $i -le $Days; $i++) {
For ($r = 1; $r -le $CompoundsPerDay; $r++) {
$Rate = (Get-BonusPercentIncrease -Rate $Rate)
$CompoundStart++
}
$Increase = ($LVT * $Rate)
$IncreaseUSD = "{0:c}" -f ($Increase * $CurrentPrice)
If ($CompoundsPerDay -ne 0) {
$LVT = $Increase + $LVT
}
}
$USD = "{0:c}" -f ($LVT * $CurrentPrice)
$Day = $i
$30DayProfit = "{0:c}" -f (($LVT * $BaseRate * $CurrentPrice) * 30)
$FormattedRate = [math]::Round(($Rate * 100), 4)
$FormattedIncrease = [math]::Round($Increase, 0)
[PSCustomObject]@{
LVT = [math]::round($LVT, 0)
CurrentPrice = [math]::round($CurrentPrice, 5)
TotalUSD = $USD
DailyUSD = "{0:c}" -f $IncreaseUSD
DailyLVT = $FormattedIncrease
'30DayProfit' = $30DayProfit
Day = $Day
Rate = "$FormattedRate`%"
}
}
}
End {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment