From 6051bb5297c24c3671575b4ad53f5b4f5f047d2b Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 27 May 2021 16:32:13 +0200 Subject: [PATCH] added support for Pre Market --- .config/polybar/custom/scripts/gme.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.config/polybar/custom/scripts/gme.sh b/.config/polybar/custom/scripts/gme.sh index 1e5eecf..afdc4b6 100755 --- a/.config/polybar/custom/scripts/gme.sh +++ b/.config/polybar/custom/scripts/gme.sh @@ -14,11 +14,13 @@ toggle() { trap "toggle" USR1 while true; do - URL="https://query1.finance.yahoo.com/v8/finance/chart/GME" - res=$(curl -sf "$URL") + URL="https://api.nasdaq.com/api/quote/GME/info?assetclass=stocks" + res=$(curl --user-agent 'Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0' -sf "$URL") - close=$(jq '.["chart"]["result"][0]["meta"]["previousClose"]' <<< "$res") - current=$(jq '.["chart"]["result"][0]["meta"]["regularMarketPrice"]' <<< "$res") + close="$(jq '.["data"]["keyStats"]["PreviousClose"]["value"]' <<< "$res")" + close="${close//[^0-9.]/}" + current="$(jq '.["data"]["primaryData"]["lastSalePrice"]' <<< "$res")" + current="${current//[^0-9.]/}" shares="1.650981" buy="214" @@ -49,7 +51,7 @@ while true; do fi echo "$output" - sleep 2 & + sleep 5 & sleep_pid=$! wait done