ChatGPT produced Bash shell script to display stock tickers every 10 seconds

Because I have a putty terminal running on my PC most every day (mostly sitting there doing nothing, waiting for a command,) I thought I’d put that open terminal to use and have it display stock tickers. So I asked ChatGPT to create a bash shell script that display a ticker and it’s price from the internet. I am not a good programmer/developer, and I can barely write a few scripts, but by using ChatGPT I was able to produce what I wanted in a short amount of time. Below is the script that it produced:

#!/usr/bin/env bash
set -e



if ! $(type jq > /dev/null 2>&1); then
  echo "'jq' is not in the PATH. (See:"
  exit 1

if [ -z "$SYMBOLS" ]; then
  echo "Usage: ./ AAPL MSFT GOOG BTC-USD"

FIELDS=(symbol marketState regularMarketPrice regularMarketChange regularMarketChangePercent \
  preMarketPrice preMarketChange preMarketChangePercent postMarketPrice postMarketChange postMarketChangePercent)

if [ -z "$NO_COLOR" ]; then
  : "${COLOR_BOLD:=\e[1;37m}"
  : "${COLOR_GREEN:=\e[32m}"
  : "${COLOR_RED:=\e[31m}"
  : "${COLOR_RESET:=\e[00m}"

symbols=$(IFS=,; echo "${SYMBOLS[*]}")
fields=$(IFS=,; echo "${FIELDS[*]}")

results=$(curl --silent "$API_ENDPOINT&fields=$fields&symbols=$symbols" \
  | jq '.quoteResponse .result')

