Happy New Year 2022!

January 15th, 2022

For the new year, I resolve to focus on the following:

  • health: lose 25 pounds in 20 weeks using diet and exercise, and 45 pounds by the end of the year
  • finance: generate returns by periodically establishing high probability of profit options trades
  • career: focus on developing marketable skills, specifically skills in securing software architectures implemented with microservices
  • hobbies: Japanese language learning by reaching level 40 on WaniKani by June

2021 felt like a continuation of 2020. Here’s to hoping that 2022 is not like 2020 too!

My Start in Options Trading

December 26th, 2021

CNBC’s Yun Li reports, “A record of 39 million options contracts have traded daily on average this year, rising 35% from 2020, according to Options Clearing Corp.” After nearly twenty years of opening a brokerage account and managing a stock portfolio, I completed an options course offered by TD Ameritrade and contributed to this year’s record options trading volume.

TD Ameritrade Certificate of Achievement for Options Course

Most of my options trades are for securities that I do not mind owning. I sell out of the money (OTM) put options rather than setting buy limit orders for stocks that I want to buy, and I sell OTM call options instead of setting sell limit orders for stocks that I own. Through these transactions, I earn a premium while I wait for my desired entry or exit prices.

Options provide investors and traders additional tools and options strategies. Without options, a swing trader is limited to buying or short selling a stock and riding the stock’s change in value. In a kind of swing trading using options, I have sold cash-secured puts, covered calls, Jade Lizards, and Iron Condors in order to gain premiums while an underlying security trades within a range. I have been able to keep premiums when options expire worthless, and I have had stocks assigned to me as well as called away. I continue to sell options on the underlying that has been assigned or called away, performing something known as the Wheel Strategy.

I have sold options and options spreads throughout my first year. I have been selling options to generate income. Future development in my options trading involves speculation and buying spreads. As Yun Li’s article reports, buying basic call and put options has a much lower probability of profit compared with options spreads. So, I intend to buy spreads or, in other words, buy an option and sell a further OTM option to offset the cost of the bought option. Buying an options spread exposes me to losing the net premium I pay for the spread. The speculative nature is derived from the premium being paid upfront and the hope that the price of the option increases to cover the cost of the spread before the options’ expiration date.

It is important to recognize the limits of one’s risk tolerance. My risk tolerance steers me away from selling naked calls and certain ratio spreads. These kinds of options trades require the highest levels of trading privileges granted by brokerages. I do not plan on requesting the highest options trading privileges at this time. I appreciate the protection that is provided by being unable to sell naked calls.

In closing, I should note that options are not suitable for all investors. Understanding option pricing behavior is a minimal requirement for trading options. Being familiar with the following is a must: how much the price of an option changes along with changes in the underlying security’s price, the change in the amount of change in an options price as the underlying’s price changes, the effect of time and changes to volatility specific to the security and the market as a whole. People have lost their entire accounts by not understanding options and neglecting basic risk management.

Can Anyone Guess When I Discovered Options Trading
by /u/hatemydarnjob on Reddit’s WallStreetBets

Tobira Kanji and WaniKani

December 5th, 2021
Posted in 日本語 | No Comments

Tobira Gateway to Advanced Japanese Learning through Content and Multimedia assumes 297 kanji are already learned by its potential readers. Tobira presents many words using these kanji without furigana. Learning the statistically most common kanji on- and kun-readings through WaniKani makes Tobira more accessible.

The following table shows what percentage of these prerequisite kanji are covered at particular WaniKani levels:

Level 5: 40%
Level 10: 76%
Level 15: 92%
Level 20: 97%

Only nine prerequisite kanji are introduced by WaniKani after level 20: 職違質授痛貸婚汚遅. The other 277 required kanji are covered in the first 20 levels.

The following snippet, with furigana as provided in Tobira, is extracted from page 5 of the textbook:

日本には、47の都道府県(一都、一道、二府、四十三県)があります。一都は東京都(首都しゅと)、一道は北海道、二府は大阪おおさか府と京都府で、そのほかは、静岡しずおか県や広島ひろしま県のように全部、県です。静岡県はお茶や富士山ふじさんで有名で、広島県には戦争せんそうおそろしさと平和の大切さを伝える原爆げんばくドームがあります。

Working through level 20 on WaniKani will not give language students the ability to know all vocabulary in the above text. However, they will be able to make good guesses at how to read words such as 都道府県 and use online dictionaries like Jisho. Several words with furigana included by Tobira, such as 他, 大阪, 広島, and 戦争, should be known by WaniKani users at level 20. If Tobira is a gateway to advanced Japanese, then WaniKani is a great tool to develop vocabulary and reading skills needed to pass through that gateway.

