“Hello, World!’ for Quant Traders

high-frequency-tradingThis is the second blog post on my journey to learn Machine Learning. My first blog post talked about setting up the infrastructure. Now that the infrastructure is up and running, I’m able to get to the business of writing Python code.

Whenever you start to learn ANY programming language the first lesson is usually titled “Hello, World!“. It’s something of a tradition to teach the person the basics of the programming language to output something to the screen which is usually – “Hello, World!”

For quant/algo traders the equivalent of “Hello, World!” is calculating a simple daily moving average (DMA) and building some logic to buy or sell a security based on the DMA parameter.

Below is my “Hello, World!” Will this strategy make you money? Absolutely not. Will it help you build other strategies? Absolutely.

Leaving Apple Island

mrj-high-school-mac

From my high school yearbook (Washington Catholic 1991).

A couple of weeks ago a friend of mine, Sahil, blogged about making the switch from Apple to the Google ecosystem. I haven’t made the jump yet, but I’m on the same trajectory. When I tell people about it, the first question is “why?”

My first memory of an Apple computer was in the early 1980s when a family friend in Chicago had an Apple II and I was mesmerized by it. That green monochrome screen seemed so magical to me. Then for the next 20 years I used Apple computers on and off but was mainly an IBM PC guy.  In 2003, I bought the “lampshade” iMac and started to get hooked into the Apple ecosystem with the iPod, iPod Shuffle and iTunes in 2004. The big move came in 2005 when I bought a MacBook Pro as my “daily driver” and completely ditched the Microsoft clusterf$#% that was Windows.

When the iPhone was announced in January 2007, I knew I had to have it and waited till June when they launched it. By October of that year, I got rid of my BlackBerry and switched to the iPhone. Over the years, I bought more Apple products and slowly accumulated what I call “technical debt.”  As of today, I own the following:

  • iPhone 6
  • iMac
  • MacBook
  • iPad Mini
  • 2 – Apple TVs

Some things just didn’t work as advertised but I was too entrenched in the Apple ecosystem to leave. Case in point, some of the torrent video files I download are in the .mkv container format which you cannot natively play via iTunes and thus can’t steam to an AppleTV. So I was converting (the technical term is transcoding) all those files to an .mp4 format which iTunes could understand. I soon realized I was spending too much time making it all work.

I also noticed that many of the apps I used on my iPhone were by Google and I just loved the software simplicity of Google. So one by one, I moved everything over to Google and currently just using the iPhone 6 for it’s hardware.

  • Email -> Inbox by Gmail
  • iTunes/Music -> Google Play Music
  • Photos -> Google Photos
  • Calendar/iCal -> Google Calendar
  • Notes -> Google Keep
  • Safari -> Google Chrome
  • iCloud Drive -> Google Drive
  • Podcast -> Overcast (non-Google app, but Google is planning to release an update to Google Play Music that will play podcasts)

For streaming video content to my TVs I’m using Plex Media Server on my iMac. And my Sony TVs run Android, so I’m running Plex as an Android app on the TV. Now, I no longer have to convert the files and can natively play any file and stream it to my TV without all that extra work. As of now, I’ve stopped using my Apple TVs.

The first device I will switch out is the iPhone, the OnePlus 5 was just announced but really I’m waiting for the Pixel 2 from Google. Then over time I will switch my iMac and MacBook to Windows 10 based machines and the iPad Mini will get replaced with a Google Pixel C.

When I first started using Apple products I was mesmerized and felt I had reached paradise island. However, after years of being loyal to Apple it’s time to leave the island.

Learning Machine Learning: The Infrastructure

braindata-370x290In 2016, all I was reading about was big data, deep learning, artifical intelligence, machine learning, etc… soon I realized I needed to do more than just read about it. So for 2017, I decided it was time to take a deep dive into Machine Learning and see what all the buzz was about.

I haven’t programmed in 20 years but figured now would be a great time to restart. From all the reading I did in 2016 it was clear that the programming language of choice for Machine Learning was Python. I didn’t want to take a bunch of disconnected courses on Coursera and Udacity to learn about Machine Learning, instead I had a project in mind. When I moved to India 12 years ago, it was to launch an algorithm/quant hedge fund and I was the guy tasked with getting all the technology infrastructure (servers, data feeds, leased lines, datacenter access, etc…) in place and then over time I would learn to build trading algorithms. One thing led to another and I never got around to build those models. Over the years, I felt the algo/quant space was over done and it would be tough to get back into it. However there has been a resurgence with all of the new technologies involving Artificial Intelligence entering the space. So that was my goal, learn Machine Learning to trade the stock market.

I spent the first couple weeks of the new year putting together a plan to accomplish the end goal. The first thing was to take an introduction course on Python from Coursera. In parallel I was researching the algo/quant side and understanding what goes into building models, trading models and risk management. Not only did I want to learn about Machine Learning but whatever I did, I wanted to build it like it was going to be a billon dollar asset management company – highly redundant architecture, quality data feeds and top-notch risk management. It soon became clear this was something that was not going to get built over the weekend!

I was able to breakdown the work into 3 stages:
1. Infrastructure – cloud provider, servers, databases, data feeds, trade execution
2. Research trading models – researching and designing algorithms to produce “alpha”
3. Risk management – once the trade is made, constantly monitoring the position and making sure it fits within the risk model that has been designed. Or as they say within the industry Value at Risk (VaR).

This blog post will talk about the infrastructure and some of the technology I learned along the way.

It quickly became apparent that many of the Machine Learning experts were using something called Jupyter which is an open-source platform to share notebooks and run live Python code. It’s like an online version of an IDE (integrated development environment) that programmers use to build applications.

The next thing was to start getting data and lots of data onto the platform that I had built. For all the crap I talk about Yahoo, they have a pretty good finance section to download historical stock data for Indian stocks. Using pandas, a Python data analysis library, I was able to pull down all the price data I needed.

Some of the technologies I learned and implemented along the way:

  • Amazon Web Services – the cloud provider
  • EC2/Ubuntu – Linux distribution on an EC2 server
  • Let’s Encrypt – secure the server with a free SSL cert
  • Python – programming language
  • Jupyter – online IDE
  • pandas – data analysis library for Python (developed by an AQR employee)
  • Python scripting – used to get the daily price updates from Yahoo
  • RDS/MySQL – database where the price data resides
  • crontab – run the Python script at 2am in the morning
  • crontab.guru – a super simple site to understand the syntax for scheduling cron jobs
  • MySQLWorkBench – Software to interact with the MySQL DB
  • SQL statements – Structured Query Language (SQL) to manage and get data from the DB

Below is a SlideShare document showing the process of setting up the server on AWS:

Part 2 will talk about the research aspect of building trading models – the traditional methods and using the newer Machine Learning tools like Apache SystemML, Caffe2, Microsoft’s CNTK,  TenserFlow and Sciket-learn to name a few.

Thank You, Mukesh Bhai

55724156.cms
On September 1, 2016 the largest Indian company by market cap – Reliance, entered the telecom market…again. In 2002, Reliance launched its first mobile network and brought the per minute call rates down. This time around Mukesh Ambani launched Reliance Jio at the annual shareholders meeting and vowed to bring down the data prices.

I remember last year calling Vodafone to get a better 4G data package and they were offering plans with 2GB, 4GB and some with 8GB of data. And my cable TV provider Hathway was offering monthly plans for 60GB and 80GB of high-speed internet at 50Mbps. Mukesh bhai was not kidding about bringing down the prices. Today, Vodafone is offering me around 7GB a month and Hathway is now offering 200GB a month at the same price I was paying. I’m sure I can negotiate and get better pricing but I’ll wait and see.

When Jio was launched they gave it away for free so everyone could experience high speed internet, which was a brilliant move. It was a hugh gamble by Mukesh and team and I think it has paid off. Because, once you get a taste of high speed internet, you are hooked and it’s really tough to go back to 2G (edge) or 3G speeds.

Although Jio has many pricing plans, I think it’s all noise. They are focused on only 1 plan – the Rs. 303 monthly plan. For Rs. 303 you get unlimited voice calling across India and 28GB of data. 28GB of data per month is a hugh disruption not only for the Indian telecom scene but around the world. AT&T Wireless in the US recently announced their “unlimited” data plan that is capped at 22GB per month.

So why did Jio pick Rs. 303 as the price point that they wanted to focus on? Currently, the average mobile phone user in India spends about Rs. 141 per month, what the industry calls ARPU – average revenue per user. I think Jio is betting that the average Indian user will double their spend to over Rs. 300 a month but only if they find value in it. And from the looks of it, they are finding value in the service. Everywhere I look, people are glued to their phones and streaming content such as movies, music and TV shows. Jio has over 100 million free users and as of March 31, 2017 over 72 million people have applied for the Rs. 99 Jio Prime yearly program.

As I mentioned because of Jio the other telecom providers have dropped their prices as well. Below is a quick comparison:
Jio – Rs. 303, unlimited voice calls, 28GB
Vodafone – Rs. 346, virtually unlimited voice calls, 28GB
Airtel – Rs. 349, unlimited voice calls, 28GB

And just for fun, let’s compare how these plans stack up against the US wireless carriers:
Sprint – Rs. 3888 ($60), unlimited calling, 23GB
T-Mobile – Rs. 4536 ($70), unlimited calling, 28GB
Verizon – Rs. 5184 ($80), unlimited calling, 22GB
AT&T Wireless – Rs. 5832 ($90), unlimited calling, 22GB

I would like to take this opportunity to thank you Mukesh Bhai for changing the telecom game in India not once but twice. I run by your house almost everyday and think of two things as I pass, just how fat is your internet pipe and why do your Z level security agents not like when I try to run on your sidewalk. Or is your fiber optic cabling located under the sidewalk?

Google Takes A Run At The iPhone

667Over the past several weeks it was widely reported that Google would be launching a new phone, the images and specs were leaked online. However, when the Pixel and Pixel XL were launched this week many people stood up and took notice.

Why? Because the Pixel phones are the first serious attempt to dethrone the iPhone. Back in 2007, when Android and iOS were announced to the world both companies took a very different path in how they would market the operating system. Google decided to focus on the Android software and left the hardware to the contract manufacturers in China. As is typical of Apple, they wanted to control and own the entire experience of software and hardware. Here we are 9 years later and it looks like Google has also started to drink the same kool-aid that Apple has been drinking.

In 2010, Google launched the Nexus line of phones and tablets but that product line is very different from the Pixel. The Nexus phones were running stock Android and Google gave the contract manufacturers some guidelines on the technical specifications but were very hands off. The Pixel line takes a page from the Apple playbook and Google has complete control of both hardware and software. Based on the technical specs the Pixel is a worthy competitor to the iPhone 7 and both are priced identically. The Pixel 32GB and the iPhone 7 32GB are both priced at $649…very ballsy of Google if you ask me.

Apple may have the hardware and software integration down to a science but Google has a couple more tricks up its sleeve. The Pixel line has 4 things it can tightly integrate:

  1. Hardware
  2. Software
  3. Project Fi – Google’s own wireless carrier. (technically it’s a mobile virtual network operator – MVNO)
  4. Cloud services like Gmail, Photos, Drive, Maps, etc…

Over the next 6 months, we’ll see how the Pixel performs and if Google can finally get their hardware story in order. Because so far it has been a complete disaster with fragmented products, no clear vision and group in-fighting. Which means it didn’t have time to innovate or release product quickly enough.

Below is a list of the hardware they sell and there is NO single website that lists everything that Google sells which just seems stupid to me. But, that just shows how fragmented the various hardware groups are within Google.

  • Chromebooks – laptops that run Google Chrome as the operating system
  • Chromecast – device to stream content to your TV or speakers
  • Google Daydream – virtual reality viewer (announced this week)
  • Google Home – voice-activated assistant, similar to Amazon Echo and Apple’s Siri (announced this week)
  • Google Wifi – wireless mesh network routers (announced this week)
  • OnHub – a router made by Asus and TP-Link
  • Nest – thermostat, smoke alarm, indoor camera (Dropcam) and outdoor camera
  • Nexus – a line of phones and tablets
  • Pixel Phone (announced this week)

The good news is that six months ago they hired Rick Osterloh away from Motorola/Lenovo. At Google he is the goto guy for anything related to hardware and supposed to get their hardware house in order. I believe the Pixel phone might be a turning point for Google and potentially turn them into a hardware powerhouse as well.

I've Been Designing Apps All Wrong

ola-luxFor the past several years I’ve been advising many startups on their technology vision and strategy. Invariably, I would get pulled into their design meetings for their apps and would happily give my thoughts on the interface, flow and usability of the app. I would spend countless hours with the team on the consumer facing app and then I had an incident with an Ola driver and realized I was going about it all wrong.

A month ago I got into an Ola cab and when the driver tried to start the trip he couldn’t. Apparently, the language on the app had changed from English to Marathi and he couldn’t proceed further. The Ola driver handed me his phone to see if I could fix the language setting and I couldn’t. Instead, I some how started the trip and ended the trip in a span of two minutes.

The driver called Ola customer service for assistance but the guy on the other end was very rude to the driver. I took the phone and said it was not the drivers fault as the language setting had changed and there was no way to get to the menu option he was talking about. The call center agent was very nice to me and told me to hand the phone back to the driver. Again, the call center agent got very angry with the driver and asked him why he hit the buttons and instead should have called customer service first.

I’ve seen this scenario played out so many times and I’m not sure why I didn’t pick up on it earlier. I can’t tell you how many times I’ve heard people complain about the Flipkart and Snapdeal seller panel. While their consumer facing website and apps are fine, the sellers that spend the most time on their websites are left using a sub-par product. On the other hand, I’ve heard rave reviews of Amazon’s seller panel which is expected since they have had 20 years of experience to perfect it.

Before my Ola experience I would rank in the order of importance the interfaces as 1. Consumer 2. field services agent (cleaner, driver, delivery person, beauticians, etc…) 3. call center agent. Now, I’ve completely flipped my thinking and reversed the order.

That Ola interaction made me realize that a lot of time is spent on the consumer facing app and very little time or thought on the call center agent interface or the field services app. Of course, the customer is king but if you don’t empower your employees and make their lives easier it makes it very tough for them to deliver the customer delight and 5 star rating that everyone is chasing.

You Down With OTT?

Back in 1991, I was a freshman at Indiana University and the first few months were a haze with my new found freedom. When I look back to that time the one song that stands out is Naughty By Nature’s “You Down With O.P.P.” It was THE party anthem back in the day. You can visit the Genius page for the lyrics to understand why.

Recently, on one of my morning runs “You Down with O.P.P.” started playing and it got me thinking about a similar sounding acronym – OTT. Over-the-top (OTT) is a concept that you can thank the iPhone for ushering in and in the process opening up the mobile internet to anyone and everyone. Let’s first go back in time before we can thank Steve Jobs and Company.

15-20 years ago if you had a mobile phone you were at the mercy of your phone carrier such as Vodafone, AT&T, etc, some would even say you were a hostage. The reason is because the phone carriers had all the power back then, they decided which phones would be allowed to connect to their network and more importantly they would only allow certain “apps” on those phones. Today, if you are at the top of the Apple App Store or Google Play Store you are golden. Back then, you had to cut deals with the carrier to be “on deck”, meaning you would get valuable screen presence on their phones and in the process handover a large chuck of revenue to them. Or in many cases there was no “app” but just an SMS code you could send to get information like horoscopes, stock quotes or other bits of information that the carrier would monetize from the content providers.

Then Apple released the iPhone for sale in June 2007, which was really Apple’s trojan horse into the AT&T network. When the iPhone was first launched there was no App Store, the only apps available were the ones that Apple shipped with iOS. A little over a year later on July 10th, 2008 Apple launched the App Store and that set in motion a whole new industry – the app economy. Multi-billion companies were created like Snapchat, Ola, WhatsApp, Uber, WeChat, etc…

It meant that apps could be created and would automatically connect to the internet without needing the prior approval of the carrier who previously called the shots. In short, these apps went over-the-top (OTT) of the carrier. Today, these carriers are essentially “dumb pipe” providers and much of the revenue and intelligence is with the app providers. So yes in fact, “We Are All Down With OTT”.