Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe 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
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
import numpy as np
import pandas as pd

class HistoryAndIndicatorArrays(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017,1,28)
        self.SetEndDate(2017,1,30)
        self.SetCash(100000)  # Set Strategy Cash
        
        # Default resolution is Minute
        self.symbol = self.AddEquity("SPY").Symbol
        
        # Default resolution is the one defined by AddEquity
        self.macd = self.MACD(self.symbol, 12, 26, 9, MovingAverageType.Simple)
        self.rsi = self.RSI(self.symbol, 14, MovingAverageType.Simple)
        self.history = self.History(self.symbol, 240).close.unstack(0)

        index = []
        macdHistory = {}
        rsiHistory = {}

        for time, close in self.history[self.symbol].iteritems():
            index.append(time)
            
            self.macd.Update(time, close)
            if self.macd.IsReady:
                macdHistory[time] = self.macd.Current.Value
            
            self.rsi.Update(time, close)
            if self.rsi.IsReady:
                rsiHistory[time] = self.rsi.Current.Value
        
        self.history = pd.DataFrame({
            'Close': self.history[self.symbol],
            'MACD': pd.Series(data=macdHistory, index=index),
            'RSI': pd.Series(data=rsiHistory, index=index)
        })

        self.history = self.history.dropna(how='any',axis=0)