Overall Statistics
#The investment universe consists of countries for which stock market index data are available and in which the proportion of population the professing Muslim faith
#exceeded 50%. Most of the countries could be easily tracked via index ETFs. The research paper we use as an example uses 14 Muslim countries.
#Ramadan is the ninth month in the Islamic calendar, which is based on the motion of the moon. The Ramadan month could be calculated by using information on the
#lunar phases and sunset times from astronomical calendar or information about Ramadan dates from various public sources.
#The trading strategy is simple. The investor holds an equally weighted portfolio of ETFs during Ramadan month. He/she is otherwise invested in cash.

from datetime import datetime
import pandas as pd

class Ramadan_Effect(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2004, 1, 1)
        self.symbols = ['TUR', 'GULF', 'GAF', 'PAK', 'UAE', 'QAT', 'EGPT', 'EWM', 'EIDO', 'KSA']
        for symbol in self.symbols:
            self.AddEquity(symbol, Resolution.Daily)

        ramadan_dates = pd.read_csv('https://docs.google.com/spreadsheets/d/1mj5GwY8JZm4trprEk0eGzC7Uzku_kosdV97SpIJAxz4/export?format=csv', header=None, sep=';')
        start_dates = [datetime.strptime(x[0], "%d.%m.%Y") for x in ramadan_dates.values]
        end_dates = [datetime.strptime(x[1], "%d.%m.%Y") for x in ramadan_dates.values]

        self.Schedule.On(self.DateRules.On(start_dates), self.TimeRules.AfterMarketOpen(self.symbols[0]), self.Open)
        self.Schedule.On(self.DateRules.On(end_dates), self.TimeRules.AfterMarketOpen(self.symbols[0]), self.Close)

    def Open(self):
        if not self.Portfolio.Invested:
            for symbol in self.symbols:
                self.SetHoldings(symbol, 1/10)

    def Close(self):