Hi All-
I've tried logging DollarVolume and MarketCap for my coarse universe but have had no luck. Anyone know how to do this? I looked into the documentation and forum but found no solution.
Justin
Hi All-
I've tried logging DollarVolume and MarketCap for my coarse universe but have had no luck. Anyone know how to do this? I looked into the documentation and forum but found no solution.
Justin
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.
Hey Justin E,
Are you trying to Log them for each of the symbols or the mean?
#Coarse universe
def SelectCoarse(self, coarse: List[CoarseFundamental]) -> List[Symbol]:
selected = [c for c in coarse if c.HasFundamentalData]
sorted_by_dollar_volume = sorted(selected, key=lambda c: c.DollarVolume, reverse=True)
return [c.Symbol for c in sorted_by_dollar_volume[:10]]
How to:
def SelectCoarse(self, coarse: List[CoarseFundamental]) -> List[Symbol]:
selected = [c for c in coarse if c.HasFundamentalData]
sorted_by_dollar_volume = sorted(selected, key=lambda c: c.DollarVolume, reverse=True)
#Add this line(will print value for each symbol)
self.Debug([c.DollarVolume for c in sorted_by_dollar_volume[:10]])
#Add this line(will print mean of all symbols)
self.Debug("MEAN: " + str(mean([c.DollarVolume for c in sorted_by_dollar_volume[:10]])))
return [c.Symbol for c in sorted_by_dollar_volume[:10]]
If you want to print the mean you will have to import this:
from statistics import mean
Or you could do it like this:
self.Debug(sum([c.DollarVolume for c in sorted_by_dollar_volume[:10]]) / len([c.DollarVolume for c in sorted_by_dollar_volume[:10]]))
You could, I dont encourage that, also print the values into a chart…
for c in sorted_by_dollar_volume[:10]:
self.Plot("DollarVolume", c.Symbol.Value, c.DollarVolume)
The same would work with market cap. The only difference would be that you would have to do that in the fine universe.
Hope it helps ;)
It does, I was looking for the log of each individual symbol and it does that now :)
How can I also pair it with the symbol itself and maybe the date (self.Time) as well to get them in a list format?
Right now it prints as: [27903659586.0, 27315343780.0, 18485063288.0, 16769323627.0, 15264435429.0, 8415523160.0, 7665633485.0, 7009039445.0, 6442835322.0, 5027921002.0]
Goal format is:
2022-9-18 9::30:30, AAPL, 1,000,000
…
Thanks,
Justin
Nevermind, I answered my own question:
for c in sortedByDollarVolume[:10]:
self.Log(str(c.Symbol.Value) + " " + str(c.DollarVolume))
Thanks again Nico Xenox!!
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!