– Amazon S3 Glacier Tree Hash

February 20th, 2022

I am planning to implement a bare-bones system to backup pictures, videos, financial records, and software development projects. Among Google, Microsoft, and Amazon, I find that the long term storage services offered by Amazon to be cost effective at $0.0036 per GB per month or $3.60/mo for 1TB. Amazon S3 Glacier also provides a mechanism for fetching an inventory of files uploaded to their service. This inventory includes a tree hash or checksum for each “archive” that is uploaded. (At $0.00099 per GB per month or $0.99/mo for 1 TB, an even more cost effective alternative is using the S3 Glacier Deep Archive storage class for data stored in Amazon S3 buckets. Amazon S3 Glacier is different from Amazon S3 with the S3 Glacier Deep Archive storage class in that the former deals with vaults and archives whereas the latter deals with buckets and storage classes. Unfortunately, the Amazon S3 service does not provide a reliable mechanism for retrieving checksum data.)

Amazon claims their S3 services achieve 99.999999999% (“eleven nines”) durability. I am uncertain that I can achieve the same level of durability independently. As part of my backup system, I need to periodically check for differences between my local files and my backups. To confirm that local copies of archives uploaded to Amazon Web Services are identical, I implemented a standalone Python script that generates the Amazon S3 Glacier tree hash checksum:

The script can be used with a command line interface as follows:
python3 inputfile.bin

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:


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:
Source Code: sha256.js, sha256main.js