Click here to Login









How to make sure your Historical Price Data is Split Adjusted

Updated on 2013-01-16





In order to update your historical EOD database, you must download new quotes every day. You can use the default downloader (Historical Stock Market Data) or any item that gets data by symbol (one request per ticker symbol). However, the biggest issue with these items is that the downloading process takes some time.

One solution would be to use downloaders that get data by date. Instead of sending a request for each symbol, these downloaders send a request per date (Quotes of all symbols on that date).
Since you are updating your database every day, you will only need one request to get latest data.

The problem with these kind of downloaders is that if a stock split or dividend occurs, you will end up with up/down gaps in your data. This is problematic particularly for those who perform backtests and analysis and those who require split and dividend adjusted data.

The idea of this blog post is to get daily stock updates (quickly), detect stocks with recent up or down gaps then download complete history data for those stocks only.


Historical Stock Market Data

If you are new to QuantShare or if you want to create a new fresh account, the first thing you must do it download the complete historical data for all your stocks.
This can be accomplished using the default downloader (Historical Stock Market Data) for example. The downloading process may take few hours but you have to do it only once.

- Select "Download" then "Download Manager"
- Select "Historical Stock Market Data" item then click on "Open Selected Downloader" button
- Select a start and end date and uncheck "Last Download Date" and "Last Symbol Date"
- Select "Symbols" tab then remove any existing condition to instruct QuantShare to download data for all available stocks
- Click on "Start Downloading"


Daily Quotes

To get latest quotes for U.S. stocks, you can use the following downloader: Daily US Stocks Data. You should run this downloader once a day to get yesterday's quotes.

The download process is quick but you can end up with unadjusted data because only the most recent quote is added to your database.
In order to fix this, you must run the historical downloader again for stocks that recently had a stock split.

There are two solutions:
- Either you download or import stock splits data, detect stocks that recently had a split then download data for these stocks (most complicated solution)
- Or, you can search for stocks that recently had an up and down gap and download historical price data for these stocks. Up and down gaps could be caused by an increase in the volatility of a stock or by a stock split.

The second solution will be explained in details in the next paragraph.


Detecting Recent Up and Down Gaps

QuantShare creates and stores pre-defined variables in an internal database. These variables are calculated for each symbol and the calculation takes place each time new data is saved.

For example, if you download historical data for Google then QuantShare will automatically calculate the following measures:
- Number of quotes
- Date of last quote
- Date of first quote
...

These variables can be used later to quickly select stocks in any QuantShare plug-in (for backtesting, screening, downloading...)

Here, we are particularly interested in one variable, which is: "Max %Gap in last 5 bars".
This variable calculates the maximum up or down gap for any stock in the last five bars.
We can use that variable in the historical downloader to get stocks that recently had a gap up or down higher than 10% for example.

First, let us create a new historical downloader. To do that, go to the following item (Historical Stock Market Data), download it, install it then when prompted to confirm the item name, rename that item so that you can have two historical downloaders in your account; one to get historical price data for all stocks and one to get historical price data for those with recent gap.

After creating the second downloader, follow the next steps to complete the setup:
- Open the new downloader in the download manager
- Select "Symbols" tab
- Remove any existing conditions
- Click on "Add a Condition" then select "Quotes"
- Click on the cell under "Values" column then select "Max %Gap in last 5 bars"
- Next to "Interval" select "-100" as minimum value and "-10" as maximum value (Down Gaps)
- Click on "Add a Condition" then select "Union"
- Click on "Add a Condition" again then select "Quotes"
- Click on the cell under "Values" column then select "Max %Gap in last 5 bars"
- Next to "Interval" select "10" as minimum value and "1000000" as maximum value (Up Gaps)




You have now instructed your downloader to get historical data for stocks that have increased more than 10% or decreased more than -10% in the past 5 bars. This allows you to get historical data price for every company that recently issued a stock split.

To summarize the process:
- Download historical price data for all stocks (only once)
- Use the daily downloader to get latest quotes (every day)
- Use the second downloader to get historical data for companies that may have issued a stock split recently (every day)












one comment (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1461 days ago

Profile Graphs
Posted 1566 days ago

QuantShare
Previous Posts

More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.