News Based Trading
Introduction
News based trading, also known as sentiment analysis trading with emotions based on the news, is one of the prime factors that affect the prices, volume, and volatility of financial assets in the market.
In news based trading, traders try to take advantage of the temporary mispricing of a security in the market. This mispricing is usually due to some events or news that have not yet been factored into the price of the security.
For instance, the news based trading depends on the news related to the-
- Quarterly results of a security
- The economic figures released by governmental or statistical agencies
- Out of the blue merger & acquisition announcement
Working of news based trading
Algorithmic news-based trading involves the use of algorithms to interpret news articles or news mentioned in tweets etc. These algorithms scan the articles using keywords, process the data, and determine the underlying meaning.
They assign scores to quantify the sentiment of each article, considering whether it is positive, negative, or neutral. Additionally, the algorithms consider the relevance and source of the news article based on assigned keywords, enabling them to make informed trading decisions.
The challenges with news based trading include not having timely and accurate information with real time data, leading to noise in news analysis and/or market inefficiency. This can lead to erroneous signals and thus an erroneous trade. Therefore strong risk management is required while trading with the news.
Python code for fetching news via tweepy library
The python code goes as follows.
# Import libraries import os import sys sys.path.append("..") # Import the get_tweepy_api from the sentiment_analysis_quantra module # The code of this module can be found in the downloads (last section) of the course # You need to edit sentiment_analysis_quantra.py file and add your Twitter tokens manually before you continue from data_modules.sentiment_analysis_quantra import get_tweepy_api api = get_tweepy_api() # You can fetch the tweets between specific dates with this python code below. tweets_search_results = api.search(q = '$AMZN', since='2017-1-1', until='2017-1-5') len(tweets_search_results)
Output:
0
To fetch the tweets in the past 1 day, you just need to update the since and until in the above code.
For any queries, drop us your comments on the community.
Explore our course on News Sentiment Trading Strategies to learn to automate extracting of sentiment from news articles. Moreover, you will learn to create 4 trading strategies. Also, learn how to automate the process of utilising news to identify the general sentiment using VADER and LLM models and trade accordingly. Additionally, you will explore how to optimise this strategy using technical indicators.