Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Volume Spread Analysis Implementation

For those of you who aren't familiar with the Volume Spread Analysis (VSA) concept, it's a form of analysis that blends price action and volume, in order to study the supply and demand. It was originally created by Tom Williams, after applying Richard Wyckoff's methods. It's not dependent on any type of instrument or time period, but since its goal is to follow the smart money, it should be applied to securities that are widely traded by big money and retail.

Here is a link to an article that introduces the concept and has two signals demonstrated: the no demand bar and the no selling pressure bar. They are two of the most important signal triggers, but, the analysis mustn't be done on a per bar basis - that would be only a small part of the analysis.

Even though it's not quant trading, per se, I have had success with it in manual trading.
I have started implementing it on Quantopian the past few days, however, since it's new language and platform for me, I am pretty sure there are issues in my code and further optimization. I am basing the beginning of my code on a VPA C# code that I found online, but I'm doing so, so I can have some sort of guide and to correlate the results. Nevertheless, I want to make a number of changes to it, and in the end it should be vastly different.

One of the problems of the code, for instance, is the lack of take profit / stop loss (even though my final intention is to avoid those and act on market behavior, I wanted to implement it to get to know the language better and to have a starting point). I've tried to code and use the ATR as SL and TP, but it's not working properly.

The other issue with the current algorithm is the data access. If you go through the code, you'll probably rapidly find out that it's not the best way and lacks versatility?

Also, meanwhile, I'm using the linear regression slope of 3 different periods to find the trend.

If anyone is also interested in this concept and would like to try to implement to Quantopian, please, feel free to improve and discuss it.

6 responses

just from glancing at the code: you don't have to retrieve the data again and again. This:

    long_term_history = history(bar_count=40, frequency='1d', field='price')  
    medium_term_history = history(bar_count=15, frequency='1d', field='price')  
    short_term_history = history(bar_count=5, frequency='1d', field='price')  

could be

    long_term_history = history(bar_count=40, frequency='1d', field='price')  
    medium_term_history = long_term_history.tail(15)  
    short_term_history = medium_term_history.tail(5)

or

    long_term_history = history(bar_count=40, frequency='1d', field='price')  
    medium_term_history = long_term_history[-1:-15]  
    short_term_history = medium_term_history[-1:-5]  

and others can make it prob even more elegant and faster

I'll implement that. Thank you for the suggestion.
Initially I had set some variables that were used more frequently, such as previous bar data. But, I like that that approach more.

The number of trades is a little too low to assess the efficacy of the system.

The system is not yet implemented. I created the thread prematurely to gauge the interest in the theme.
It has some basic concepts coded, but the signals aren't yet properly designed. It will lose money as is.

Im very interested in implementing something similar as ive also had sucess with this on a discretionary basis.
Have you had any progress?

I think it has potential. If we made it work in pipeline on a universe of stocks it could look across and buy sell more than just AAPL. It could pick the top 10 based on signal strength for diversification