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.
// in algorithm
MarketOnOpenOrder("SPY", 10);
MarketOnCloseOrder("SPY", -10);
//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public void OnData(TradeBars data)
{
var _momSPY = GEMSymbolData["SPY"].MomScore;
var _momTbill = GEMSymbolData["BIL"].MomScore;
var Bonds = GEMSymbolData["AGG"].Symbol;
decimal holdingPercent = 1m;
var orderedMomScores = SectorSymbolData.OrderByDescending(x => x.MomScore.Current.Value).ToList();
int numberOfSectors = 4;
foreach (var x in orderedMomScores)
{
Log(">>SCORE>>" + x.Symbol + ">>" + x.MomScore);
}
}
if (lastSampleTime.Date == Time.Date) return;
Hi Reuben, I am new here but have brief comment. I think you just need to add the "dual" aspect. Invest in all sectors that are positive for 1-year & have 1-year return greater than SPY & have a 1-yea return greater than Bond fund.
To avoid putting too much $ into one sector (like at time of market turmiol or turnign points), only invest 1/3 in each of the top three sectors. If there are only two, 1/3 is in cash. Only one, 2/3 in cash, etc.
Reuben & Tripp, I have modified the original code and tried to add in the "dual" aspect. The code now goes through each of the selected "strong sectors", and applies the "downside protection" method (
) by checking against "TMOM" and "MA" rules. TMOM refers to time-series momentum, whether the asset's momentum is greater than that of the T-Bill. MA refers to moving average, whether the asset is above a certain moving average. If both conditions are met, 25% of the allocation goes to that sector. If only one of the conditions are met, 12.5% of the allocation goes to that sector and 12.5% of the allocation goes to bonds. If both conditions are not met, 25% that originally goes to the sector would be allocated to bonds.
I am trying to implement a custom momentum indicator, to exclude the most recent month from the calculation. Any suggestions as to how this should be done? I have implemented a "MMomentumPercent" class in the code, but can't seem to get it to work.
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!