Overall Statistics
Total Trades
338
Average Win
1.02%
Average Loss
-0.71%
Compounding Annual Return
1.486%
Drawdown
8.800%
Expectancy
0.273
Net Profit
36.818%
Sharpe Ratio
0.431
Probabilistic Sharpe Ratio
0.353%
Loss Rate
48%
Win Rate
52%
Profit-Loss Ratio
1.45
Alpha
0.013
Beta
0.035
Annual Standard Deviation
0.036
Annual Variance
0.001
Information Ratio
-0.378
Tracking Error
0.192
Treynor Ratio
0.449
Total Fees
$1757.60
Estimated Strategy Capacity
$270000000.00
 
 
# https://quantpedia.com/strategies/momentum-factor-effect-in-country-equity-indexes/
#
# The investor is invested in stocks during FOMC meetings (going long S&P 500 ETF, fund, future, or CFD on a close one day before the meeting and closing position on close after the meeting).
# Otherwise, he is invested in cash during the remaining days. The strategy has very low exposure to the stock market (8 days during the average year); therefore, it can be very easily leveraged
# to gain very significant returns.
#
# QC implementation:
#   - FED dates are imported from text file.

from pandas.tseries.offsets import BDay

class MomentumFactorEffectinCountryEquityIndexes(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2000, 1, 1)
        self.SetCash(100000)
        
        self.SetBrokerageModel(BrokerageName.AlphaStreams)
        
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())
        
        self.symbol = self.AddEquity("SPY", Resolution.Minute).Symbol

        # fed days
        csv_string_file = self.Download('data.quantpedia.com/backtesting_data/economic/fed_days.csv')
        dates = csv_string_file.split('\r\n')
        dates = [datetime.strptime(x, "%Y-%m-%d") - BDay(1) for x in dates]
        
        self.Schedule.On(self.DateRules.On(dates), self.TimeRules.BeforeMarketClose(self.symbol, 1), self.DayBeforeFED)
    
    def DayBeforeFED(self):
        self.EmitInsights(Insight.Price(self.symbol, timedelta(minutes = 6.5*60 - 1), InsightDirection.Up, None, None, None, 1))