Get Back Adjusted Historical Data for Amibroker using Python and Tiingo api

Home » Blog » Tools » Get Back Adjusted Historical Data for Amibroker using Python and Tiingo api

In this post I will share a quick way for Amibroker users to update quotes using split and dividend back adjusted data from a fairly new provider, Tiingo.com. Although we do run our investment strategies on our very own QuantTrader, we use various other tools to analyse markets, including Amibroker.

The problem: Where to download dividend adjusted data

Many Amibroker users build strategies that rely on dividend adjusted historical data. At this moment it is difficult to find similar data since Yahoo, as well as many other sources, do not back-adjust prices to include dividends. A solution is to use free (or rather donation-based) EOD data from Tiingo.com.

What happened to the free Yahoo finance historical data?

Yahoo! finance has changed their Yahoo Finance API and the way the data is delivered. This has disrupted the workflow of many self-directed investors that use Excel or Google sheets to track their holdings. It has also created problems for users of financial software that use Yahoo’s service.

The service has not been discontinued. Rather, it has been changed. You can still retrieve stock, ETF, mutual funds and currency historical data. From what we can see so far, the data is in json format, adjusted for splits but not for dividends, although the dividend information is provided in the data and can be retrieved (as of 6/3/2017).

If you use Amibroker, you can use the updated Amiquote to retrieve data using the new Yahoo API. It will not be dividend-adjusted (just try to download a bond ETF like “TLT”). If you want to continue an existing workflow of dividend-adjusted data, you can try this solution.

You will need:

  1. Amibroker.
  2. A free account at Tiingo.com to get a Token #
  3. A way to run the following Python script.

Tingo API  docs for daily prices: https://api.tiingo.com/docs/tiingo/daily

 

 

 

 

 

2017-06-03T16:30:26+00:00 By |8 Comments

About the Author:

Vangelis has been involved in quantitative research and development since 2007. He blogs under the 'Sanz Prophet' alias. He has built, run and tested literally thousands of trading systems using Matlab, Python, C#, QuantShare and Amibroker and has contributed as a researcher/programmer in academic papers. His quantitative blog has been part of the “Whole Street” quant blog aggregator since inception. He holds a B.A. in Economics & Theater Arts from Cornell University and an M.F.A. in Motion Picture Producing from the Peter Stark Program at the University of Southern California.Before entering the financial world Vangelis worked as a film and commercial director and collaborated with agencies such as Bold Oglivy, Adel Saatchi and Saatchi and clients including Pepsico, P. & G., Hyundai and others.

8 Comments

  1. Mark Lipsman 06/04/2017 at 1:36 pm - Reply

    I posted this once, but it seems to have gotten lost:

    The xltraders Yahoo group has also been discussing this (I imagine there are discussions all over the web). Randy Harmelink, who posts frequently there, says this about the new data feed: “Unfortunately, it’s in JSON format, so needs to be extracted piece by piece. Since they’re currently not adjusted for dividends, I’m doing that myself, since the data is already available there.”

    I looked at Tiingo, but they don’t seem to have historical data, which I use. Someone on xltraders suggested intrinio.com, and I also found eoddata.com. Both offer free data, but the latter charges for more than 30 days of historical.

    Intrinio seems promising–they have a limit of 500 free data points per day, including historical. It works a little differently–you have to sign up for a free account and login when you want to download. They have an Excel Add-in, but it only works with Excel 2010 and later, so I have to update my Excel, which won’t happen till next week.

    You can take a look at their available functions here:

    http://docs.intrinio.com/excel-addin#intrinio-excel-functions

    and their dividend functions here:

    http://blog.intrinio.com/how-can-i-see-a-companys-dividend/?utm_source=Intercom&utm_medium=Support&utm_campaign=Intercom%20How%20can%20I%20see%20a%20company%27s%20dividend%3F

    With the Yahoo APIs, I had an Excel whiz from upwork.com, Eugeniu A, do some custom work to create an Excel downloader for daily, historical, and dividends. I posted it at xltraders, but obviously it’s now useless. I’ll get it modified for the new data source and will again post it at xltraders if anyone wants it, probably within the next couple of weeks. And if anyone needs custom Excel programming, I can recommend Eugeniu highly–he lives in Moldova, does great work, speaks excellent English, and has very reasonable prices. https://www.upwork.com/ab/profiles/search/details/~01c9afeb30d4c02e9b/profile

  2. Vangelis 06/04/2017 at 2:42 pm - Reply

    Thank you Mark for the feedback. Tiingo.com does have daily div-adjusted historical data. We actually use it currently.
    Yahoo does return a json file. An excel coder should be able to extract the prices. Take a look. Lots of nice info one can retrieve:

    https://query2.finance.yahoo.com/v8/finance/chart/SPY?formatted=true&crumb=&lang=en-US&region=US&period1=959115167&period2=1495030581&interval=1d&events=div|split&cors

  3. Mark Lipsman 06/04/2017 at 5:36 pm - Reply

    Thanks, Vangelis. On the Tiingo site, where do they mention historical data, and how many years are available? All I see is a reference to daily prices on their API page (https://api.tiingo.com/), and I don’t even see that on the list of their fundamental data points (https://www.tiingo.com/data/fundamentals).

  4. Mark Lipsman 06/07/2017 at 1:59 pm - Reply

    After looking into Tiingo a little further, you’re right, it is a better deal. Intrinio’s Excel add-in is convenient, but they provide only 500 free data points per day, and unless you have more than a few tickers, it would require some juggling to avoid exceeding that–maybe daily and dividends one day and historical prices the next. Even then, you have to pare down your data set to minimize the number of points requested. (They offer unlimited data for $40 a month.)

    Tiingo has a much higher cap, and it’s monthly rather than daily. The average user probably wouldn’t exceed it. They ask for a $7/month donation, but it’s not required and even so, is very reasonable compared to what other sites charge. It’s possible to get daily, historical, and dividends in two calls, according to the page you linked above:

    Daily: https://api.tiingo.com/tiingo/daily//prices

    Historical (including dividends–“divCash”): https://api.tiingo.com/tiingo/daily//prices?startDate=2016-1-1&endDate=2017-1-1

    Then the file needs to be parsed to extract the data. (A free account is necessary for these to work.)

    I’m having my Excel downloader updated to use these and will post it on XL Traders when it’s ready.

    Thanks again, Vangelis–this is a really good source.

    Mark

  5. Mark Lipsman 06/07/2017 at 2:01 pm - Reply

    These didn’t come out right when they converted to links above–I’ll try square brackets instead of angle brackets:

    Daily: https://api.tiingo.com/tiingo/daily/%5Bticker%5D/prices

    Historical (including dividends–“divCash”): https://api.tiingo.com/tiingo/daily/%5Bticker%5D/prices?startDate=2016-1-1&endDate=2017-1-1

  6. Mark Lipsman 06/07/2017 at 2:03 pm - Reply

    That’s not so good either. The ticker goes between “daily/” and “/prices”.

  7. Vangelis 06/07/2017 at 3:43 pm - Reply

    Hi Mark. Glad you found this useful. I myself have to give credit to LI users Alberto Magnani and Peter V as they pointed out Tiingo (see forum). I like it when we all share and benefit from each other’s research.

Leave A Comment