Skip to content

Instantly share code, notes, and snippets.

@nicocavallo
Created June 28, 2017 23:03
Show Gist options
  • Save nicocavallo/c8b05387a3f0e1eeb5bcd0cf054b4551 to your computer and use it in GitHub Desktop.
Save nicocavallo/c8b05387a3f0e1eeb5bcd0cf054b4551 to your computer and use it in GitHub Desktop.
PowerShell Script for notifying when a given crypto-currency's price is under a given threshold.
param(
$confPath = "./conf.txt"
)
while (1)
{
$props = convertfrom-stringdata (get-content -path $confPath -raw)
$period = [convert]::ToInt32($props.'app.interval', 10)
$threshold = [convert]::ToInt32($props.'app.min', 10)
$cryptoCurrency = $props.'app.cryptoCurrency'
$currency = $props.'app.currency'
$url = "https://api.coinbase.com/v2/exchange-rates?currency=$cryptoCurrency"
$ethInfo = (New-Object System.Net.WebClient).DownloadString("$url") | ConvertFrom-Json
$cryptoPriceInPounds = [decimal]$ethInfo.data.rates.$currency
if ($cryptoPriceInPounds -lt $threshold) {
[system.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null
$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
$objNotifyIcon.Icon = "C:\tools\Scripts\edit_16x16.ico"
$objNotifyIcon.BalloonTipIcon = "Info"
$objNotifyIcon.BalloonTipText = "Price: " + $cryptoPriceInPounds + " " + $currency
$objNotifyIcon.BalloonTipTitle = "Buying " + $cryptoCurrency + "?"
$objNotifyIcon.Visible = $True
$objNotifyIcon.ShowBalloonTip(1000)
}
sleep -sec $period
}
app.cryptoCurrency=ETH
app.currency=GBP
app.min=150
app.interval=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment