To make a long story short…
#!/bin/bash
PATTERN=$(echo $1 | tr [:lower:] [:upper:])
# or
PATTERN=$(echo $1 | tr [a-z] [A-Z])
# or
PATTERN=$(echo $1 | awk '{print toupper($0)}')
echo "Your $1 argument is now uppercase: $1"
To make a short story long…
Just to let you know a little more about me and reveal a few more shells tricks along the way.
I am a very conservative investor - always have been but the low interest rates over the recent past has forced me to try a squeeze a little more out of the stock market also known as a “a gentleman’s gambling parlor of greedy people”. To do this I have been using covered secure puts and covered calls (did I mention that I am conservative?). So what does this have to do with the title here?
I heavily use scripting to quickly determine current positions on stocks I track. It starts with a file listing details of those stocks on each line. Then run a script that will selectively get the current price on each of stock and calculate how close it is to my target option price. I am lazy - which is one indispensable trait of a good system admin or programmer (never do anything manually more than once). So I needed a way to get stock quotes on one of the stocks in my list. The obvious solution is to grab the stock out of the list using grep (or awk) but all the stocks need to be uppercase. I scrape the current price off of a financial site but it requires uppercase.
I mention all this because my underlying motive is to encourage people to leverage shell tools (principally grep and awk). Fact is, financial incentives work (maybe that is a sad thing).
By the way, my script will use command line arguments to give me a detailed single line output of selected stocks providing:
- current price, difference from target and %difference from target
- target price and recent price, IV (implied volatility), and probability of out of the money
- how many lots to offer as Puts or Calls for the selected account
- purchase price if I bought in the past
- PE and future PE, ROE, various ratings, and 52 week range
- shares owned,percent of account(s), and any notes on the stock
Lots of this is manually maintained and, yes, it can be tedious but I have the time. The script grabs only what I tell it through the command line (just puts or calls or selected stocks or all of them etc). Then it grabs the current price and tells me how close it is to my target price as a percentage. For example I can tell the script to just grab potential puts that are within X% (eg 6%) of its strike or target price.
This gives me a good starting point for doing further research on selected stocks for the day. For example this will give me all put options that interest me where the current price is within 6% of my target.
# get stocks with interesting put options, mark anything with 6% of the target/strike price
# and grep out those marked stocks only
getquotes.sh -p -m 6 -g
I won’t bore you with anymore detail - besides anything after this gets pretty cryptic…
Enjoy
-g-
comments powered by Disqus