Get Crypto Coins Wallet Worth PowerShell

Get Crypto Coins Wallet Worth PowerShell


Today a quick followup post of my previous one about BitCoin and its price. I improved it to get a overview of your wallet worth if you have multiple of them on different platforms.

Get Crypto Coins Wallet Worth PowerShell

Some trading platform provide an overview of the wallet you own there, but not global overview of all of your wallets. I wrote a simple function that allows you to keep track of your “investments” in cryptocoins:

Function Get-WalletWorth{
        [String]$RefCurency = 'EUR' #USD,EUR
    $ApiUrl = ''
    $Wallet= @'
'@ | ConvertFrom-Csv -Delimiter ';'
    $PreContent = @'
    table {
        border-collapse: collapse;
    h2 {text-align:center}
    th, td {
        padding: 8px;
        text-align: left;
        border-bottom: 1px solid #ddd;
    <h1>Crypto Coin Dashboard</h1>
    if($RefCurency -eq 'USD'){
        $CurrencyFormat = New-Object System.Globalization.CultureInfo('en-US')
        $ExpandProperty = 'price_usd'
    elseif($RefCurency -eq 'EUR'){
        $CurrencyFormat = New-Object System.Globalization.CultureInfo('fr-FR')
        $ExpandProperty = 'price_eur'
    $WalletWorthTable = $Wallet | ForEach-Object -Begin {$TotalValue=0;$TotalInvested=0} -Process {
        $CurrentValue = ((Invoke-WebRequest -Uri "$($ApiUrl)$($_.Name)/?convert=$RefCurency" | Select-Object -ExpandProperty Content | ConvertFrom-Json) | Select-Object -ExpandProperty $ExpandProperty) -as [double]
        New-Object -TypeName PSObject -Property @{
            Currency             = $_.Name
            "PriceIn$RefCurency" = $CurrentValue.ToString('c',$CurrencyFormat)
            ValueInWallet        = ($CurrentValue * $_.Amount).ToString('c',$CurrencyFormat)
            Amount               = $_.Amount
            Performance          = "{0:P}" -f ((($CurrentValue * $_.Amount)-$_.Invested)/$_.Invested)
            Invested             = ([double]$_.Invested).ToString('c',$CurrencyFormat)

        $TotalValue += ($CurrentValue * $_.Amount)
        $TotalInvested += $_.Invested

        $CurrentValue = $null
    $PostContent = @"
Total Invested: $($TotalInvested.ToString('c',$CurrencyFormat))
Total Value: $($TotalValue.ToString('c',$CurrencyFormat))
Total Performance: $("{0:P}" -f (($TotalValue-$TotalInvested)/$TotalInvested))
Last Refresh: $(Get-Date)
    $WalletWorthTable | ConvertTo-Html -PreContent $PreContent -PostContent $PostContent -Title 'Crypto Coin Dashboard' | Out-File -FilePath $env:temp\wallet.htm
    #Open the report
    Invoke-Item -Path $env:temp\wallet.htm

Once you run it, it will open the html report with your default web browser:

Get Crypto Coins Wallet Worth PowerShell - Example

Get Crypto Coins Wallet Worth PowerShell – Example

All the performances and value calculation are based on the herestring $Wallet defined at the beginning of the function.

You need to feed it with the name of the crypto currency you own, the amount you have, and the price you paid to acquire it. Based on this, the function will ask CoinMarketCap to get the current value and calculate your benefits. When you call the function, you need to specify if you paid in € or $ (defaulted to €), and it will adapt the calculation.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.