The above percentage data was derived from output of a JavaScript program, wktobira.js, which maps Tobira prerequisite kanji to WaniKani levels and is an example of using the WaniKani Web API.

JavaScript: SHA-256 Implementation

October 3rd, 2021
Posted in JavaScript | No Comments

This weekend I decided to experiment with using JavaScript to implement client-side processing of files using a web browser. To make it interesting, I wanted to see if it was possible to implement a cryptographically strong hash function: SHA-256.

This exercise gave me exposure to Web Workers and the Stream API. I encountered compatibility challenges. Google Chrome does not respond to UI updates when using setInterval() or setTimeout() while the browser is busy, but its user interface can be updated when processing messages from web workers. Mozilla Firefox does not support passing {type: ‘module’} to the Worker() constructor; ECMAScript modules are unsupported. Firefox reports a syntax error when trying to import modules from the Web Worker’s source file. This forced me to add Worker code to the source code file containing the JavaScript SHA-256 implementation.

The following checksum generator implements SHA-256 as defined by FIPS PUB 180-4. Files are not sent to the server for processing. The cost of transferring data would be too much. Files are processed locally on the web browser running on the user’s computer.

SHA-256 Checksum Generator

Input File:
Checksum:
Source Code: sha256.js, sha256main.js

Using GoDaddy API for Dynamic DNS

September 27th, 2021

It has been difficult accessing my home computer, with potentially a dynamically allocated IP address, from anywhere on the Internet after dyndns.org became a paid service. The following bash script made available by TheBelcherman on the GoDaddy Community forum simulates the functionality of dyndns.org by programmatically updating a DNS record that has GoDaddy as its authoritative nameserver:

#!/bin/bash

# This script is used to check and update your GoDaddy DNS server to the IP
# IP address of your current internet connection.
# Special thanks to mfox for his ps script
# https://github.com/markafox/GoDaddy_Powershell_DDNS
#
# First go to GoDaddy developer site to create a developer account and get
# your key and secret
#
# https://developer.godaddy.com/getstarted
# Be aware that there are 2 types of key and secret - one for the test server
# and one for the production server
# Get a key and secret for the production server
#
# Enter vaules for all variables, Latest API call requries them.

domain="mydomainname.com"                   # your domain
type="A"                                    # Record type A, CNAME, MX, etc.
name="myhostname"                           # name of record to update
ttl="600"                                   # Time to Live min value 600
port="1"                                    # Required port, Min value 1
weight="1"                                  # Required weight, Min value 1
key="ABCxyz123+qwertzxcvASDFasdfBCDEFGwysi" # key for godaddy developer API
secret="122333444455555xyz123abcqwerty"     # secret for godaddy developer API

headers="Authorization: sso-key $key:$secret"

# echo $headers

result=$(curl -s -X GET -H "$headers" \
 "https://api.godaddy.com/v1/domains/$domain/records/$type/$name")
echo $result

dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
echo "dnsIp:" $dnsIp

# Get public ip address there are several websites that can do this.
ret=$(curl -s GET "http://ipinfo.io/json")

# echo $ret
currentIp=$(echo $ret | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
echo "currentIp:" $currentIp

if [ -z $dnsIp ] || [ $dnsIp != $currentIp ];
then
  echo "IP's are not equal, updating record"
  curl \
    -X PUT "https://api.godaddy.com/v1/domains/$domain/records/$type/$name" \
    -H "accept: application/json" \
    -H "Content-Type: application/json" \
    -H "$headers" \
    -d "[ { \"data\": \"$currentIp\", " \
        + "\"port\": $port, \"priority\": 0, " \
        + "\"protocol\": \"string\", \"service\": " \
        + "\"string\", \"ttl\": $ttl } ]"
fi

if [ ! -z $dnsIp ] && [ $dnsIp = $currentIp ];
then
        echo "IP's are equal, no update required"
fi

With the above bash script saved at /usr/local/bin/updatedns, the following crontab entry is added to schedule repeated execution of the above script:
*/30 * * * * /usr/local/bin/updatedns

Now, I am able to ssh into my home computer using the following command:
$ ssh myusername@myhostname.mydomainname.com

My ssh clients are configured with my home computer’s host key signature beforehand, so that man-in-the-middle attacks can be detected.