For one reason or another, some traders may require having two different set of symbols, one for each data source. Let me explain how to implement this in QuantShare by taking an example. The user in our example have two different data sources (Yahoo and Metastock). He wants to get historical quotes from Yahoo and from a Metastock database at the same time in order to compare it. He also want to have two symbols for each stock, one for each data source. This means that for example he may have "GOOG" for Metastock and "GOOG-Y" for Yahoo data. How to set up a metastock database Setting a metastock database is very easy in QuantShare. You can find full instructions here. Once your database folders are set, you can select whether to add new symbols to your database or not. Keep the option checked to add new symbols to your local database. Select a symbol and open a chart to display data from the new Metastock database. You should see "Metastock" printed on the chart (top-right corner) if the data comes from the metastock database. If you see nothing then the data is loaded from the local database and this also means that there are no quotes for the selected symbol in the metastock database. How to get historical data from Yahoo Historical EOD quotes can be downloaded from Yahoo using the following item: Historical Stock Market Data. This is QuantShare’s default downloader. This downloader gets symbol name from the "Name1" field. In case this field is empty, it gets symbol name from the default "Name" field. What is "Name1"? In QuantShare, there is the default field (Name) to store symbol names but there are also several other fields (Name1, Name2 and Name3). These fields can be used in case there are several variations of the symbol name. You can use them to store for example unique identifiers like the CUSIP and to differentiate assets with the same symbol name (Example: a US stock and an International stock). Creating a different set of symbols for Yahoo data We will keep original symbols for the Metastock database and update ticker symbols used by the Yahoo downloader. First, we must export the list of symbols and change the ticker symbol of each security. - Create a new basic watchlist and add all symbols that you want to use with the yahoo downloader - Right click on the watchlist then select "Copy all symbols to the clipboard" - Now, you must append "-Y" to every ticker symbol. You can automate that by copying the symbols list in Excel, adding "-Y" to a second column, copy it to all rows then merging the result by copying both all rows in both columns then pasting it in a text editor. - Perform the same operation to add the original name to each ticker symbol Example of Result: AAPL-Y;AAPL GOOG-Y;GOOG C-Y;C - Save the result in a file - In QuantShare, select "Symbol -> Import symbols from a file" - Type ";" next to "Data must be separated by" - Click on "Load File" and select the previously created file - Under "Symbols" tab, select "name" (first row) for the first column and "name1" for the second column - Click on "Create List" button at the bottom - Type a name then click on "Save" - When you are prompted to add the symbols to the current account, select "Yes" - Select the "Historical Stock Market Data" downloader in the download manager (This is the Yahoo downloader) - Click on "Open Selected Downloader" - Select "Symbols" tab - Remove any existing conditions then add a "Symbol Info" condition - Select "Name" under "Values" then type "*-Y" next to "Search:" This will allow you to select all stocks whose ticker name ends with "-Y". You should now have 2 ticker symbols for each stock. Example: AAPL and AAPL-Y GOOG and GOOG-Y C and C.Y … When selecting "AAPL", data from Metastock will be loaded, and when you select "AAPL-Y", data from local database (Yahoo data) will be loaded. Remember, we said that Yahoo downloader gets symbol names from "Name1" field and thus when downloading data for "AAPL-Y", it will in fact uses "AAPL" as symbol name. Comparing historical data from different data sources The best way to compare historical data from the different data sources is by plotting them on the same chart. - Create a new chart then select a stock (Example: GOOG) - Create a new pane by right clicking on the chart then selecting "Create new pane" - Right click on the new pane then select "Edit Formula" - Type the following formula then click on "Update Graph" s = name(); close1 = GetSeries(s, close); open1 = GetSeries(s, open); high1 = GetSeries(s, high); low1 = GetSeries(s, low); PlotCandleStick1(open1, high1, low1, close1, s, colorBlack, StyleSymbolNone); PrintChart('Symbol: '.s, '', BottomLeft, colorRed, colorTransparent, colorTransparent, 250); To create a line that shows whether there is a difference in OHLC prices, type the following formula: s = name(); close1 = GetSeries(s, close); open1 = GetSeries(s, open); high1 = GetSeries(s, high); low1 = GetSeries(s, low); diff = iff(close1 != close or open1 != open or high1 != high or low1 != low, 1, 0); plot(diff, "Diff");
|