To create buy and sell trading rules based on news, you need to download news data first. Fortunately, there are several news data downloaders available in the QuantShare sharing server. You can for example download news releases, articles, blog post titles, tweets...
Each downloader gets data for the ticker symbols you specify and stores it in a custom database. For example, the Historical Stock Market News item gets RSS feeds from Google, downloads more than 3 years worth of news items and saves the data in a custom database whose name is "google_news". This database contains three fields: date (news release date), title (The title of the news release) and description (A brief description of the content of the news release).
Here are some other interesting downloaders:
- Currency Pairs Calendar Data: Gets economic calendar events for the most traded FX pairs (including EUR/USD, GBP/USD and USD/CAD)
- Currency Trading News from Yahoo - Forex Market: Downloads trading news for several Forex pairs
- StockTwits: Downloads realtime tweets for the US stock market. You can use this item to get tweets for the Forex and futures markets.
- Recent Insider Buying and Selling for US Stocks: Retrieves insider trading news (buying and selling activity data)
- Stock News from Articles, Bloggers, Columnists, Traders and Analysts: Gets articles for U.S. stocks from a variety of blogs and online newspapers.
Now, let us download some news data using the Historical Stock Market News item.
- First, download this item from the sharing server (click on the above link, click on "Download" then follow the instructions)
- In QuantShare trading software, select "Download" then "Download manager"
- Select the item you have just downloaded then click on "Open Selected Downloader"
- In "Symbols" field, select one or several stocks then click on "Start Downloading"
How to display these news releases
There are mainly two ways to display the trading news releases you have previously downloaded:
- Database Editor
- Database Data Viewer
- Select "Data" then "Edit databases"
- Select "Custom" then "google_news"
- Select the "Databases" tab then select a symbol (stock, currency pair, futures symbol...)
Data is displayed on the right panel. You can add, remove and update rows or fields and export the data to CSV format.
Database Data Viewer:
- In the main menu, select "Tools" then "Database Data"
- Select "google_news" database to display news release for the active chart stock or for a list of stocks (Click next to "Filters" to update the symbols criteria)
This tool allows you to display news releases and lets you filter news by a specific keyword. To do this, type a keyword next to "Search" and select a field (Example: Title).
Note: To display stock trading news on a chart, click on "Show data on chart".
Create news-related trading rules
News data can be plotted on a chart, used in a screen or watchlist, backtested in a trading system or used in portfolio to generate buy and sell signals. You may even develop market composites based on it. Example: Number of news articles that contains the word "rise" for each trading bar across all stocks in the U.S. Stock Market.
There are several functions you can use to retrieve and analyze custom database data in QuantShare language.
For a complete list:
- Open the "Add Indicator" control (Right click on a chart, select "Edit Formula" then click on "Add Indicator")
- In "All Indicators" tab, select "database" category
The "GetDataCount" function for example calculates the number of items (News releases in this case) that occurred in each trading bar period.
The "GetDataStringCount" function returns, for each trading bar, the number of news releases that contains a given keyword.
Example of a trading system:
buy = GetDataStringCount("google_news", "title", "buy") > 0;
sell = GetDataStringCount("google_news", "title", "sell") > 0 or GetDataStringCount("google_news", "title", "down") > 0;
The above formula can be backtested using the simulator or added to a portfolio strategy.
Enters a long trade/order if a news release contains the word "buy"
Exits an existing position if a news release contains the word "sell" or the word "down"
Trading the news using advanced rules
To create advanced news based rules, you can implement your own indicators using "Create Functions" tool.
- Select "Tools" then "Create Functions"
- Click on "Add", type the indicator name then click on "Save Item"
- News data can be referenced using the "cFunctions.GetCustomDatabaseData" function.
Here is how to implement the built-in "GetDataCount" function:
VectorCustom vc = cFunctions.GetCustomDatabaseData("google_news", "title");
for(int i=0;i < vc.Length;i++)
result[i] = vc[i].Length;
Here are some advanced news based trading indicators: (You can edit each indicator to see how it is implemented)
- News parser function: Returns whether a news release contains a specific word from a list of words passed to the function.
- News Sentiment Indicator: Calculates a sentiment measure by counting the number of bullish or positive words and then subtracting this value by the number of bearish or negative words.
- Word Occurrence in News Titles - Quantitative Trading Analysis: This function facilitates the optimization of news-based trading strategies. Read the trading object description for more information.
These functions can be applied, in day trading and EOD trading, to create quantitative strategies based on news releases, tweets, economic releases, futures reports...