from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Python import PythonQuandl
class CalibratedMultidimensionalCompensator(QCAlgorithm):
Time_stop = datetime.min
def Initialize(self):
self.SetStartDate(2015, 1, 1)
self.SetEndDate(2020,3,10)# Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.Ticker = ["AAPL","FB","MSFT","LMT","GS","MS","BAC","TSLA","GM","NVDA","AMD","AMZN","XOM","HAL","EA","SNE","SPY","JPM","SWKS","UBS","CS","GOOG","BLK","BX"]
self.SMAS = {}
self.RSIA = {}
self.SMAL = {}
self.SMAST = {}
for ticker in self.Ticker:
symbol = self.AddEquity(ticker,Resolution.Daily).Symbol
self.RSIA[symbol] = self.RSI(ticker,14)
self.SMAS[symbol] = self.SMA(ticker,20)
self.SMAL[symbol] = self.SMA(ticker,200)
self.SMAST[symbol] = self.SMA(ticker,10)
self.SetExecution(ImmediateExecutionModel())
self.SetWarmUp(200)
self.maximumDrawdownPercent = -0.10
self.initialised = False
self.portfolioHigh = 0
self.AddEquity('TLT',Resolution.Daily)
self.TBills = "USTREASURY/YIELD"
self.AddData(QuandlFuture, self.TBills, Resolution.Daily)
# self.AddEquity("SPY", Resolution.Minute)
def OnData(self, data):
dt = data["USTREASURY/YIELD"]
self.one_year = dt.GetProperty("1 YR")
self.Debug(self.one_year)
class QuandlFuture(PythonQuandl):
def __init__(self):
self.ValueColumnName = "3 MO"