May 27, 2016

OAuth 1.0a for ETrade API using Haskell

Lately, I have been interested in creating a market quotes receiver which later on, using a DB and ML algorithms, will analyze the market movements and provide suggestions for better investments. But initially, I had to connect to an API provided, for which I found ETrade, which is an Online Broker stablished in the USA which has a REST API to request quotes, account data or even place orders to the Stock Exchange.

I have been long time fan of Haskell, but I had never engaged with a long term project to learn more about the language, the platform and all its possibilities, although I have a book pending to continue writing about Haskell FRP for Game development, this project seems like a good time/learn investment for long term goals: apply category theory, learn to trade stocks, explore Machine Learning algorithms and many more.

For all that, I started doing authentication to the platform, considering that I had to email ETrade customer service to request a Auth public/private key, then later with those in file, I created this script which will perform all necessary steps to retrieve a access token, which would allow me to query everything within the Sandbox: so here is the code: