Inspiration

Options trading or derivative trading gives the right but not the obligation to exercise on an equity currently trading in the market. Investors world wide using options to hedge their positions against market volatility and also capitalize on possible stock devaluation. Options trading has being a huge revenue generating product in the financial industry. However, individual investors who doesn't have a big financial background may not have a good understanding in options. As a result they may miss opportunities to increase their portfolio value. Investors gets to buy or sell and option in the market. Since options are derivatives of equities, they are priced using different mathematical models. Our application gives the individual investor without much options trading background to price their options or to compare premium prices when they are buying an option in the open market.

What it does

It gets the current stock price and 2 years worth of market data. Using that data it extract parameters to call for Black Scholes Model. Those parameters for the

  1. Current stock price
  2. Expiration Date
  3. Strike price
  4. Volatility
  5. Risk free rate

By using there parameters it generates the premium price for an option. Option could be either call or put option.

How I built it

using markitondemand api we gets the current stock price and 2 year worth of history data for any ticker. We use highstocks.js open source library to parse the api data and generate an interactive plot. This plot allows user to interact with the data. WE custom designed a back end web server using TCL. The idea of a custom web server is to optimize the api calls by doing to get the latest stock price on a even on a high frequency trading day. TCL is used widely in the world wide web as a simple, easy to set up end points and can run in one file. Which gives the opportunity to the develoer to tweak the server and easy to debug. Jquery is used in the client side to make continuous ajax calls to the server. In this app user gets the opportunity to adjust parameters and gets the premium price on real time.

Challenges I ran into

The most serious bug was a formatting issue that arose when transferring data from the server to the client. The data was in the form of a JSON object returned by a third party API serving historical stock pricing data. The backend server is written in Tcl, and Tcl’s treatment of strings caused some confusion in terms of where braces were supposed to be present. At first it wasn’t obvious this was the source of the bug. The client wasn’t receiving enough data for meaningful debugging messages. After assuring myself the backend was receiving the correct data, I was able to tweak and hard-code some output into a format the client would accept. I worked backwards from this point until I had reconciled the issue and figured out where the bad formatting was taking place. In the end, it was Tcl’s treatment of strings that caused the issue, but also made it trivial to fix. Tcl does not discriminate between code and data, and thus provides excellent mechanisms for handling situation involving complex escaping. Despite this issue taking several hours to pinpoint, I think using Tcl on the backend was an overall gain in terms of productivity because it lays bare all implementation details; there are no magic underscores or restricting types to deal with; I spent surprisingly little time worrying about the backend apart from this bug.

Accomplishments that I'm proud of

We were able to give a valuable opportunity to individual small scale investors to use option pricing models used by large investment banks for free.

What I learned

nothing is impossible

What's next for Black Scholes Options Pricing Calculator

Adding a feature to contact brokers to execute derivatives

Share this project:
×

Updates