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 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
namespace QuantConnect.Algorithm.CSharp { public class ResistanceNadionCoreWave : QCAlgorithm { private Dictionary<string, TradeBar> MyStocks = new Dictionary<string, TradeBar>(); public override void Initialize() { SetStartDate(2018, 1, 1); //Set Start Date SetCash(5000); //Set Strategy Cash // AddEquity("SPY", Resolution.Minute); AddUniverse(CoarseSelectionFilter); UniverseSettings.Resolution = Resolution.Minute; UniverseSettings.Leverage = 2; Schedule.On(DateRules.Every(DayOfWeek.Friday), TimeRules.At(11,30), CloseAllPositions); } /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// Slice object keyed by symbol containing the stock data public override void OnData(Slice data) { foreach(var security in Securities) { var symbol = security.Key; if(!Portfolio[symbol].Invested && MyStocks[symbol] != null) { Log("Not invested in " + security.Key + " and Consolidator set"); if(data[symbol].Close > MyStocks[symbol].High) { SetHoldings(symbol, 1.0m/Securities.Count); Log("Long: " + symbol); } if(data[symbol].Close < MyStocks[symbol].Low) { SetHoldings(symbol, -1.0m/Securities.Count); Log("Short: " + symbol); } } } // if (!Portfolio.Invested) // { // SetHoldings(_spy, 1); // Debug("Purchased Stock"); //} } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach(var security in changes.AddedSecurities) { if(!MyStocks.ContainsKey(security.Symbol)) { MyStocks.Add(security.Symbol, null); Consolidate(security.Symbol, TimeSpan.FromMinutes(30), OnDataConsolidation); } } } private void OnDataConsolidation(TradeBar bar) { if(bar.Time.Hour == 9 && bar.Time.Minute == 30) { MyStocks[bar.Symbol.Value] = bar; } } private void CloseAllPositions() { foreach(var security in Securities) { Liquidate(security.Key); MyStocks[security.Key] =null; } } public IEnumerable<Symbol> CoarseSelectionFilter(IEnumerable<CoarseFundamental> coarse) { var sortedByDollarVolume = coarse.OrderByDescending(x => x.DollarVolume); var filteredByPrice = sortedByDollarVolume.Where(x => x.Price > 10).Select(x => x.Symbol); filteredByPrice = filteredByPrice.Take(10); return filteredByPrice; } } }