Back

Coarse Universe Selection and Candlestick Patterns

Hello QC Community!

I have been struggling with getting the core framework for a long/short portfolio established.  My objective is to hold long a balanced portfolio that will shift up and down risk based on broad market technical data.  The short portfolio is something new to me and I am just beginning to explore these strategies.

In the attached strategy I was hoping to accomplish the following:

1)      Simple Risk/De-risk on the Long portfolio

2)      Short positions where RSI > 80 and the EveningDojiStar pattern exists

I am running into the following issues.

-          Warmup function for RSI in Coarse filter not working

-          SPY and TLT are being included in the short portion of the portfolio and are liquidated in the OnData function

-          How do I filter out all of the leveraged VIX products that are shorted?

-          I don’t even know where to begin to get the Evening Doji Star calculated or what it’s output is.  Didn’t see much in the documentation about using the Candlesticks Patterns.

 

Any thoughts would be greatly appreciated!

 

-Brian

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.


Hi Brian,

I've attached a backtest that includes some changes that will help you modify your algorithm. To answer your questions briefly, the WarmUp function wasn't affecting the RSI Indicators because they weren't being created in the Initialize() method. I've modified the code so that each RSI indicator being created uses a historical data warm-up and is primed for the next statement to evaluate in the LINQ. Additionally, the Symbol comparisons weren't functioning as intended because cf.Symbol returns a QC Symbol object. Instead, the comparison should be made to cf.Symbol.Value, which returns the string of the QC Symbol (i.e., the ticker) -- this is the same issue as the one you're encountering with symbol comparison in the OnData() method. You can filter out VIX products in the Universe selection the same way you have filtered for TLT and SPY, or this could be done in the OnData() method by skipping the for-loop if the security in changes.AddedSecurities is a VIX security. I've addressed the EveningDojiStar issue you encountered and it requires similar construction as the RSI indicator. You can find more information about candlestick patterns in this forum discussion and see the source code for the Evening Doji Star here.

One other thing I noted is that the trading logic in the OnData() method doesn't rely on any TradeBars being passed through, and so I moved it to OnSecuritiesChanged in the backtest just to clean things up a bit.

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