Hi!
I have been working on a strategy, which involves sorting stocks by their Market Cap. Unfortunately I am facing 2 problems which I can't solve. Firstly, when I try to test the strategy from 2017 and invest in smallest 10% stocks, the algo goes Long only 32 companies. If i change startDate from 2018, the list of companies expands to 295. Is it possible that prior to 2018 the list of stocks with MarketCap is incomplete?It would be very strange as in the “Book-to-market Value Anomaly” tutorial, which has a very similar approach, the data used in the test begins in 2004.
Secondly, In my example, when I try to test my strategy prior to 2017, I receive this notification:
Runtime Error: It is not possible to cast a non-finite floating-point value (NaN) as decimal. Please review math operations and verify the result is valid. (Parameter 'input') in Trading.cs:line 1075
Here is the code which I use:
+ Expand
#region imports
from AlgorithmImports import *
#endregion
# https://quantpedia.com/Screener/Details/26
from QuantConnect.Data.UniverseSelection import *
import math
import numpy as np
class BooktoMarketAnomaly(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017, 1, 1)
self.SetEndDate(2018, 1, 10)
self.SetCash(1000000)
self.UniverseSettings.Resolution = Resolution.Daily
self.AddEquity("SPY", Resolution.Daily)
self.AddUniverse(self.CoarseSelectionFunctionBottom, self.FineSelectionFunctionBottom)
def CoarseSelectionFunctionBottom(self, coarse):
return [x.Symbol for x in coarse if x.HasFundamentalData and x.Price > 5]
def FineSelectionFunctionBottom(self, fine):
bottom_market_cap = sorted(fine, key = lambda x:x.MarketCap, reverse=False)[:int(len([j for j in fine])*0.1)]
self.sorted_by_mc_bottom = [j.Symbol for j in bottom_market_cap]
total_market_cap_bottom = np.sum([j.MarketCap for j in bottom_market_cap])
self.weights_bottom = {}
for j in bottom_market_cap:
self.weights_bottom[str(j.Symbol)] = j.MarketCap/total_market_cap_bottom
return self.sorted_by_mc_bottom
def OnData(self, data):
if not self.Portfolio.Invested:
for j in self.sorted_by_mc_bottom:
self.SetHoldings(j, self.weights_bottom[str(j)])
self.Log("Otwarcie Small Cap")
Louis Szeto
Hi Sebastian
There may not be a market cap for some exotic securities. Always check if the security has one:
Best
Louis
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.
Pangyuteng
Just signed into Alpaca's slack, looks like there is no upddate yet. I had to liquidate my positions manually, and switch to QC's paper trading to continue forward testing!
fyi. below is the response from one of Alpaca's staff a month ago:
"Alpaca is still in the process of working with QuantConnect to resolve these issues. No ETA on a final fix. A positive step is that there is a solid technical solution, however the implementation needs to be worked out which involves some changes on the QuantConnect side. We'll keep everyone posted."
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.
Jared Broad
pangyuteng Sorry you were impacted.
FYI it has nothing to do with technical changes. We have finished Tradier implementation which is also a $0 fee brokerage; and will install it into the website after that Alpha Market bug fixes have settled down =).
Onwards and upwards!
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.
OkiTrader
Update- Alpaca has crossed the last line. The polygon.io support is no longer supported. Now you will have to pay $199 for market data. Surprised how things went quickly downhill.
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.
Jared Broad
Ouch =(
Connor -- It's done in LEAN now we are working hard fighting a few fires in live trading then will be in a more stable place to deploy Tradier to the website. Hopefully next week.
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.
Robert Koch
The loss of polygon is particulalry bad, and means I'll be moving away from Alpaca. I've found that their in house historical data is quite bad, and it also is missing a lot of volume. Too bad.
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.
OkiTrader
I agree polygon.io was a key feature. I was using it to practice building my own SQL database, CRUD operations. Using this database I would run my paper trading algos. It's the hard way, but learned a lot while doing it. Their in-house historical data is terrible, especially for minute data. Additionally, when I tried intraday queries it would sometimes break. Even the documentation provided by support would sometimes fix the bugs. Definitely think you would lose money if you tried to trade live with them.
Gained an appreciation of QuantConnect and where it is going.
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.
Shile Wen
Hi Conner,
The Tradier support has been merged, and we will make it available to QC Cloud as soon as possible. A great way to get the current statuses of features is through the Issues or PRs pages on Github, and subscribe to the threads to get notifications.
Once it is available, to use the brokerage, use the following line of code in Initialize: self.SetBrokerageModel(BrokerageName.TradierBrokerage)
Best,
Shile Wen
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.
Jared Broad
Shipped this afternoon, let me know if there are any issues. Officially still in "beta" mode.
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.
Superfatkorean
Hey guys Ive notcied tradier isnt insured. Should I be worried about this ?
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.
Derek Melchin
Hi Superfatkorean,
Please open a dedicated thread for this question, since it's outside of the scope of this thread and other members may want to comment.
If you'd feel safer with some protection, consider using Interactive Brokers. They offer some Account Protection.
Best,
Derek Melchin
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!