Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-04-07 17:42:31

jt1122
Member
Registered: 2021-03-26
Posts: 33

Stock quotes panel app?

Hi,

Could members here advise if there is a panel app which shows stock quotes (symbol+quote+%change), for example in a ticker format or a table format?..

Thanks

Offline

#2 2021-04-07 22:01:13

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 7,650

Re: Stock quotes panel app?

Here is a first run at something that might fit the bill. It uses the xfce4-genmon-plugin and requires the package "jq" and that you install ticker.sh.

Then use this script in xfce4-genmon-plugin:

#!/bin/bash

# list of stocks to show in the tooltip
STOCKS="GME MSFT GOOG BTC-USD APPL FGEN ODT"

# the stock to show on the panel
SHOW="GME"

FIRST="$(env NO_COLOR=1 /home/toz/ticker.sh $SHOW)"
ALL="$(env NO_COLOR=1 /home/toz/ticker.sh $STOCKS)"

echo "<txt>$FIRST</txt><tool>$ALL</tool>"
exit 0

...make the script executable, change the path to the ticker.sh file on lines 9 & 10 to point to the location of your ticker.sh script, and change the "STOCKS" and "SHOW" variables to suit your needs.

In the genmon properties, disable the label and set the period to your refresh frequency.

Edit: screenie
stonks.png

Last edited by ToZ (2021-04-07 22:14:14)

Offline

#3 2021-04-08 10:15:25

Jerry3904
Member
Registered: 2013-11-09
Posts: 818

Re: Stock quotes panel app?

I myself have not use for that, ToZ, but that's very cool.


MX-19.4 (based on Debian Stable) with our flagship Xfce 4.16.
My little collection: Xfce Tidbits

Offline

#4 2021-04-08 16:27:08

CwF
Member
Registered: 2018-01-28
Posts: 128

Re: Stock quotes panel app?

Excellent!
This is another example that begs for a better way to schedule genmon's other than an interval.

Offline

#5 2021-04-08 16:31:38

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 7,650

Re: Stock quotes panel app?

CwF wrote:

Excellent!
This is another example that begs for a better way to schedule genmon's other than an interval.

What do you mean? In this case, the interval is the refresh time (refresh quote data). Isn't that what would be expected here?

Offline

#6 2021-04-08 17:07:03

CwF
Member
Registered: 2018-01-28
Posts: 128

Re: Stock quotes panel app?

ToZ wrote:

What do you mean?

Minor traffic, but I'd like it timed and not every so often. Market closed, holidays and other periods to go quiet, starting at open, cease at close, maybe an after hours check, maybe every minute from 7:30 local to 7:45, similar last 15 minutes, etc...

Really, I'd like similar timing for weather, and the convoluted genmon I use for 8 channel dvb status and stream monitoring.

I've been pondering on this for awhile with no complete thought yet, but basically some timing mechanism in a cron like format. Maybe an interval entry of '0' zero could trigger reference to an external $(name)-genmon.cron where the schedule could be formatted. Even better would be events to trigger or modify timing, referenced in that same file.

Last edited by CwF (2021-04-08 17:08:17)

Offline

#7 2021-04-08 17:18:09

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 7,650

Re: Stock quotes panel app?

What if you separated the script and the timing from the actual display. For example, have something working in the background, based on cron timing frequencies, and send the output to a file. Then only use genmon to display the contents of the file? The genmon frequency would become kid of irrelevant, it would only refresh the display based on whats in the file and if that hasn't changed, the genmon content stays the same.

It's not exactly as you are thinking since the cycle will still fire at regular intervals. However, in the code, the cycle will still need to run regardless, even if to check the cron settings. At least that's the way it is now without a major re-write.

Offline

#8 2021-04-08 17:29:36

CwF
Member
Registered: 2018-01-28
Posts: 128

Re: Stock quotes panel app?

Yes, that's what I do for a few things.
Weather at a local AFB is updated hourly, so cron times the cache file, my genmon just parses the local file. So it's never down, just the timestamp for reference. The wttr version is often down, and not locally very accurate.

just dreaming!

Offline

#9 2021-04-09 01:16:17

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 7,650

Re: Stock quotes panel app?

A slightly better formatted version:

#!/bin/bash

# list of stocks to show in the tooltip
STOCKS="GME MSFT GOOG BTC-USD AAPL FGEN ODT CVNA TSLA ETSY QRTEA BIO WTM HUN VIRT"

# the stock to show on the panel - from list above starting at 0
PANEL=8

### No need to change anything below

UPDATE=$(date)
NUM_STOCKS=$(echo $STOCKS | awk '{for(i=0;i<=NF;i++); print i-1 }')

declare -A stock=() price=() change=() percent=()
{
	c=0
	while read -r STOCK PRICE CHANGE PERCENT; do
		stock[$c]=$(printf %-8s $STOCK)
		price[$c]=$(printf %10s $PRICE)
		change[$c]=$(printf %10s $CHANGE)
		percent[$c]=$PERCENT
		((c=c+1))
	done
} < <(env NO_COLOR=1 /home/toz/ticker.sh $STOCKS)

