Back

Trading a list of Equities

I attempted at trading a list of equities but I was wondering if I am missing some pieces of code or if some things are not working in the code such as:

1. Is my code storing each securities' rolling window individually

2. Is the code buying the individual security when the specific pattern happens

3. Is the code issuing the stop loss and profit taking mechanism individually for each security?

4. What am I missing? What do I need to get rid of?

I know it is a complex code but my main points of emphasis are what I wrote above.

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.


Hey Nicholas,

As discussed over Slack and in case anyone else stumbles upon this thread, here's a few pointers:

  • From what I can see in your latest code, I think the main issue is that your self.Security and self.Window are not arrays, so you end up overwriting them. For example you could do self.Windows = dict() and then writing self.Windows[Symbol] = RollingWindow[TradeBar](5) instead. I don't use python on a regular basis so not sure if syntax is correct, but I suspect something like that should work.
  • Tricky bit is when you want to consolidate to multiple different rolling windows -  I think you could potentially leave your self.Consolidate-line as it is and simply rewrite your TradeBarHandler:
def TradeBarHandler(self, TradeBar):
self.Windows[TradeBar.Symbol].Add(TradeBar)
  • This is assuming your self.Windows is a dict keyed by the symbol as discussed above.
  • Going further down your code, you'd obviously have to rewrite all references to self.Window[x] to self.Windows[Symbol][x]. Implementing those changes would at least get the window consolidation up to speed. Then I don't know if the rest of the code works as intended, but that's based on what rules you want the trading to follow.

1

Thanks Douglas

0

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