Overall Statistics
Total Orders
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Sortino Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.336
Tracking Error
0.168
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
# region imports
from AlgorithmImports import *
# endregion

class MyAlgorithmInstance(QCAlgorithm):

    def Initialize(self):
        self.SetCash(100000)
        self.SetStartDate(1998,1,1)
        self.SetEndDate(2014,6,1)
        
        Cape.Algorithm = self
        self.AddData(Cape, "CAPE")

    def OnData(self, data):
        self.Plot("CAPE", "Value", data["CAPE"].Value)

class Cape(PythonData):  
    def GetSource(self, config, date, isLiveMode): 
        Cape.Algorithm.Debug("Test Static")
        return SubscriptionDataSource("https://www.dropbox.com/s/ggt6blmib54q36e/CAPE.csv?dl=1", SubscriptionTransportMedium.RemoteFile)
    
    def Reader(self, config, line, date, isLiveMode):
        if not (line.strip() and line[0].isdigit()): return None 
        index = Cape()
        index.Symbol = config.Symbol 
        Cape.Algorithm.Debug("Test Static 2")
        try: 
            data = line.split(',') 
            index.Time = datetime.strptime(data[0], "%Y-%m")
            index["Cape"] = float(data[10]) 
            index.Value = float(data[10])
        except ValueError: 
                return None 
        return index