OUT=$(echo ${stock[$PANEL]}${price[$PANEL]}${change[$PANEL]} "${percent[$PANEL]}" | sed -e 's/  */ /g')

for (( c=0; c<$NUM_STOCKS; c++ ))
do
	TOOL="$TOOL${stock[$c]}${price[$c]}${change[$c]}\t${percent[$c]}\n"
done
TOOL="$TOOL\n<small><i>Last Updated: $UPDATE</i></small>"

echo -e "<txt>$OUT</txt><tool><tt>$TOOL</tt></tool>"

exit 0

Screenie:
stonks.png

Offline

#10 2021-04-09 03:27:47

CwF
Member
Registered: 2018-01-28
Posts: 128

Re: Stock quotes panel app?

Very nice work, clean colums

I did the file option from cron.

env NO_COLOR=1 ticker.sh 1 2 3' > ~/ticker.txt

...if no color tags

P1=$(cat ~/ticker.txt | grep 1 | cut -b 13-18)

to clip out share price of stock 1

a few lines for quantity

V3=$(echo "$P3 * 1200" | bc)

...then a sum for main

ACCT=$(echo "$P1 + $P2 + $P3" | bc)
echo "<txt>$ACCT</txt><tool>$ALL</tool>"

where 1 2 3 are some stocks in a taxable category.
btw, I had, HAD, GME since they paid dividends...

Oh, I figured the trailing asterisk is a after hours price.

Offline

#11 2021-04-09 11:35:31

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 7,650

Re: Stock quotes panel app?

That's interesting. You have the monetary value of your account in the panel - much better than just some random stock. I don't dabble in the stock market so I'm not 100% sure what I'm looking at here. The * makes sense as an indicator that trading has closed for the day, though.

Offline

#12 2021-04-09 11:44:01

jt1122
Member
Registered: 2021-03-26
Posts: 33

Re: Stock quotes panel app?

ToZ wrote:

Here is a first run at something that might fit the bill. It uses the xfce4-genmon-plugin and requires the package "jq" and that you install ticker.sh.

Then use this script in xfce4-genmon-plugin:
...

Great - thanks for taking the time to provide this handy solution.

Since there seems to be interest also from others in such an applet it seems useful to have it as a dedicated applet possibly with additional common features like setting alarms when a quote reaches some target price etc.

In the meantime I'll use your suggestion.

Cheers

Last edited by jt1122 (2021-04-09 16:03:14)

Offline

#13 2021-04-09 15:46:32

CwF
Member
Registered: 2018-01-28
Posts: 128

Re: Stock quotes panel app?

Genmon is such a great thing!

From that asterisk note, a few thoughts;
Contracts (big) that happen after hours can change the price, but not for 'us'. So the asterisk means it's not 'accurate'.  I noticed the asterisk on a stock yesterday that was inflated some 40 cents, and led me to see an institutional buy of  3 million shares happened...the 'real' price at close, and open this morning did NOT retain that  'premium'.

Next, as far as alerts and the like - be careful! The data from this is delayed at least minutes if not more. Great things happen in seconds! 'F' hit 13.62 the other Monday, it was above 13.50 just long enough for me to dump hundreds, but not all...with limits I ended with 100 unsold. All happening faster than I could type! On a near real time feed I saw the 13.62 for literally seconds - that doesn't show on most 'smoothed' graphs after the fact - and a utility like this would certainly miss it.

Like a lot of things in our world - real actionable information cost real money. I'm going to trim the '.00' and a '$' out of my display to be more obtuse. This is fine for a quick glance, and greatly satisfies my inner geek, but is not suitable as a primary indicator.

For the most part, any source within a minute of accuracy is only available behind a logged on qualified account. Trading records are timestamped to the BILLIONTH of a second!

GME is going to be THE case study of manipulation.

Offline

#14 2021-04-09 16:07:39

jt1122
Member
Registered: 2021-03-26
Posts: 33

Re: Stock quotes panel app?

CwF wrote:

Genmon is such a great thing!
...

Thanks for the interesting read.

I'm not day-trading hence I don't need microsecond quote accuracy but I do want to see trends and adjust stop loss/loss limits dynamically.

As I've suggested it would be useful if there was a dedicated stocks applet on xfce.

Cheers

Offline

#15 2021-04-10 02:55:15

CwF
Member
Registered: 2018-01-28
Posts: 128

Re: Stock quotes panel app?

jt1122 wrote:

As I've suggested it would be useful if there was a dedicated stocks applet on xfce.

Cheers

agreed, but this is working pretty well.

I did answer my question! With the script I made up to populate a file with the ticker.sh output, I just pointed the txtclick to the script!

echo "<txt>${ACCT%%.*}</txt><tool>$ALL</tool><txtclick>tickpop.sh</txtclick>"

Interval problem solved!

Offline

Board footer

Powered by FluxBB