#region imports
from AlgorithmImports import *
#endregion
class CreativeFluorescentYellowCaterpillar(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2011, 7, 6)  # Set Start Date
        self.SetEndDate(2013, 2, 1) #Set End Date
        self.SetCash(100000)  # Set Strategy Cash
   
        self.stocks = ["AAPL","TSLA"]
        self.Assets = {}
        for stock in self.stocks:
            ticker = self.AddEquity(stock, Resolution.Daily)
        #symbol = self.AddEquity("TSLA", Resolution.Daily)
        #symbol = self.AddCfd("WTICOUSD", Resolution.Daily, Market.Oanda)
        #symbol = self.AddCrypto("BTCUSD", Resolution.Daily, Market.Bitfinex)
        #symbol = self.AddCrypto("ETHUSD", Resolution.Daily, Market.Bitfinex)
            self.Assets[symbol] = ticker.Symbol
            self.Assets[rsi] = self.RSI(ticker.Symbol, 14, MovingAverageType.Simple, Resolution.Daily)
            self.Assets[current] = None
            self.Assets[entry_price] = None
            self.Assets[highestPrice] = 0

        
    def OnData(self, data):
        for asset in self.Assets:
            self.asset[current] = self.Securities[self.asset[symbol]].Close
            
            if self.asset[current] == None: continue
            
            # trading conditions, only when we are not invested
            if self.asset[rsi].Current.Value > 60:
                self.Debug("RSI is more than 60")
                if not self.Securities[self.asset[symbol]].Invested:
                    self.SetHoldings(self.asset[symbol], 0.1) #invested 10% of our capital
                    self.asset[entry_price] = self.asset[current]
                    self.Debug("Entry at " + str(self.asset[entry_price]))
                    
            #exit conditions, only if we are invest
            if self.Securities[self.asset[symbol]].Invested:
                if self.asset[current] <= self.asset[entry_price] - (self.asset[entry_price]*0.05): #cut loss at 5%
                    self.Liquidate(self.asset[symbol], "stop-loss")
                    self.Debug("stopped out at " + str(self.asset[current]))
                elif self.asset[current] >= self.asset[entry_price] + (self.asset[entry_price]*0.1): #tp > 10%
                    self.Liquidate(self.asset[symbol], "take-profit")
                    self.Debug("TP at " + str(self.asset[current]))
            

 

Hi all, 

I am rather new to python and Quantconnect. I wanted to construct a portfolio with a mixture of equities, CFDs and cryptos. I do not wish to write multiple times AddEquities, AddCfd and AddCrypto. Any code examples i can refer to?

 

Any help would be greatly appreciated. Thanks in advance!