mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-31 15:35:39 +02:00
Updated list-crypto-rates.ps1
This commit is contained in:
parent
f896e880a3
commit
7e4b4e06ce
@ -2,13 +2,13 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
List crypto rates
|
List crypto rates
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries cryptocompare.com and lists the current crypto exchange rates in USD/EUR/RUB/CNY.
|
This PowerShell script queries the current crypto exchange rates from cryptocompare.com and lists it in USD/EUR/CNY/JPY.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-crypto-rates.ps1
|
PS> ./list-crypto-rates.ps1
|
||||||
|
|
||||||
CRYPTOCURRENCY USD EUR RUB CNY
|
CRYPTOCURRENCY USD EUR CNY JPY
|
||||||
-------------- --- --- --- ---
|
-------------- --- --- --- ---
|
||||||
1 Bitcoin (BTC) = 29054.01 26552.23 2786627.84 172521.27
|
1 Bitcoin (BTC) = 97309.81 94385.57 38800 14798679.56
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -17,24 +17,26 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
function ListCryptoRate { param([string]$Symbol, [string]$Name)
|
function ListCryptoRate { param([string]$Symbol, [string]$Name)
|
||||||
$rates = (Invoke-WebRequest -URI "https://min-api.cryptocompare.com/data/price?fsym=$Symbol&tsyms=USD,EUR,RUB,CNY" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
$rates = (Invoke-WebRequest -URI "https://min-api.cryptocompare.com/data/price?fsym=$Symbol&tsyms=USD,EUR,CNY,JPY" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
||||||
New-Object PSObject -property @{ 'CRYPTOCURRENCY' = "1 $Name ($Symbol) ="; 'USD' = "$($rates.USD)"; 'EUR' = "$($rates.EUR)"; 'RUB' = "$($rates.RUB)"; 'CNY' = "$($rates.CNY)" }
|
New-Object PSObject -property @{ 'CRYPTOCURRENCY' = "1 $Name ($Symbol) ="; 'USD' = "$($rates.USD)"; 'EUR' = "$($rates.EUR)"; 'CNY' = "$($rates.CNY)"; 'JPY' = "$($rates.JPY)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListCryptoRates {
|
function ListCryptoRates {
|
||||||
ListCryptoRate BTC "Bitcoin"
|
ListCryptoRate BTC "Bitcoin"
|
||||||
ListCryptoRate ETH "Ethereum"
|
ListCryptoRate ETH "Ethereum"
|
||||||
ListCryptoRate BUSD "BUSD"
|
ListCryptoRate SOL "Solana"
|
||||||
ListCryptoRate XRP "XRP"
|
ListCryptoRate XRP "XRP"
|
||||||
|
ListCryptoRate USDC "USD Coin"
|
||||||
|
ListCryptoRate SUI "Sui"
|
||||||
|
ListCryptoRate DOGE "Dogecoin"
|
||||||
|
ListCryptoRate TRUMP "Official Trump"
|
||||||
ListCryptoRate USDT "Tether"
|
ListCryptoRate USDT "Tether"
|
||||||
|
ListCryptoRate BUSD "BUSD"
|
||||||
ListCryptoRate AVAX "Avalanche"
|
ListCryptoRate AVAX "Avalanche"
|
||||||
ListCryptoRate LTC "Litecoin"
|
ListCryptoRate LTC "Litecoin"
|
||||||
ListCryptoRate SOL "Solana"
|
|
||||||
ListCryptoRate GALA "Gala"
|
ListCryptoRate GALA "Gala"
|
||||||
ListCryptoRate DOGE "Dogecoin"
|
|
||||||
ListCryptoRate ADA "Cardano"
|
ListCryptoRate ADA "Cardano"
|
||||||
ListCryptoRate BNB "Binance Coin"
|
ListCryptoRate BNB "Binance Coin"
|
||||||
ListCryptoRate USDC "USD Coin"
|
|
||||||
ListCryptoRate DOT "Polkadot"
|
ListCryptoRate DOT "Polkadot"
|
||||||
ListCryptoRate UNI "Uniswap"
|
ListCryptoRate UNI "Uniswap"
|
||||||
ListCryptoRate BUSD "Binance USD"
|
ListCryptoRate BUSD "Binance USD"
|
||||||
@ -48,8 +50,8 @@ function ListCryptoRates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ListCryptoRates | Format-Table -property @{e='CRYPTOCURRENCY';width=28},USD,EUR,RUB,CNY
|
ListCryptoRates | Format-Table -property @{e='CRYPTOCURRENCY';width=28},USD,EUR,CNY,JPY
|
||||||
Write-Host "(by cryptocompare.com • Crypto is volatile and unregulated • Capital at risk • Taxes may apply)"
|
Write-Host "(by https://www.cryptocompare.com • Crypto is volatile and unregulated • Capital at risk • Taxes may apply)"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user