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 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
namespace QuantConnect.Algorithm.CSharp { public class ModulatedQuantumCoreWave : QCAlgorithm { IEnumerable<Symbol> MyCoarseFilterFunction(IEnumerable<CoarseFundamental> coarse) { var stocks = (from c in coarse where c.DollarVolume > 3000000 && c.Price > 15 orderby c.DollarVolume descending select c.Symbol).Take(950).ToList(); return stocks; } public override void Initialize() { SetStartDate(2020, 2, 25); //Set Start Date SetEndDate(2020, 2, 25); UniverseSettings.Resolution = Resolution.Minute; AddUniverse(MyCoarseFilterFunction); } /// 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 item in SymbolDict) { var symbol = item.Key; if (data.ContainsKey(symbol) == false) continue; var currentBar = data[symbol]; if (currentBar == null) continue; item.Value.lp = currentBar.Close; // assigned value in last minute is the last price of this trading day } } class SP { public string s; public decimal lp; public SP(string ls, decimal llp) { s = ls; lp = llp; } } IDictionary<string, SP> SymbolDict = new Dictionary<string, SP>(); public override void OnEndOfAlgorithm() { var str = ""; foreach (var item in SymbolDict) { var symbol = item.Key; var lastDayClose = item.Value.lp; lastDayClose = (decimal) System.Math.Round(lastDayClose, 2); str += $"s=\"{symbol}\",p={lastDayClose} "; } Debug($"{str}"); } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach (var added in changes.AddedSecurities) { var symbol = added.Symbol.Value; symbol = symbol.ToUpper(); if (SymbolDict.ContainsKey(symbol) == true) { // already added, for table short, the same. return; } AddEquity(symbol, Resolution.Minute); SymbolDict[symbol] = new SP(symbol, 0); } } } }
/* namespace QuantConnect.Algorithm.CSharp { public class ModulatedQuantumCoreWave : QCAlgorithm { private const int _cNumStocksSelected = 950; IEnumerable<Symbol> MyCoarseFilterFunction(IEnumerable<CoarseFundamental> coarse) { var stocks = (from c in coarse where c.DollarVolume > 3000000 && c.Price > 15 orderby c.DollarVolume descending select c.Symbol).Take(_cNumStocksSelected).ToList(); return stocks; } public override void Initialize() { SetStartDate(2020, 2, 25); //Set Start Date SetEndDate(2020, 2, 25); // AddEquity("SPY", Resolution.Minute); UniverseSettings.Resolution = Resolution.Minute; AddUniverse(MyCoarseFilterFunction); } /// 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) { // if (!Portfolio.Invested) // { // SetHoldings(_spy, 1); // Debug("Purchased Stock"); //} foreach (var item in SymbolDict) { var symbol = item.Key; if (data.ContainsKey(symbol) == false) continue; var currentBar = data[symbol]; if (currentBar == null) continue; if (data.Time.Hour == 16 && data.Time.Minute == 00) { item.Value.lp = currentBar.Close; //Debug($"{data.Time} - {symbol} last day close = {currentBar.Close}"); } } //Debug($"A bar time={currentBar.Time}"); } class SP { public string s; public decimal lp; public SP(string ls, decimal llp) { s = ls; lp = llp; } } IDictionary<string, SP> SymbolDict = new Dictionary<string, SP>(); public override void OnEndOfAlgorithm() { int numPerLine = 3000; string str = ""; foreach (var item in SymbolDict) { var symbol = item.Key; var lastDayClose = item.Value.lp; if (numPerLine < 0) { Debug($"{str}"); numPerLine = 3000; str = ""; } //str += $"\"{symbol}\", "; // example: new symbolLastPrice{symbol="a",lastPrice=1.11m}, lastDayClose = (decimal) System.Math.Round(lastDayClose, 2); //str += $"new SP{{s=\"{symbol}\",lp={lastDayClose}m}},"; str += $"s=\"{symbol}\",p={lastDayClose} "; numPerLine--; } Debug($"{str}"); } public override void OnSecuritiesChanged(SecurityChanges changes) { //if (LiveMode) { //Debug($"OnSecuritiesChanged, RemovedSecurities: "+string.Join(",", changes.RemovedSecurities.Select(x => x.Symbol.Value))); //Debug($"OnSecuritiesChanged, AddedSecurities: "+string.Join(",", changes.AddedSecurities.Select(x => x.Symbol.Value))); //} foreach (var removed in changes.RemovedSecurities) { var symbol = removed.Symbol.Value; } int numPerLine = 3000; string str = ""; foreach (var added in changes.AddedSecurities) { var symbol = added.Symbol.Value; symbol = symbol.ToUpper(); if (SymbolDict.ContainsKey(symbol) == true) { // already added, for table short, the same. return; } var s = AddEquity(symbol, Resolution.Minute).Symbol; var history = History<TradeBar>(s, 1, Resolution.Daily); //decimal lastDayClose = 0; //if (history.Count() == 1) // lastDayClose = history.Last().Close; SymbolDict[symbol] = new SP(symbol, 0); /* //var history = History<TradeBar>(s, 1, Resolution.Daily); //if (history.Count() == 1) // lastDayClose = history.Last().Close; //else //Debug($"Error: {symbol} history Count is not 1, but {history.Count()} instead"); if (numPerLine < 0) { Debug($"{str}"); numPerLine = 3000; str = ""; } //str += $"\"{symbol}\", "; // example: new symbolLastPrice{symbol="a",lastPrice=1.11m}, lastDayClose = (decimal) System.Math.Round(lastDayClose, 2); str += $"new SP{{s=\"{symbol}\",lp={lastDayClose}m}},"; numPerLine--; * } //Debug($"{str}"); } } } */