Back

RSI - executing via universe (python)

I am complete newbie in Python and I reviewed the documentation, but I was wondering if someone can help me out?  I reviewed some other posts in the forums as well, but I am still stuck.  I'm trying to trigger trading once various RSI levels are reached in the attached python code across a universe of equities, but I don't know how to get the loop to work and/or for the code to store the data so it can trigger the trades based on the RSI for the right equity.  My current code only takes the RSI of AAPL and not the right RSI for the assigned symbol I believe.  Thanks for any help!

Update Backtest








Thank for attaching the algorithm. After looking through the code, I have confirmed the algorithm does not use the right RSI for the assigned symbol:

2018-01-09 00:00:00 85.43980614637137717643498911
2018-01-09 00:00:00 85.43980614637137717643498911
2018-01-09 00:00:00 85.43980614637137717643498911
2018-01-10 00:00:00 86.41249310672776865922991676
2018-01-10 00:00:00 86.41249310672776865922991676
2018-01-10 00:00:00 86.41249310672776865922991676

In order to keep track of the data for each symbol, trying using the SymbolData class like the one used the example here. A potential implementation could be:

class SymbolData:
'''Contains data specific to a symbol required by this model'''
def __init__(self, security):
self.Security = security
self.Symbol = security.Symbol
self.RSI = None

This object can be indexed by its ticker in a dictionary like this: 

self.symbolDataBySymbol = {}

By doing so, you will be able to properly maintain the RSI objects created for each ticker.

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

 
";