Created
June 28, 2017 23:03
-
-
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.
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
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 | |
} |
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
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