query () {
  echo $results | jq -r ".[] | select(.symbol == \"$1\") | .$2"

for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do
  marketState="$(query $symbol 'marketState')"

  if [ -z $marketState ]; then
    printf 'No results for symbol "%s"\n' $symbol

  preMarketChange="$(query $symbol 'preMarketChange')"
  postMarketChange="$(query $symbol 'postMarketChange')"

  if [ $marketState == "PRE" ] \
    && [ $preMarketChange != "0" ] \
    && [ $preMarketChange != "null" ]; then
    price=$(query $symbol 'preMarketPrice')
    percent=$(query $symbol 'preMarketChangePercent')
  elif [ $marketState != "REGULAR" ] \
    && [ $postMarketChange != "0" ] \
    && [ $postMarketChange != "null" ]; then
    price=$(query $symbol 'postMarketPrice')
    percent=$(query $symbol 'postMarketChangePercent')
    price=$(query $symbol 'regularMarketPrice')
    diff=$(query $symbol 'regularMarketChange')
    percent=$(query $symbol 'regularMarketChangePercent')

  if [ "$diff" == "0" ] || [ "$diff" == "0.0" ]; then
  elif ( echo "$diff" | grep -q ^- ); then

  if [ "$price" != "null" ]; then
    printf "%-10s$COLOR_BOLD%8.2f$COLOR_RESET" $symbol $price
    printf "$color%10.2f%12s$COLOR_RESET" $diff $(printf "(%.2f%%)" $percent)
    printf " %s\n" "$nonRegularMarketSign"

This produced the following, for example:

This works well, however I want the script to display a number of different tickers and have the data refresh every 10 seconds. The next script produced is the following I added my tickers


while true; do
    sleep 10

This is what I was looking for! So I simply had to modify both to run as executible / binary files. To do so, use the command:

chmod +x

Lastly, run the script with the command ./

18 Things I’ve learned Trading Options on Robinhood and TD Ameritrade in the past 12 Months

So for the past 12 months or so I’ve tried my hand had trading options on Robinhood and TD Ameritrade, and I want to pass on what I’ve learned so perhaps someone new to options can get a head start. *Disclaimer: I’m in no way endorsing or advocating trading options. What you do with your money and your trades has no association with the information presented here. By reading this information you’re agreeing that you hold harmless and no liability to myself, my employer or this website. If that scares you, please click here. In all my trades, I’ve only made a little bit of money with a total amount of trade money equaling under $1000. *update 1/30/21* I’ve now made more than a little money 🙂 Starting in April of last year I funded $2500 into my TD Ameritrade account. Using the principles I have below, AND A LOT OF LUCK, my account has grown to around $17k. This was done with a combination of stocks and options purchases. This may not happen to you, and I’m not saying it will, this post is merely for advice and informational purposes. As you can see, I didn’t become a millionaire in a month. If that’s what you want, head on over to wallstreetbets with your 50k to blow. But I did earn enough for a pretty nice used car or family vacation…

Before you get started, it’s important to know that trading options are essentially gambling; it’s almost pure speculation on whether or not the market or stock will go up or down and your bets will pan out. I say almost because there are traders out there who make a consistent living doing options trading. This article is not for those who already know the in’s and out’s of options trading or are looking for information about advanced options trading strategies (spreads etc). But back to gambling… if you have a tendency to let emotions get control of you if you win or lose, or if you’ll hurt yourself or your family because one of your trades goes the wrong way, then stay out of options trading. I won’t go into all the other investment vehicles you can use to safeguard your money for retirement, and at a bare minimum, don’t even think of trading options if you don’t first have an emergency fund of several thousand dollars.

I work for a brokerage, and I’m in no way endorsing trading of options as a retirement vehicle. If you trade options, you may lose everything you have in your bank in one week if you’re not careful. Trading options can be stressful and painful when things don’t go your way. You really do have to watch your puts and calls pretty much every minute of the day while your trades are active. But on the flip side, if you are frugal and learn as much as you can, trading options can be a nice way to generate money quickly without too much physical work. Options trading really is just for “play” money; I advocate putting 99% of your money into a Roth IRA or 401K.

Now onto the eighteen things I’ve learned trading options. I, myself, read my list EVERY TIME I’M ABOUT TO PUT IN AN OPTIONS ORDER. I’ve probably canceled a dozen trades after I’ve read my own list just because I’ve let emotions get hold of me and this list brings me back to reality. This list isn’t necessarily in order of importance.

  1. Limit your losses (always) – Decide how much your bottom limit is and stick to it. If I ever let another option expire worthlessly, I’m worthless. It’s my money. Always keep enough in the brokerage account to at least place a couple more orders. When you have to add money to your brokerage account from savings to keep trading, you’re losing.
  2. Don’t buy options for smaller companies, stocks, or obscure ETFs based on hunches or charts. Smaller stocks sometimes don’t have the volumes and there will be no one around to buy your Out-of-the-Money option if the market is heading the wrong direction. They often have fewer price points and options in the option chains.
  3. If you win (your option hits its price target), you’ll probably be up a good amount, so sell when the trend is favorable.  You’ll never know what will happen in the next few hours or days. DISCIPLINE! Some news might hit, the president will tweet about China, or a scandal could erupt, and everything goes down or vice-versa.
  4. You’ll never time the sale of an In-the-money option exactly at the peak price of the day so it’s ok to sell after it’s coming down from the intra-day high. Better to make some money on the drop from the high than to wait for it to get back to the peak.
  5. It’s ok to sell for a $5, $10, or $20 profit if you’re In The Money and not feeling it and the trend changes or news hits.
  6. The whole reason you’re doing this is to make money whether or not the market is Rising or Falling. Don’t get emotional about what you want to happen to the market or company. Only go by the numbers and make money off of the trend, whether it’s a Call or a Put.
  7. Don’t let an option ride overnight especially if your option is expiring soon. After-market trading is a good way to lose a lot of money real quick once the market opens. You need your sleep and you don’t like to wake up early. This is not set in stone because you could be betting on a piece of big after-hours news or earnings. Also, if you have more money, you can purchase more expensive options that expire in a few months, which is absolutely better than buying a weekly that expires in a few days. This takes the ease off of after-hours fluctuations.
  8. Sometimes stocks are so beaten up, some more bad news just clears the way for a rally because there isn’t any reason to punish the stock further.
  9. Same with good news, a stock could be so bid-up that more good news essentially causes a ceiling and there is no reason for it to go up more because it is already so priced for perfection so it goes down.
  10. In a bad market, bulls want red openings and bears want green openings.  In a bad market, bulls will buy low right?  And in a bad market bears will fade a gap (short). 
  11. Keep a good positive mindset and just keep hitting singles for $20, $30, $50, whatever, and keep the loser mentality away.
  12. It sucks you can only do 4 same-day trades in 5 days (with Robinhood,) but don’t allow that fact make you ride an option longer than its value. Theta will steal your money anyway so stick to day trades with options. If you have a long-term bet then buy the actual stock, or buy an expensive option that expires in a few months/year.
  13. Implied Volatility (IV) – when looking to buy an option, look at the Implied Volatility. If it is something high like 91%, then you can probably expect to see the value of your options (most likely) swing/drop 91% during the term of your option. Options are not the best vehicle during earnings. It’s best to sell and make any profit you can before earnings come out. I YOLO bought $375 worth of SBUX options on Thursday with IV of 91% which expired the next day (Friday.) The option made almost no money on Thursday, then favorable earnings came out that Thurs night. The stock jumped up a little in after-hours trading then went back down again. The next morning it dropped like a rock 91 %. I got out that morning and lost $300. Then later that day, like not even 2 hours later, the stock went back up to its previous close. See the chart below. I could have just held on through the IV and not lost as much, but it takes real guts to hold in that situation, which you don’t want to go through, believe me. Again, holding options through earnings is very risky unless it’s something like MSFT which beat it’s projected earnings by a lot and IV was low. Place your bet either prior to or after the earnings and then watch the market reaction. Because this option was expiring the same day, theta was going to quickly eat into its value even if I held during the rise after the sharp drop. IV I’m not entirely sure about, so comment if you know more about this below.
  14. No “options guru tweet” nor r/wallstreetbets post will give you a winning trade every time. Trust your own instincts, gather as much information and news as you can, and find out what works for you, not someone else.
  15. In general it’s better to buy “natural” monthly options with non-weekly strike dates. For some reason, the weeklies don’t tend to do as well.
  16. In general, it’s better to buy an option with an expiration a few months out. Yes the option you’re buying on a Tuesday has better “YOLO” returns if it expires on Friday, but just the same, you have a bigger chance of losing everything very quickly. At least with an option a few months out, you can hold through a few dips without too much consequence, and then if a big pop occurs you can capitalize on it. Again, discipline. If you get a pop on an option, even if it expires in say, 2 months, cash out and bank the money. I’ve never regretted taking a big earnings pop and banking it. More often than not, the next couple days/weeks, the stock returns to it’s previous trend. The point is, you don’t know what the stock will do. Take your gains and get out. Then sit with your cash in your account, smile, take a breath, do your research again, and wait for the next opportunity.
  17. TD Ameritrade is my broker of choice now, and although I’ve got a little money in Robinhood, it’s practices lately are forcing me to close my Robinhood account. FYI, you don’t have to sell your securities in Robinhood in order to put them in a different brokerage, you can transfer. There is a $75 fee associated with the transfer, so it may or may not make more sense to sell your securities and just pull the money out or the transfer may make more sense if there are tax ramifications.
  18. Aside from Options, now that I have more cash in my account, I’ve done pretty well with “lots” of stocks. By “lots” I mean purchasing lower priced stocks in quantities of 100 shares. That way if the price goes up 1 point, I know I’ve made $100 on that stock that day. Just because they are shares, doesn’t mean I have to hold on to them for a longer period of time. There are better tax advantages when you hold on to a stock for at least one year, but I use the same principles above and sell and bank stock gains the same as I do options.

That’s it for now! I hope some of the information was valuable, and I wish you an exciting and profitable foray into the world of trading options.