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
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
namespace QuantConnect.Rotation
{
    public class GlobalRotation : QCAlgorithm
    {
		private int N = 3;
		private int period = 6*21;
        // these are the growth symbols we'll rotate through
        List<string> GrowthSymbols = new List<string>
        {
            			"EWJ",  //# iShares MSCI Japan Index ETF
                        "EZU",  //# iShares MSCI Eurozone ETF
                        "EFNL", //# iShares MSCI Finland Capped Investable Market Index ETF
                        "EWW",  //# iShares MSCI Mexico Inv. Mt. Idx
                        "ERUS", //# iShares MSCI Russia ETF
                        "IVV",  //# iShares S&P 500 Index
                        "ICOL", //# Consumer Discretionary Select Sector SPDR Fund
                        "AAXJ", //# iShares MSCI All Country Asia ex Japan Index ETF
                        "AUD",  //# Australia Bond Index Fund
                        "EWQ",  //# iShares MSCI France Index ETF
                        "BUND", //# Pimco Germany Bond Index Fund
                        "EWH",  //# iShares MSCI Hong Kong Index ETF
                        "EPI",  //# WisdomTree India Earnings ETF
                        "EIDO", // # iShares MSCI Indonesia Investable Market Index ETF
                        "EWI",  //# iShares MSCI Italy Index ETF
                        "GAF",  //# SPDR S&P Emerging Middle East & Africa ETF
                        "ENZL", //# iShares MSCI New Zealand Investable Market Index Fund
                        "NORW",  //# Global X FTSE Norway 30 ETF
                        "EWY",  //# iShares MSCI South Korea Index ETF
                        "EWP",  //# iShares MSCI Spain Index ETF
                        "EWD",  //# iShares MSCI Sweden Index ETF
                        "EWL",  //# iShares MSCI Switzerland Index ETF
                        "GXC",  //# SPDR S&P China ETF
                        "EWC",  //# iShares MSCI Canada Index ETF
                        "EWZ",  ///# iShares MSCI Brazil Index ETF
                        "ARGT", //# Global X FTSE Argentina 20 ETF
                        "AND",  //# Global X FTSE Andean 40 ETF
                        "AIA",  //# iShares S&P Asia 50 Index ETF
                        "EWO",  //# iShares MSCI Austria Investable Mkt Index ETF
                        "EWK",  //# iShares MSCI Belgium Investable Market Index ETF
                        "BRAQ", //# Global X Brazil Consumer ETF
                        "ECH",  //# iShares MSCI Chile Investable Market Index ETF
                        "CHIB", //# Global X China Technology ETF
                        "EGPT", //# Market Vectors Egypt Index ETF
                        "ADRU", //# BLDRS Europe 100 ADR Index ETF
                        "EDV", //#20+yr treasure bond
                        "SHY", //#1-3y treasure bonds
                        "GLD", //#gold
                        "DBC", //#commodities
        };

        // these are the safety symbols we go to when things are looking bad for growth
        List<string> SafetySymbols = new List<string>
        {
  
        };

        // we'll hold some computed data in these guys
        List<SymbolData> SymbolData = new List<SymbolData>();

        public override void Initialize()
        {
            
            SetStartDate(2017, 12, 25);
            SetEndDate(2018, 1, 15);
			SetCash(100000);
			SetWarmUp(period);
			
            foreach (var symbol in GrowthSymbols)
            {
                // ideally we would use daily data
                AddSecurity(SecurityType.Equity, symbol, Resolution.Daily);
                var threeMonthPerformance = MOM(symbol, period, Resolution.Daily);

                SymbolData.Add(new SymbolData
                {
                    Symbol = symbol,
                    ThreeMonthPerformance = threeMonthPerformance
                });
            }
            
            
            
            //# shcedule the function to fire at the month start 
        	Schedule.On(DateRules.MonthStart("IVV"), TimeRules.AfterMarketOpen("IVV"), Rebalance);
        }

        public void OnData(TradeBars data)
        {
          
        }
        
        public void Rebalance() 
        {
        		if (IsWarmingUp) return;
        		// pick which one is best from growth and safety symbols
        			Debug(Time.ToString());
                    
                    
					
                    var orderedObjScores = SymbolData.OrderByDescending(x => x.ObjectiveScore).ToList();
                    foreach (var t in orderedObjScores) {
						Debug(t.Symbol + "    " + t.ObjectiveScore);
					}
					/*
					
                    foreach (var orderedObjScore in orderedObjScores)
                    {
                        Log(">>SCORE>>" + orderedObjScore.Symbol + ">>" + orderedObjScore.ObjectiveScore);
                    }
                    var top = orderedObjScores.Take(N);
                   
			
					//liquidate
					foreach (var kvp in Portfolio)
					{
						var security_hold = kvp.Value;
						//liquidate the security which is no longer in the top momentum list
						if (security_hold.Invested)
						{
							bool inlist = false;
							foreach (var t in top) {
								if (security_hold.Symbol.Value == t.Symbol)
									inlist = true;
							}
							if (inlist)
								Liquidate(security_hold.Symbol);
						}
					}
					
					// we'll hold some computed data in these guys
        			List<SymbolData> added_symbols = new List<SymbolData>();
					foreach (var symbol in top) {
						if (!Portfolio[symbol.Symbol].Invested)
							added_symbols.Add(symbol);
					}
					
					foreach (var symbol in added_symbols) 
					{
						SetHoldings(symbol.Symbol,1/added_symbols.Count);
					}
					*/
        }
    }

    class SymbolData
    {
        public string Symbol;

        public Momentum ThreeMonthPerformance { get; set; }

        public decimal ObjectiveScore
        {
            get
            {
                return ThreeMonthPerformance;
            }
        }
    }
}