Companionway

Meeting challenges with success

Python's all() function

Python all() function

Much of my coding efforts are directed towards analyzing financial data specifically targeting potential cash secured puts or covered calls. Recently, I had to refine some market overview displays. I needed a listing of the current market “gainers” and market “losers”. There is one site which I scrape using panda read_html function to grab a hadful of tables. My problem arises from two factors. One is there are no labels or titles to the tables and they can vary. The a table can arise from special (temporart) events and the weekends or holidays might call for the tables to re-arrange their order. This requires that I look directly at the panda table and derive which table I might be examining. One table I look for lists all the “gainers” currenly in the market. What I do know is that the third column of that table will always contain a plus sign (the % change of all the gainers). I had nested loops initially to do this but I refactored the code to use the “all()” function to discover which table has all “+” signs in the column 3. My standard caveat applies here - there is likely a better way to do this - so let me know.


shell/bash uppercase arguments

turning your commandline arguments into uppercase

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?