Back

Dollar Volume Universe Selection Issue?

I used this code to log the top 3 dollar volume, the output was : 

['AOL', 'INTC', 'YHOO']

However, according to the research environment, there is no output for AOL.

class CoarseFundamentalTopAlgorithm(QCAlgorithm):

def Initialize(self):

self.SetStartDate(1999,1,11)
self.SetEndDate(1999,1,12)
self.SetCash(10000)

self.UniverseSettings.Resolution = Resolution.Daily

self.AddUniverse(self.Universe.DollarVolume.Top(3))

self.__numberOfSymbols = 3

def OnData(self, data):

x = []
for key in data.Keys:
x.append(str(key.Value))
x.sort()

self.Log(x)

 

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.


I should have used this code instead

from QuantConnect.Data.UniverseSelection import *

class BasicTemplateAlgorithm(QCAlgorithm):

def Initialize(self):
self.num_coarse = 3
self.SetCash(100000)
self.SetStartDate(1999,1,4)
self.SetEndDate(1999,1,5)

self.UniverseSettings.Resolution = Resolution.Daily

self.AddUniverse(self.CoarseSelectionFunction)

def CoarseSelectionFunction(self, coarse):

selected = [x for x in coarse if (x.HasFundamentalData)]

sortedByDollarVolume = sorted(selected, key=lambda x: x.DollarVolume, reverse=True)
top = sortedByDollarVolume[:self.num_coarse]

self.tickers = []
for ticker in top:
self.tickers.append(ticker.Symbol)
return self.tickers


def OnData(self, data):
for i in self.tickers:
self.SetHoldings(i, 0.9/self.num_coarse)

all_symbols = [ x.Value for x in self.Portfolio.Keys ]
all_symbols.sort()
self.Log(all_symbols)

 

0

Hi Kevin,

The ticker `AOL` returned by your strategy represents company AOL Time Warner Inc. (NYSE: AOL). However, there was a ticker symbol change to `TWX` for this company in 2003. The strategy needs to use the new ticker `TWX` to fetch historical `AOL` data before the symbol change event in 2003. Please see my attached research notebook. For more information, please refer to the SymbolChangedEvent documentation section.

Also, if you're interested, please check out this old news about the change of Time Warner's name and ticker symbol in 2003.

I hope this helps!

Xin 

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