• Free Book
  • Store
    • Books
    • Free First Chapters
    • Free Newsletters
  • Recent Articles

TradingMarkets.com

Quantified Stock Market Trading Strategies & Systems

  • Home
  • New Trading Research
  • Education
    • Articles
      • Connors Research
      • ETFs
      • Options
      • Stocks
      • Volatility
    • Trading Lessons
    • Connors Research
    • Glossary
    • Interview Archive
    • Videos
  • Python
  • Quantamentals
    • Quantamentals: The Next Great Forefront of Trading and Investing
    • Quantamentals Resources
  • Courses
  • Store
    • New Book! The Alpha Formula
    • “Buy The Fear, Sell The Greed” – Best Seller!
    • Swing Trading College 2019
    • Trading Books and Guidebooks
    • Street Smarts
    • Online Trading Courses
    • Private Mentoring with Larry Connors
    • Customized Trading Research
    • Amibroker Strategy Add On Modules
You are here: Home / Connors Research Traders Journal / Fact-Checking CNBC with Python

Fact-Checking CNBC with Python

December 17, 2019 by Larry Connors and Chris Cain, CMT

The ability to code is like having a trading superpower. 

For instance, when something that seems “rare” happens in the marketplace, you can quickly and easily write some code to see how rare that event actually is. 

Instead of relying on the financial media, you can do your own analysis. More importantly, you can see what happened after such an event occurred and whether that constitutes a tradable opportunity or not.

In this Connors Research Traders Journal, we will show you how easy it is to check the frequency of a market event.  We will also show you how straightforward it is to observe typical market behavior after such an event occurred.

Rely On Facts! Not Talking Heads on CNBC Who Say “I Think…”

Imagine that the US stock market has been on a run of strong recent performance, rising 10% in the last 6 months. 

You are wondering if it is the right time to put some of your cash to work in the market given the strong performance.

You don’t want to be a sucker, however. The market has increased by 10% in just 6-months, isn’t it too late to buy now?

You turn on CNBC and a pundit basically says what you are thinking.

“The market has had a very strong run here and I think it looks expensive and overbought” (of course citing no data whatsoever).  “I wouldn’t buy at these elevated prices after this run-up.”

If you have basic coding skills, you can easily check to see if this recent run of performance is, in fact, as overbought and as rare as the pundit is implying.

Data vs. Opinion. The Beauty of Python Code

The first step is to grab the data. If you don’t know how to do this, attend our free webinar on how to code in Python on Monday, December 23 at 1 pm. Click here to register.

Here we grab daily historical open, high, low, close, and volume data for SPY beginning on January 1, 2003 through December 15, 2019.

We save our data as the variable “df”.  We then observe the last 5 rows of our data using .tail().

Let’s make a quick graph of the historical price of SPY. This is done via only two lines of Python code as shown below.

Let’s now make a quick plot of rolling 6-month, or 126 business days, total returns. 

Shocking! It certainly doesn’t look like a 10% trailing 6-month total return is anything out of the ordinary. In fact, we can see that the market has had much stronger 6-month performances in the past, hitting +20% or higher multiple times.

Next, let’s check out how many total days are in our sample size and how many of those days had a trailing 6-month return greater than 10%.

Here we have 4,142 total days in our sample. 

Of those 4,142 today days, 1,148 of them had trailing 6-month returns greater than 10%.  That is 27.7% of the time, not exactly a rare event!

Finally, let’s see what the future 3-month returns are for SPY after a 10% 6-month advance occurred. This can be accomplished in a few lines of Python code.

As you can see, the median 3-month future return after a 10% 6-month increase is a positive 3.36%. Annualized it’s over 13% a year!

We can certainly agree that just because the market increased 10% in a 6-month period, that is NOT a reason to sell as the TV pundit implied. 

Learn How To Do This For Yourself

With basic Python coding skills, you’re empowered to decide for yourself with facts and data instead of the opinion of a TV pundit. This is the power of coding in Python. You can quickly, and professionally fact check analysts who rely on their opinion. 

Don’t worry if this code is confusing to you, especially if you have limited experience with a coding language. All this is learnable in under 10 hours.

In fact, we guarantee you’ll learn how to code strategies in Python in under 6 hours. We back this with a 100% money-back guarantee. That’s how sure we are you’ll have the knowledge to run a test like this.

We will teach you how to do all of this and more in our upcoming course – Python Programming for Traders.

Attend the free webinar on Monday (or sign up to receive the recording). You’ll be on the path to joining the tens of thousands of professional traders around the world who work for major hedge funds and bank trading desks who do their systems testing and programming in Python.

Click here to register for the webinar now.

Chris Cain, CMT

PS – If you’re already programming in Python, feel free to type my code onto Quantopian to go even further with this.

Filed Under: Connors Research Traders Journal, Recent Tagged With: python

Buy The Fear, Sell The Greed

Buy The Fear, Sell The Greed

Swing Trading College

New Book From Larry Connors and Chris Cain, CMT – "The Alpha Formula; High Powered Strategies to Beat The Market With Less Risk"

We’re excited to announce the release of a new investment book written by Larry Connors and Chris Cain, CMT. The book, “The Alpha Formula; High Powered Strategies to Beat The Market With Less Risk “ combines… Hedge fund legend Ray Dalio’s brilliant insight into combining uncorrelated strategies… With new, minimally correlated, quantified, systematic strategies to trade… [Read More]

Buy The Alpha Formula Now

Connors Research Traders Journal (Volume 57): 7 Real-World Reasons Why Short Strategies Should Be Included In Your Portfolio

In our new book, The Alpha Formula – High Powered Strategies to Beat the Market with Less Risk, we show the benefits of including short-strategies in your portfolio. As a reminder, building portfolios should be based on First Principles – otherwise known as truths. These truths are: Markets Go Up Market Go Down Markets Go… [Read More]

Company Info

The Connors Group, Inc.
185 Hudson St., Suite 2500
Jersey City, NJ 07311
www.cg3.com

About Us

About
Careers
Contact Us
Link To Us

Company Resources

Help
Privacy Policy
Return Policy
Terms & Conditions

Properties

TradingMarkets
Connors Research

Connect with TradingMarkets

Contact

info@cg3.com
973-494-7311 ext. 628

Free Book

Short Term Trading Strategies That Work

© Copyright 2020 The Connors Group, Inc.

Copyright © 2023 · News Pro Theme on Genesis Framework · WordPress · Log in