| 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 Probabilistic 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 -2.63 Tracking Error 0.056 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
#region imports
from AlgorithmImports import *
#endregion
# https://quantpedia.com/Screener/Details/7
# The investment universe consists of global large cap stocks (or US large cap stocks).
# At the end of the each month, the investor constructs equally weighted decile portfolios
# by ranking the stocks on the past one year volatility of daily price. The investor
# goes long stocks with the lowest volatility.
from QuantConnect.Data.UniverseSelection import *
import math
import numpy as np
import pandas as pd
class ShortTermReversalAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017,1,1)
self.SetEndDate(2017,12,31)
self.SetCash(100000)
self.UniverseSettings.Resolution = Resolution.Daily
self.universe_etf = self.Universe.ETF('SPY', Market.USA, self.UniverseSettings, self.ETFConstituentsFilter)
self.universe_fine = self.AddUniverse(self.universe_etf, self.FineSelection)
self.symbolDataDict = {}
self.daycount=0
self.Nbalance=50
def ETFConstituentsFilter(self, constituents: List[ETFConstituentData]) -> List[Symbol]:
#self.Log(f"Universe, {self.daycount},{self.Time}")
if self.daycount % self.Nbalance != 0:
return Universe.Unchanged
else:
self.Log(f"***** Universe Undate, {self.daycount}, {self.Time} *****")
U=[c.Symbol for c in constituents]
#self.Log(U[100].Value)
return U
def FineSelection(self, fine: List[FineFundamental]) -> List[Symbol]:
self.Log(f"FineSelection, {self.daycount}, {self.Time}")
self.universe_fine = [f.Symbol for f in fine]
return self.universe_fine
def OnSecuritiesChanged(self, changes):
pass
def OnData(self, data):
self.daycount = self.daycount + 1
if (self.daycount-1) % self.Nbalance != 0:
return
else:
self.Log(f"@@@@@ OnData Rebalance, {self.daycount-1}, {self.Time} @@@@@")