Overall Statistics
Total Trades
342
Average Win
1.02%
Average Loss
-0.70%
Compounding Annual Return
1.436%
Drawdown
8.800%
Expectancy
0.268
Net Profit
35.907%
Sharpe Ratio
0.419
Probabilistic Sharpe Ratio
0.286%
Loss Rate
49%
Win Rate
51%
Profit-Loss Ratio
1.46
Alpha
0.012
Beta
0.035
Annual Standard Deviation
0.036
Annual Variance
0.001
Information Ratio
-0.399
Tracking Error
0.191
Treynor Ratio
0.436
Total Fees
$1764.07
Estimated Strategy Capacity
$210000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
# 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))