Created
August 26, 2019 15:03
-
-
Save amandadebler/1f8e56c9d208c1e33af80a370f61750b to your computer and use it in GitHub Desktop.
The robo-advisor in PowerShell that no one asked for
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
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