Danny Groves Profile picture
Nov 12, 2023 15 tweets 5 min read Read on X
The Stockbee Market Monitor by @PradeepBonde is probably one of the best free resources out there.

It's amazing for gauging situational awareness of the market.

Let's take a look from a data-science perspective in predicting trends in SPY 🧵 Image
@PradeepBonde If you're a swing trader, then the Market Monitor is a seriously useful market breadth tool.

I'm using it to understand whether the market is favorable to long-based momentum trades.

Basically, I'm looking to trade long when the chart is highlighted green. Image
@PradeepBonde Of course, labelling areas as green/red is easy in hindsight.

What's harder is knowing that before it happens.

So, what the aim is here is to use the Market Monitor to predict when green/red happens.

We are going to use machine learning for this.
@PradeepBonde Firstly, we need the market monitor data.

Fortunately, this is completely free, just google it (thanks Pradeep!).

Many of the columns are dependent on the # of stocks in the universe.

So first, let's normalise pretty much every column by the # of stocks.
@PradeepBonde Why?

We want the machine learning model to learn general rules.

If we feed in raw figures, it may not understand that the # will change because the universe size changes.

The 5 & 10 day ratio are already normalised, so they are fine too (same for the t2108). Image
@PradeepBonde With all these features & the uptrend/downtrend label (which is binary) we can train a model.

To start with, use a tree-based model like a random forest.

With no effort to optimise the training/feature engineer - we get a remarkable 67% accuracy in trend prediction. Image
@PradeepBonde The best thing about tree based models is that you can extract feature importance.

In other words, per column in Pradeep's data, what are the most/least important.

Interestingly, the # of stocks up 13% plus in 34 days is most important. Closely followed by the 10 day ratio. Image
@PradeepBonde Since a random forest is a non-linear model, it's likely all columns have interaction with each other.

Since there are no features where there a value close to 0 on the scale, all look pretty useful.

This is no surprise given Pradeep's expertise, he knows what works!
@PradeepBonde But what does this mean for our chart?

Actually... it's pretty messy. But it indeed captures the good/bad pretty well!

Remember, this is a quick/dirty train of a model, there is plenty to be done in terms of optimisation. Image
@PradeepBonde Another good thing about ML models is they can produce "probabilities"

I.e., the last image shows anything above 50% probability.

Higher probability = greater model "surety" that it's in an uptrend.

Upping it to 70% shows a cleaner view, for sure! Image
@PradeepBonde Let's look to improve slightly.

I'm adding in a few technicals from the SPY itself, including:
• Price distance from the moving averages
• Average range over n days
• Price distance from an n day max/min

There's no need to overthink this too much.

ML is all iteration!
@PradeepBonde We now get an improved accuracy to 73%.

This shows the power of feature engineering.

There is undoubtedly more tinkering to be done - but outside the scope of a simple thread. Image
@PradeepBonde With the new features & model, we end up with a cleaner chart again.

What I find quite interesting is seeing how the model is quite unsure in 2023.

Lots of chop for sure - I'm sure many traders can vouch for that personally! Image
@PradeepBonde TL;DR

The Market Monitor is an exceptional tool for understanding trading environments.

Machine learning can be leveraged with this data to provide an indicator of when to swing trade long.

And be sure to thank Pradeep for the data/free content!
@PradeepBonde Anyway, that's all for this one!

If you are interested in applying Python/Data-Science to finance then:

1. Follow me @DrDanobi for more of these
2. Check out some other of my threads.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Danny Groves

Danny Groves Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @DrDanobi

Jan 9, 2024
Finding optimal trading parameters is great - but they may not respond or adapt to market changes

This is where ML may be able to help us!

So let's take a step-by-step case study in this 🧵and use ML to try and predict the best trading parameters each day

Enjoy! Image
I can't take credit for the idea - that goes to @chanep and his team at @PredictNowAI

