Stock Options Contracts are an interesting instrument. If the underlying stock were to stay the same price the value of the decays as a function of distance to the maturity date. Almost like a linear line. Too far away from the underlying strike price? No one would be interested.

Both money and interest lay within an envelope near the strike price. Over time the underlying strike price will most likely move. As the price moves away from an option interest will naturally wane and thus devalue. When prices move towards placing the asset in the money the instrument will generally rise in value. Often as an instrument approaches being in the money the value of an option will rise very quickly.

For put options, in the money is defined as the strike price being below the contracted strike price. If the backing instrument continues to fall the will begin to fall outside the envelope and devalue again. Worst case scenario for an underwritter is being stuck with a large difference between the contracted strike price and the underlying stock’s strike price while in the money. Best case it to get in a reasonable price and exit when the option begins to rise above a cretain treshold.

For a stock I would use a trailing stop with a reasonable tolerance to capture the rising value. I was not able to find a way to express this concept to my brokerage when trying to issue a trailing stop to capture value on the downward movement of the put options. Ideally after exit you can reevaluate the position and determine if the asset is still where you want. Not being able to issue this order has been the largest hole in my trading strategy.

Roadmap: The Easy Part

I would like to implement an application the following phases:

  1. Implementing a trailing stop algorithm against an option. Entirely command line driven to prove the software works as expected. The inputs are effecitvely the option symbol and break even point. If the value beings to rise while above the break even point it just complains. Otherwise when it detects a drift above the line it will notify the user.
  2. More robost notification system: The program should notify me via Slack on either of the terminal conditions.
  3. Operational readiness: Modify the application to run under K8S with tracing. At this point it would officially take the application off my device and place it in my operational cluster.
  4. Autonomy: Give the application the ability to submit an order to liquidate the option when the threshold has been execeeded.

Implementation: The Hard Part. Also a developer log.

In general I default to NodeJS since it has a pretty good balance of libraries, performance, and developer expierence. Normal Node project setup and such. Since naming things is hard I’m just calling it Maurice after a founder of the Dutch East Indian Company since they started this whole stock trading thing. I am torn about uploading this to Github but very well might.

There are to main components for observing the change: a unit repsonsible for managing and updating threshold; and a unit repsonsible for interperting a stream of quotes into the threshold. This allows a set of quotes to be represented as a stream for processing, error management, and feedback. Not that the markets cares about the stream :-D .