Ugh. I feel like I'm still not getting a core concept here. Although, I feel like I've made it a bit further, I still feel like I'm completely screwing up how this is supposed to work.
Attached is my project as-is. Essentially, I'm trying a Trading-the-Odds VRP strategy, where the general gist of is the following:
When EMA5(vix - (astd)) > 1, you go long XIV. Else, you long VXX. Pretty simple.
In the equation above, "vix" is the 30 day constant maturity price of Vix, which is achieved with the quandl code I have installed in the algo. The variable "astd" is the annualized standard deviation of SPY of the past two days, which is calculated as
standard deviation((LN(todaysclose/yesterdaysclose), LN(yesterdaysclose/twodaysagoclose)) * 100 * sqrt(252))
I've broken it down to the following:
1.) Custom indicator to calculate the two day standard deviation of the messy equation above. It uses a custom consolidator.
2.) Standard SMA(1 day) indicator of the VIX contract price from quandl to indicate today's closing price of VIX 30 day contract
3.) Custom indicator to calculate the five day exponential moving average of the difference of SMA(1) and the astd.
So, all told, this project uses:
1.) A custom quandl data source with custom column name
2.) Two custom indicators (I'm not even sure if I'm using that correctly)
3.) Two different data types: standard SPY and QuandlVixContract (of base type Quandl)
I think I've just about incorporated every complicated aspect of the LEAN engine I possibly can! Maybe I bit off more than I could chew?
That said, if I get this running, I'd be happy to explain it and share it with the community. The problem I'm encountering is that my UpdateEMADiff(data) method is putting up an error that says it is expecting a data type "QuandlVixContract" but is instead receiving "Quandl". Not sure what that means.
On top of that, I don't really know how to access the data from Quandl and use it properly. I've put comments in the UpdateEMADiff(data) method for what I know I WANT to do, but don't know how to do it.
Any help is appreciated, and free points for those who do. Thanks everyone.