Back

Volume Delta

Is there an easy way to sort the universe for a spike in volume day to day and look at that at the morning bell?

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Claryifying a little bit:

Is there a way to filter a universe daily by volume, to then compare that list to the prior days volume in order to find out if its unusual by a certain metric or not?

0

Have you tried keeping using a seperate class to track relevant variables like in this this example?

In the same way the example tracks the 100 EMA and 300 EMA, you might be able to track the EMA or MA (or whatever you want) of the Volume.

For example, you might identify a volume spike if its current daily volume is 5 times greater than the 20 day moving average of the Volume.

0

Thanks for the quick reply!

So, from what I saw in this example, a blank dictionary "averages" is created and is filled with 10 tickers.  It is then re-visited daily.  But won't it only look at those 10 stocks day to day?  We'd want to be looking basically all available in the course univerise and saying "ok, which of these have had a major influx of volume today."  Do you know what I mean?

0

This code isn't looking at only 10 securities, it is selecting the top 10 securities that best match the criteria. They are sorting by the speed at which the moving averages are diverging (self.scale). 10 is an arbitrary limit, you can select as many securites that meet your criteria as you want.

0

Hi Stephen,

As AK M pointed out, we can adjust the EmaCrossUniverseSelectionAlgorithm to filter our universe to the 10 securities that have the largest influx in daily volume. This can be accomplished by changing line 65 from

avg.update(cf.EndTime, cf.AdjustedPrice)

to

avg.update(cf.EndTime, cf.Volume)

It can be seen that the strategy doesn't trade until both of the volume moving average indicators are ready. Normally, we'd recommend our users to warm up their indicators before the start of a backtest begins. However, as our documentation states, "due to technical limitations Universe selection cannot be fast-forwarded. Any universe selection is skipped until realtime is reached."

See the attached backtest which shows a full working example of this.

Best,
Derek

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thank you!!!

Is there anyway to look at this in an overall timeframe? Something like highest volume ever traded for that security or highest price ever achieved?

0

Hey Stephen,

We can create pointers in SymbolData to keep track of the max volume and max price, and then we can update the pointer accordingly as we encounter new data points.

class SymbolData:
def __init__(self, symbol):
....
self.max_volume = 0
self.max_price = 0

def update(self, time, volume, price):
if volume > self.max_volume: self.max_volume = volume
if price > self.max_price > self.max_price = price

This implementation will only track the highest volume and price we've seen during the backtest runtime. If you wish to keep track of the all time highs, we can use a history call to 'warm up' our pointers.

def __init__(self, algorithm, symbol):
....
self.max_volume = 0
self.max_price = 0

# Start of backtesting data
start = datetime(1998, 1, 1)
end = algorithm.Time

history = algorithm.History(symbol, start, end, Resolution.Daily)
for bar in history.itertuples():
volume = bar.volume
high = bar.high
if volume > self.max_volume: self.max_volume = volume
if high > self.max_price: self.max_price = high

 

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed