Overall Statistics
from math import ceil,floor,isnan
from datetime import datetime
import pandas as pd
import numpy as np
from scipy.optimize import minimize



class AssetAllocationAlgorithm(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2007, 01, 01)  #Set Start Date
        self.SetEndDate(2018, 01, 01)    #Set End Date
        self.SetCash(100000)            #Set Strategy Cash

        tickers = [ "IEF", "TLT", "SPY", "EFA", "EEM", "JPXN", "VGT"]
        self.symbols = [] 
        for i in tickers:
            self.symbols.append(self.AddEquity(i, Resolution.Daily).Symbol)

        self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY"), Action(self.Rebalancing))
       

    def OnData(self, data):
        pass
        
    def Rebalancing(self):
        
  
        for syl in self.symbols:
            # equally weighted
            self.SetHoldings(syl, 1.0/len(self.symbols))