{"id":149920,"date":"2022-08-17T09:00:00","date_gmt":"2022-08-17T13:00:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=149920"},"modified":"2022-11-21T09:57:23","modified_gmt":"2022-11-21T14:57:23","slug":"tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/","title":{"rendered":"Tweepy &#8211; Generate Sentiment Trading Indicator using Twitter API in Python"},"content":{"rendered":"\n<p><strong><em>Excerpt<\/em><\/strong><\/p>\n\n\n\n<p>Social media and Twitter in particular are alternative data sources that are being used extensively to take the pulse of market sentiment.<\/p>\n\n\n\n<p>In this post we will review the Tweepy library for fetching real-time and historical data from Twitter. We will go through the following topics:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Twitter and Sentiment Analysis<\/li><li>The impact of social networks on market trends<\/li><li>What is Twitter?<\/li><li>A Python Twitter API, tweepy<\/li><li>How to install and set up Tweepy?<\/li><li>Authentication on Twitter API<\/li><li>How to use Tweepy to get tweets<\/li><li>Tweets pagination with cursors<\/li><li>Building a naive sentiment indicator<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-twitter-and-sentiment-analysis\">Twitter and Sentiment Analysis<\/h2>\n\n\n\n<p>Social networks and Twitter in particular are alternative data sources that are being used extensively as a market sentiment indicator.<\/p>\n\n\n\n<p><a href=\"https:\/\/quantra.quantinsti.com\/course\/trading-twitter-sentiment-analysis\" target=\"_blank\" rel=\"noreferrer noopener\">Sentiment analysis of news and social networks<\/a>&nbsp;is a comprehensive area of study where natural language processing is of vital importance to extract quantitative information from unstructured information sources.<\/p>\n\n\n\n<p>We would need a book, if not an encyclopedia to describe the whole process of sentiment analysis and integrate it into our trading system.<\/p>\n\n\n\n<p>So, in this post we are going to start with the first step, extracting information from Twitter to feed our Natural Language Processing algorithms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-impact-of-social-networks-on-market-trends\">The impact of social networks on market trends<\/h2>\n\n\n\n<p>Social networks have emerged as &#8211; mainstream communication media where users can be both consumers and creators of information.<\/p>\n\n\n\n<p>Users are continuously generating data, either passively as mere receivers of information where our interest, reading time, etc. are recorded, or actively by creating content, expressing our interest in another content or even sharing it.<\/p>\n\n\n\n<p>In addition, sufficiently interesting or shocking news can literally travel the world and become a global trend. Users with millions of followers can also create trends or impacts on specific topics.<\/p>\n\n\n\n<p>The analysis of this type of data has been the subject of study for several years, having generated abundant academic material to model the flow of information, their interpretation and the extraction of mood, trends and forecasts.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-s-twitter\">What\u2019s Twitter?<\/h2>\n\n\n\n<p><a href=\"https:\/\/twitter.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Twitter<\/a>&nbsp;is a microblogging social network where users interact by posting information, sharing through retweets or showing their interest by marking information as a favourite.<\/p>\n\n\n\n<p>It also has a hashtags (#) mechanism to tag content with the ability for the message to reach many more people than just followers.<\/p>\n\n\n\n<p>According to the<a href=\"https:\/\/www.internetlivestats.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;Internet Live Stats<\/a>, Twitter has more than 372 million active users, and the number is continuously increasing, and more than 700 million tweets are posted every day.<\/p>\n\n\n\n<p>There are users with millions of followers whose tweets can have a huge impact on&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/course\/getting-market-data\" target=\"_blank\" rel=\"noreferrer noopener\">markets<\/a>. The cases of<a href=\"https:\/\/www.researchgate.net\/publication\/324203948_Using_social_media_analytics_The_effect_of_President_Trump's_tweets_on_companies'_performance\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;Donald Trump<\/a>&nbsp;and<a href=\"https:\/\/www.researchgate.net\/publication\/349007665_How_Elon_Musk's_Twitter_activity_moves_cryptocurrency_markets\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;Elon Musk<\/a>&nbsp;are well known, where a single tweet can create shocks or booms.<\/p>\n\n\n\n<p>On the other hand, hundreds of users can generate heated debates about a company, which creates trends about the mood of the investors. Debates with thousands, if not millions of passive and active viewers.<\/p>\n\n\n\n<p>Twitter has therefore become a relevant source of alternative information for analysts who believe that social media sentiment can increase their edge in the markets.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-a-python-twitter-api-tweepy\">A Python Twitter API, Tweepy<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.tweepy.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Tweepy<\/a>&nbsp;is an easy-to-use&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/python-trading-library\/\">Python library<\/a>&nbsp;for accessing the Twitter API, as its &#8211; website claims. It\u2019s not a unique library to connect to the Twitter API, but it is one of the best known and with very active development on<a href=\"https:\/\/github.com\/tweepy\/tweepy\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;GitHub<\/a>.<\/p>\n\n\n\n<p>As can be easily deduced from the previous paragraph, Tweepy allows us to connect to Twitter information to extract historical and real-time data. This means that we have tons of information available for analysis through this library.<\/p>\n\n\n\n<p>The information from social networks, and Twitter in particular, is unstructured data and uses a lot of jargon, slang, emoticons, etc., which makes it especially complicated to analyze.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.nltk.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Natural Language Processing or NLP<\/a>&nbsp;is an area specialized in extracting quantitative and qualitative information from all this unstructured information. When it is used in conjunction with<a href=\"https:\/\/scikit-learn.org\/stable\/tutorial\/text_analytics\/working_with_text_data.html\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;classical statistical tools or machine learning<\/a>, we are able to do sentiment analysis of social networks and unstructured data in general.<\/p>\n\n\n\n<p>In one post there is not enough space to do a complete coverage of sentiment analysis in social networks, so here we are going to focus on the first but not least important step of sentiment analysis which is the extraction, transformation and loading of Twitter information into analysis\u2019 algorithms.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-install-and-set-up-tweepy\">How to install and set up Tweepy?<\/h2>\n\n\n\n<p>Install the Tweepy Python library as usual through the pip installer:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install tweepy\n<\/code><\/pre>\n\n\n\n<p>Or clone the source code from GitHub and install it as a developer in your machine if you plan to modify the code and make your own contribution to the community.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/tweepy\/tweepy.git\ncd tweepy\npython setup.py develop<\/code><\/pre>\n\n\n\n<p>In addition to installing the Tweepy library in Python, it is required to create a&nbsp;<a href=\"https:\/\/developer.twitter.com\/en\/apply-for-access\" target=\"_blank\" rel=\"noreferrer noopener\">developer account on Twitter<\/a>&nbsp;in order to obtain the keys that will allow us to connect with the Twitter servers to extract data.<\/p>\n\n\n\n<p>Once the library is installed and the developer keys are obtained, we are ready to start working with information from Twitter.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-authentication-on-twitter-api\">Authentication on Twitter API<\/h2>\n\n\n\n<p>Start a terminal (Anaconda prompt if you want) and launch an interactive python session with the ipython command, import the tweepy library and assign variables for the keys.<\/p>\n\n\n\n<p>Next we must create an authentication handler object and finally, create a tweepy object with the authentication handler object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"818\" height=\"97\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-1-quantinsti.png\" alt=\"\" class=\"wp-image-149936 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-1-quantinsti.png 818w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-1-quantinsti-700x83.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-1-quantinsti-300x36.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-1-quantinsti-768x91.png 768w\" data-sizes=\"(max-width: 818px) 100vw, 818px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 818px; aspect-ratio: 818\/97;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1100\" height=\"473\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-2-quantinsti-1100x473.png\" alt=\"\" class=\"wp-image-149937 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-2-quantinsti-1100x473.png 1100w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-2-quantinsti-700x301.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-2-quantinsti-300x129.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-2-quantinsti-768x330.png 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/authentication-handler-object-2-quantinsti.png 1274w\" data-sizes=\"(max-width: 1100px) 100vw, 1100px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1100px; aspect-ratio: 1100\/473;\" \/><\/figure>\n\n\n\n<p>Now we have an object called api which is a<a href=\"https:\/\/en.wikipedia.org\/wiki\/Network_socket\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;socket<\/a>&nbsp;connected against Twitter machines and enables us to extract tweets from specific users, extract tweets related to some word or set of words or even manage our own Twitter account.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-use-tweepy-to-get-tweets\">How to use Tweepy to get tweets<\/h2>\n\n\n\n<p>The object api we have created allows us to use 105 RESTful methods from the Twitter API, some of them are only available for the premium API.<\/p>\n\n\n\n<p>We can list all the available methods:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-restful-methods-1-quantinsti.png\" alt=\"\" class=\"wp-image-149938 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-restful-methods-2-quantinsti.png\" alt=\"\" class=\"wp-image-149939 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>The list is not complete, although we have seen that we have 105 methods available. If we take a look, we will see that we can perform more functions than with the App itself and we can automate our own Twitter account and manage our publications or even create a completely autonomous bot to manage an account.<\/p>\n\n\n\n<p>Some of the most used methods to get data are the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>search<\/strong>&nbsp;to search for tweets containing certain words<\/li><li><strong>user_timeline<\/strong>&nbsp;to search for tweets from specific users<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-search\">search<\/h3>\n\n\n\n<p>Let\u2019s get some tweets by looking for a word. We call the search method of the api object with the input parameter q for query.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/input-parameter-q-for-query-1-quantinsti.png\" alt=\"\" class=\"wp-image-149940 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Checking the results, we are getting a model (another object) with the tweets for the requested query, we get 15 tweets looking for the ticker of Johnson &amp; Johnson $JNJ<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-model-search-results-1-quantinsti.png\" alt=\"\" class=\"wp-image-149941 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Although this is the default number, we can increase it to 100 using the count input parameter, the maximum per request for a free Twitter API developer.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-api-count-quantinsti.png\" alt=\"\" class=\"wp-image-149942 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>It is incredible the vast amount of meta-information that comes with a simple tweet of 140 characters, I have only included the first part of the result because to show it completely would require several pages.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"667\" height=\"874\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-fetched-data-quantinsti.png\" alt=\"\" class=\"wp-image-149943 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-fetched-data-quantinsti.png 667w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-fetched-data-quantinsti-300x393.png 300w\" data-sizes=\"(max-width: 667px) 100vw, 667px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 667px; aspect-ratio: 667\/874;\" \/><\/figure>\n\n\n\n<p>So let&#8217;s take a look at more specific information such as the date and time of the tweet, the user and the content posted.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"666\" height=\"47\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-date-and-time-quantinsti.png\" alt=\"\" class=\"wp-image-149944 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-date-and-time-quantinsti.png 666w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-date-and-time-quantinsti-300x21.png 300w\" data-sizes=\"(max-width: 666px) 100vw, 666px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 666px; aspect-ratio: 666\/47;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"675\" height=\"68\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-text-quantinsti.png\" alt=\"\" class=\"wp-image-149945 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-text-quantinsti.png 675w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-text-quantinsti-300x30.png 300w\" data-sizes=\"(max-width: 675px) 100vw, 675px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 675px; aspect-ratio: 675\/68;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"675\" height=\"587\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-user-info-quantinsti.png\" alt=\"\" class=\"wp-image-149946 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-user-info-quantinsti.png 675w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-user-info-quantinsti-300x261.png 300w\" data-sizes=\"(max-width: 675px) 100vw, 675px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 675px; aspect-ratio: 675\/587;\" \/><\/figure>\n\n\n\n<p>Again, for the user it returns a large amount of metadata associated with the user, such as name, alias, number of followers, etc.<\/p>\n\n\n\n<p>To see a little more detail, we need again to use the methods available in the search object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/method-in-search-object-quantinsti.png\" alt=\"\" class=\"wp-image-149947 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Remember that what Twitter returns us is an object model and as such, we have at our disposal countless methods to work with those objects.<\/p>\n\n\n\n<p>Each tweet is an object of the Status class and we can see its methods here.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-model-status-quantinsti.png\" alt=\"\" class=\"wp-image-149948 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>For the User model we have 52 methods available for working with users.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/user-model-52-methods-1-quantinsti.png\" alt=\"\" class=\"wp-image-149949 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Please, check the<a href=\"https:\/\/docs.tweepy.org\/en\/latest\/api.html#search-methods\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;documentation<\/a>&nbsp;to learn about the large number of parameters that can be used in searches.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-user-timeline\">user_timeline<\/h3>\n\n\n\n<p>Another of the most used methods of the Twitter API is the user_timeline that allows us to analyze all the publications of a particular user.<\/p>\n\n\n\n<p>Elon Musk&#8217;s account is hot, he has millions of followers and some of his posts cause seismic movements. Let&#8217;s pull down some of his tweets.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"675\" height=\"48\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/elon-musk-tweets-quantinsti.png\" alt=\"\" class=\"wp-image-149950 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/elon-musk-tweets-quantinsti.png 675w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/elon-musk-tweets-quantinsti-300x21.png 300w\" data-sizes=\"(max-width: 675px) 100vw, 675px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 675px; aspect-ratio: 675\/48;\" \/><\/figure>\n\n\n\n<p>Again we can see that what we get is an object of class ResultSet or properly speaking a model of objects that provide us with a multitude of methods to work with the information.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweepy-models-result-set-quantinsti.png\" alt=\"\" class=\"wp-image-149951 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"674\" height=\"109\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweets-name-text-quantinsti.png\" alt=\"\" class=\"wp-image-149952 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweets-name-text-quantinsti.png 674w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweets-name-text-quantinsti-300x49.png 300w\" data-sizes=\"(max-width: 674px) 100vw, 674px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 674px; aspect-ratio: 674\/109;\" \/><\/figure>\n\n\n\n<p>Note that the maximum number of tweets returned is 20 by default, although we can extend it up to 200 with the count parameter.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/07\/tweet-count-quantinsti.png\" alt=\"\" class=\"wp-image-149953 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>It is not possible here to describe each of the parameters for the user_timeline function so we strongly recommend you to visit the&nbsp;<a href=\"https:\/\/docs.tweepy.org\/en\/latest\/api.html#user-methods\" target=\"_blank\" rel=\"noreferrer noopener\">Tweepy documentation<\/a>.<\/p>\n\n\n\n<p><em>Visit QuantInsti for additional insight on this topic: <a href=\"https:\/\/blog.quantinsti.com\/tweepy\/\">https:\/\/blog.quantinsti.com\/tweepy\/<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.<\/p>\n","protected":false},"author":387,"featured_media":83281,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,349,338,350,341,344],"tags":[8485,806,5479,865,2859,595,1038,12357,12358],"contributors-categories":[13654],"class_list":{"0":"post-149920","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-python-development","10":"category-ibkr-quant-news","11":"category-quant-asia-pacific","12":"category-quant-development","13":"category-quant-regions","14":"tag-data-mining","15":"tag-data-science","16":"tag-data-visualisation","17":"tag-github","18":"tag-natural-language-processing","19":"tag-python","20":"tag-sentiment-analysis","21":"tag-tweepy","22":"tag-twitter-api","23":"contributors-categories-quantinsti"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Tweepy &#8211; Generate Sentiment Trading Indicator using Twitter API in Python<\/title>\n<meta name=\"description\" content=\"In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/149920\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tweepy - Generate Sentiment Trading Indicator using Twitter API in Python | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-17T13:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T14:57:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mario Pisa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mario Pisa\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Mario Pisa\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/f2bfe36ae4f6f088b98f90558d37ed12\"\n\t            },\n\t            \"headline\": \"Tweepy &#8211; Generate Sentiment Trading Indicator using Twitter API in Python\",\n\t            \"datePublished\": \"2022-08-17T13:00:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:57:23+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/\"\n\t            },\n\t            \"wordCount\": 1473,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/python-tile.jpg\",\n\t            \"keywords\": [\n\t                \"Data Mining\",\n\t                \"Data Science\",\n\t                \"Data Visualisation\",\n\t                \"GitHub\",\n\t                \"Natural Language Processing\",\n\t                \"Python\",\n\t                \"Sentiment Analysis\",\n\t                \"Tweepy\",\n\t                \"Twitter API\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Asia Pacific\",\n\t                \"Quant Development\",\n\t                \"Quant Regions\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/\",\n\t            \"name\": \"Tweepy - Generate Sentiment Trading Indicator using Twitter API in Python | IBKR Quant Blog\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/python-tile.jpg\",\n\t            \"datePublished\": \"2022-08-17T13:00:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:57:23+00:00\",\n\t            \"description\": \"In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/python-tile.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/python-tile.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Python\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/f2bfe36ae4f6f088b98f90558d37ed12\",\n\t            \"name\": \"Mario Pisa\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/mariopisa\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Tweepy &#8211; Generate Sentiment Trading Indicator using Twitter API in Python","description":"In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/149920\/","og_locale":"en_US","og_type":"article","og_title":"Tweepy - Generate Sentiment Trading Indicator using Twitter API in Python | IBKR Quant Blog","og_description":"In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/","og_site_name":"IBKR Campus US","article_published_time":"2022-08-17T13:00:00+00:00","article_modified_time":"2022-11-21T14:57:23+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg","type":"image\/jpeg"}],"author":"Mario Pisa","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mario Pisa","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/"},"author":{"name":"Mario Pisa","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/f2bfe36ae4f6f088b98f90558d37ed12"},"headline":"Tweepy &#8211; Generate Sentiment Trading Indicator using Twitter API in Python","datePublished":"2022-08-17T13:00:00+00:00","dateModified":"2022-11-21T14:57:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/"},"wordCount":1473,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg","keywords":["Data Mining","Data Science","Data Visualisation","GitHub","Natural Language Processing","Python","Sentiment Analysis","Tweepy","Twitter API"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Asia Pacific","Quant Development","Quant Regions"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/","name":"Tweepy - Generate Sentiment Trading Indicator using Twitter API in Python | IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg","datePublished":"2022-08-17T13:00:00+00:00","dateModified":"2022-11-21T14:57:23+00:00","description":"In this post we will review the Tweepy library for fetching real-time and historical data from Twitter.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/tweepy-generate-sentiment-trading-indicator-using-twitter-api-in-python\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg","width":1000,"height":563,"caption":"Python"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/f2bfe36ae4f6f088b98f90558d37ed12","name":"Mario Pisa","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/mariopisa\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/python-tile.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/149920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/387"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=149920"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/149920\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/83281"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=149920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=149920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=149920"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=149920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}