Wednesday, February 20, 2013

Algorithmic Trading System Update 02/20/2013

Work generally prevents me from really testing out my system during market hours. I was able to take a day off recently and play around with my system during trading hours. I found a ton of bugs which I've now fixed. Among one of them was a problem where orders were not reconciling properly between the brokerage and ATS (Algo Trading System). Hence, one of my algorithms repeatedly fired buy orders! Programmers, me included, would like to think that we can write code without any bugs. Forward testing in my paper trading account is a necessary precaution.

My ATS is now currently able to run multiple strategies simultaneously. I know other errors will come up in the future when I begin expanding functionality. For example, each toy strategy currently only monitors one stock and none of the stocks overlap between strategies. Areas where I expect problems to occur are:

  • Pairs trading - monitoring and trading multiple stocks within same strategy
  • Overlapping stocks between strategies - potential problems occur when I'm +100 in one strategy and -100 in another strategy, meaning my brokerage has a 0 position, but my ATS has 2 positions.
With that said, I've started working on some other data projects as well! I've been doing some web scraping in order to pull precious information from the internet. Here are a list:
  • Ticker List from Google Finance - Basically, this uses the Google Finance screener to find stocks. I've only put in PE < 30, ROA > 5 and ROE > 10. This gives me a list of about 1500 tickers to work with.
  • Yahoo Daily Data - With the list of tickers that I got from Google Finance, I'm using Yahoo to pull End Of Day daily prices. This is amazingly easy since Yahoo provides data in a CSV format. They also provide split and dividend adjusted prices.
  • Morningstar Fundamentals - In my DCF worksheet here, I show you how I calculate intrinsic value using discounted cash flow analysis. The problem that I've always had was that this was relatively time consuming. It would take a good 2 minutes to open up the financial statements and plug the numbers into the spreadsheet. 2 minutes doesn't seem like a lot, but there are thousands of stocks out there! Those numbers update every 3 months, meaning I would have to keep doing it over and over again. So what I've done is write a 3rd web scraper which goes onto Morningstar and pulls the financial statements for the list of tickers.
  • Now that everything is in place, I just have to build the last piece. I will calculate the intrinsic value for every stock in my ticker list. There are currently 1500 in my list so far. Since everything is automated, I can have fresh intrinsic value data against the whole market all of the time. Comparing against the Daily price feed, I can now isolate the potentially undervalued companies very easily!!! Note that this is NOT for automated trading. This system basically highlights companies whose prices may have dropped near or below intrinsic value so that I can do further research. This will let me catch and research a lot more opportunities that I would normally not be able to cover.
The Google Finance, Yahoo, and Morningstar pieces have already been built. I've already popuplated my database with all of the financial statements form Morningstar. I'm currently still waiting for the daily prices download to finish from Yahoo. Who knew there would be so much data? I'll have to post some screenshots eventually, although there isn't really much to see. Most of the user interfaces are pretty bland and show only what I need to see. I'm full of ideas right now and too short on time.

2 comments:

  1. I am currently in the process of making my own ATS as well. Can you please share more experiences about your ATS ? It helps to make test cases.

    cheers
    sidharth

    ReplyDelete
  2. Hi Sidharth, I plan on posting up more details in the future, as well as some screenshots and implementation details. I'm writing this in C#, WPF, MSSQL, and using Interactive brokers's API. I'm using a lot of multithreading and locking, which is definitely a big source of problems and bugs. How are you going about yours?

    ReplyDelete