They call it "Conditional Parameter Optmisation" (CPO) - the key idea is to use ML to find the optimal parameters based on the current market conditions, i.e. it's adaptive.
@chanep @PredictNowAI So what are we going to consider in this 🧵?

• SPY only
• An intraday RSI strategy with 3 parameters (two thresholds and a lookback period)
• ML features from daily data
• Outcome = predicted best 3 parameters for tomorrow

Let's dig in!
Read 31 tweets
Dec 31, 2023
Good visualisations are key to quickly assessing strategy performance

So here's a 🧵to discuss two I use frequently:

1. Monte Carlo Plots
2. Win Rate Heatmap

And yes, all Python code is included, enjoy! Image
First of all, let me say that my personal ethos with visualisations is to be as minimalist as possible.

I have sat through one too many presentations with complex charts - sure they're packed with info, but not easy to immediately digest.
So how do I create minimalist charts?

Easy! I start by creating complex ones - then iteratively simplify and/or take things away until it's as clean as it can be.

This is also the approach I take to programming.

Anyway, let's dig in with an example!
Read 17 tweets
Dec 21, 2023
Machine learning for finance can be tricky

So let's break it down in a step-by-step case study 🧵

This time - let's create a model, and use explainable ML techniques to understand how it's making decisions.

And hopefully we'll gain some trading insights along the way!

Enjoy! Image
First of all - this 🧵will use the same application as in the quoted one.

However, this time we will:
• Use a different classifier
• Drop correlated features
• Explain the model outputd

And I'll even throw the details of the attached 🧵 here too.
The basic motivation is to try and understand what decisions the ML model is making at specific points (e.g. at the COVID crash)

Perhaps this understanding can be used to gain more trading intuition - or at the very least to make better models with

Let's dig in! Image
Read 37 tweets
Dec 16, 2023
I spent 100's of hours making a ML breakout scanner.

The outcome - scanning the entire market ≤ 2 mins per day.

The thing is, I hardly use it now... but it taught me a lot.

Here's 10 things I learned from this experience 🧵

(My favourite is Tip 7!) Image
Firstly, what was my rationale for this idea?

Pro traders recommend checking out 1000's of examples to learn setups.

I was like "Hey, whilst I'm doing that, I will save the examples and let ML find them again for me, saving me loads of time!"

Seemed like a win-win!
Why don't I use it?

My trading/ML has evolved - the outcome meant I discretionarily picked tickers the scanner spat out.

It doesn't suit my personality to be discretionary at all - so now I consider other ideas.

Anyway, intro over, here are the 10 things!
Read 17 tweets
Dec 12, 2023
Machine learning for finance is not all about prediction.

So let's take a step-by-step case study in this 🧵

This time - let's cluster trades to try and find similar ones in the future

Enjoy! Image
First of all let me say that I love prediction problems, it's fun stuff.

However, prediction can be tricky - you have to be careful with what you ask the model or it may just not find anything at all.

Unsupervised is different, you let it find the patterns for you!
What's the idea here? We will:

1. Take a simple trading strategy
2. Find examples over a small basket of stocks
3. Ask ML to group these past trades

Why?

I'd like to see if it can find similar looking trades in the future, so we get an expectancy on how they should behave.
Read 29 tweets
Dec 10, 2023
Machine learning for finance can be tricky!

So let's explore with another step-by-step case study 🧵

This time, let's use ML to find time series patterns across multiple instruments.

The aim - to find like patterns in the market and build a scanner.

Enjoy! Image
OK, what ML tools are we using here?

This will be a clustering approach = unsupervised.

Unsupervised means we give the algorithm no guidance on what to look for.

I'm interested to see what patterns IT can find for me.

Yes, I'm lazy.
Algos like K means clustering don't really have a concept of a time-series

They're great at other things, of course, but I want to find time series patterns.

So let's consider a special kind of clustering.

Time-series clustering, using tslearn.
Read 29 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(