| Overall Statistics |
|
Total Trades
362
Average Win
1.03%
Average Loss
-0.73%
Compounding Annual Return
1.479%
Drawdown
8.800%
Expectancy
0.266
Net Profit
39.870%
Sharpe Ratio
0.353
Probabilistic Sharpe Ratio
0.008%
Loss Rate
48%
Win Rate
52%
Profit-Loss Ratio
1.41
Alpha
0.009
Beta
0.035
Annual Standard Deviation
0.03
Annual Variance
0.001
Information Ratio
-0.288
Tracking Error
0.159
Treynor Ratio
0.303
Total Fees
$1835.22
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 AlgorithmImports import *
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))