Skip to content

Instantly share code, notes, and snippets.

@amandadebler
Created August 26, 2019 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandadebler/1f8e56c9d208c1e33af80a370f61750b to your computer and use it in GitHub Desktop.
Save amandadebler/1f8e56c9d208c1e33af80a370f61750b to your computer and use it in GitHub Desktop.
The robo-advisor in PowerShell that no one asked for
function Get-Portfolio {
[CmdletBinding()]
param (
$amount,
$transactionCost = 5,
$maxCostRatio = 0.02
)
begin {
}
process {
if ($stocks -eq $null) {
Get-SP500Summary
}
foreach ($stock in $stocks) {
$purchase = Get-SharesInAmount -stock $stock -amount $amount -transactionCost $transactionCost -maxCostRatio $maxCostRatio
if ($purchase.Shares -gt 0) {
$purchase
}
}
}
end {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment