q/kdb+ api for getting market and financial data from IEX

Few months ago, I wrote an api for getting market and financial data from IEX in python. As discussed earlier, IEX makes a lot of its data available to the public through its webservice api (link).

In this post, I will show you how to use the api I wrote in q/kdb+. Let’s get started.

You can find the code here.


Use this function to get last trade data (price and size) for one or more securities.

sym  price  size time
AAPL 174.66 100  2017.11.10D20:59:58.008999936
IBM  149.18 300  2017.11.10D20:59:59.724999936 


Python api for getting market and financial data from IEX

Most of you have probably heard about IEX: The Investors Exchange. IEX is the exchange started by Brad Katsuyama who was the protagonist of Michael Lewis’s famous book Flash Boys (review). Just last year, IEX scored a major win when SEC approved its application to register as a national securities exchange. As time passes by, IEX continues to gain more and more market share.

Just like any other exchange, one of IEX’s most valuable asset is the market data generated by all the trading. However, unlike other exchanges, IEX makes its data available to public for free via web API. On February 22, 2017, IEX wrote a blog post announcing release of its web API. Since then, IEX has made quite a few enhancements and added support for newer datasets as well.

As of today, some of the data that IEX provides includes:

  • pricing data (latest trade and quote data as well as summary data going back up to 5 years),
  • reference data,
  • new data,
  • earnings data, and
  • financial data.


A brief history of ECNs

What comes to your mind when someone mentions ‘ECNs’? Stock exchanges? NYSE and NASDAQ? Prior to reading Scott Patterson’s Dark Pools, I knew very little about Alternate Trading Systems (ATS) and how famous public exchanges such as NYSE and NASDAQ came to be.  This post is not meant to be a detailed history of (US) trading venues but instead to provide you with a brief overview of different ECNs that exist or existed and how they led to today’s behemoth trading venues.

What are ECNs?

ECN stands for electronic communication network. An ECN is an automated system where client orders are matched. ECNs eliminate the need to interact with a middleman, such as an exchange market maker, to buy or sell securities. ECNs earn money by charging users a fee for each transaction. While public exchanges have fixed hours dedicated to trading, ECNs are usually open 24 hours and hence, facilitate after-hours trading.


My experience at The Trading Show – quant, automated trading and big data conference

I was lucky enough to get a complimentary pass to The Trading Show from one of our vendors – OneMarketData. They were one of the sponsors and had some spare tickets. The Trading Show is a conference on “quant, automated trading, big data and high performance computing (HPC)”. I have never attended a conference at such a large scale so it was definitely a new experience for me. The event was hosted at Three Sixty Tribeca.

I spent the entire day attending keynotes, panel discussions and round-table discussions, and networking. I will give you a brief summary of what each session covered. For reference, this was the agenda.


Understanding types of market data

You can, most likely, work with market data without knowing much about the data itself. You can capture it, save it and deliver it to your clients who can use this data to do transaction cost analysis, trade surveillance, P&L and a lot of other stuff. But in the long run, you will find yourself in a position where knowing the data inside out would help a lot. It can even be the deciding factor in who gets the next promotion! To be able to do your job most effectively, it’s highly crucial to know the data itself. Understand life cycle of a trade: how is the data generated, how it is provided and how it is analyzed for different purposes by different teams.

I will be writing a series of posts about market data itself. This post will focus on types of data such as trade, quote and market depth. In a future post, I will cover types of securities as well.

Most common way of approaching this topic is probably by starting from the higher level with trades and quotes and then diving deeper into depth and orderbook data. However, I am going to explain in the reverse order because that’s the natural flow of the data. It will help you understand market data with respect to the trading life cycle.

Note: I excluded time stamps from examples below as they were unnecessary.