Hi Guys,

I am trying to backtest and draw chart locally with latest download Lean-master 2016-05-17.

When I am using the C# BasicTemplateAlgorithm and Resolution.Second, everything works as expected.One trade is made, statistics generated and chart shown.

But when I change to Resolution.Daily, no trades are made, no stats are generated and no chart is shown (see logs below)

I have changed BasicTemplateAlgorithm.cs to the following:

using QuantConnect.Data; using QuantConnect.Data.Market; namespace QuantConnect.Algorithm.CSharp { /// <summary> /// Basic template algorithm simply initializes the date range and cash /// </summary> public class BasicTemplateAlgorithm : QCAlgorithm { /// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> public override void Initialize() { SetStartDate(2013, 10, 07); //Set Start Date SetEndDate(2013, 10, 11); //Set End Date SetCash(100000); //Set Strategy Cash // Find more symbols here: http://quantconnect.com/data AddEquity("SPY", Resolution.Second); // This works with public override void OnData(Slice data) //AddEquity("SPY", Resolution.Daily); // This does not work with public void OnData(TradeBars data), which i think it should //AddEquity("SPY", Resolution.Minute); // This does not work with public void OnData(TradeBars data), which i think it should } // Uncomment the following to backtest with Resolution.Second (this works), at the the same time comment out OnData(TradeBars data) method below public override void OnData(Slice data) // This works with Resolution.Second { if (!Portfolio.Invested) { SetHoldings("SPY", 1); Debug("Purchased Stock"); } } // Uncomment the following to backtest with Resolution.Daily (doesn't work), at the the same time comment out OnData(Slice data) method above //public void OnData(TradeBars data) { // This doesn't work with Resolution.Daily (or Resolution.Minute), which I think it should. // if (!Portfolio.Invested) { // SetHoldings("SPY", 1); // Debug("Purchased Stock"); // } //} } }

The reasong I chage the OnData() method from Slice to TradeBars when using daily data is that I could not get Slice to work with Resolution.Daily. So I looked at how it is done in DailyAlgorithm.cs, but this still doesn't work.

 

Relevant lines in my Launcher/config.json are as follows (the only changes are 'environment', 'job-user-id' and 'api-access-token'):

"environment": "backtesting-desktop", "algorithm-type-name": "BasicTemplateAlgorithm", "algorithm-language": "CSharp", "algorithm-location": "QuantConnect.Algorithm.CSharp.dll", "data-folder": "../../../Data/", "job-user-id": "#####", (where ##### is the job id i got from the backtesting terminal) "api-access-token": "xxx", (where xxx is my access token from quantconnect.com/account)

 

Log output to LeanWinForm when it is working OK with Resolution.Second and OnData(Slice data):

2016-05-20T08:25:04.2270452Z Trace Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/ 2016-05-20T08:25:04.2280452Z Trace Config.Get(): Configuration key not found. Key: version-id - Using default value: 2016-05-20T08:25:04.2280452Z Trace Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.2.0.2 Mode: DEBUG 2016-05-20T08:25:04.2280452Z Trace Engine.Main(): Started 10:25 2016-05-20T08:25:05.4641159Z Trace Engine.Main(): Memory 42Mb-App 3Mb-Used 2195Mb-Total 2016-05-20T08:25:05.4691162Z Trace Config.GetValue(): job-project-id - Using default value: 0 2016-05-20T08:25:05.7131302Z Trace JobQueue.NextJob(): Selected QuantConnect.Algorithm.CSharp.dll 2016-05-20T08:25:05.7211306Z Trace Config.Get(): Configuration key not found. Key: history-provider - Using default value: SubscriptionDataReaderHistoryProvider 2016-05-20T08:25:05.7491322Z Trace JOB HANDLERS: 2016-05-20T08:25:05.7491322Z Trace DataFeed: QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed 2016-05-20T08:25:05.7501323Z Trace Setup: QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler 2016-05-20T08:25:05.7501323Z Trace RealTime: QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler 2016-05-20T08:25:05.7501323Z Trace Results: QuantConnect.Lean.Engine.Results.BacktestingResultHandler 2016-05-20T08:25:05.7501323Z Trace Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler 2016-05-20T08:25:05.7501323Z Trace History: QuantConnect.Lean.Engine.HistoricalData.SubscriptionDataReaderHistoryProvider 2016-05-20T08:25:05.7501323Z Trace Commands: QuantConnect.Queues.EmptyCommandQueueHandler 2016-05-20T08:25:05.7501323Z Trace Config.GetValue(): ignore-version-checks - Using default value: False 2016-05-20T08:25:05.7561326Z Trace Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 10 2016-05-20T08:25:05.7771338Z Trace Config.Get(): Configuration key not found. Key: ironpython-location - Using default value: ../ironpython/Lib 2016-05-20T08:25:05.7811341Z Trace Loader.TryCreateILAlgorithm(): Loading only the algorithm assembly 2016-05-20T08:25:05.8081356Z Trace Loader.TryCreateILAlgorithm(): Loaded BasicTemplateAlgorithm 2016-05-20T08:25:05.9581442Z Trace BacktestingResultHandler(): Sample Period Set: 04,00 2016-05-20T08:25:05.9591443Z Trace Time.TradeableDates(): Security Count: 1 2016-05-20T08:25:05.9611444Z Trace Config.GetValue(): forward-console-messages - Using default value: True 2016-05-20T08:25:05.9811455Z Trace AlgorithmManager.Run(): Begin DataStream - Start: 2013-10-07 00:00:00 Stop: 2013-10-11 23:59:59 2016-05-20T08:25:05.9901460Z Trace FileSystemDataFeed.GetEnumerator(): Begin: 2013-10-07 04:00:00 UTC 2016-05-20T08:25:15.8337091Z Trace FileSystemDataFeed.Run(): Data Feed Completed at 2013-10-11 20:00:00 UTC 2016-05-20T08:25:15.8337091Z Trace AlgorithmManager.Run(): Firing On End Of Algorithm... 2016-05-20T08:25:15.8337091Z Trace Engine.Run(): Exiting Algorithm Manager 2016-05-20T08:25:15.9617164Z Trace Launching analysis for BasicTemplateAlgorithm with LEAN Engine v2.2.0.2 2016-05-20T08:25:19.0918954Z Trace Purchased Stock 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Total Trades 1 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Average Win 0% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Average Loss 0% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Compounding Annual Return 264,956% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Drawdown 2,200% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Expectancy 0 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Net Profit 0% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Sharpe Ratio 4.411 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Loss Rate 0% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Win Rate 0% 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Profit-Loss Ratio 0 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Alpha 0.002 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Beta 1 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Annual Standard Deviation 0.193 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Annual Variance 0.037 2016-05-20T08:25:19.1819006Z Trace STATISTICS:: Information Ratio 6.816 2016-05-20T08:25:19.1829006Z Trace STATISTICS:: Tracking Error 0 2016-05-20T08:25:19.1839007Z Trace STATISTICS:: Treynor Ratio 0.851 2016-05-20T08:25:19.1849007Z Trace STATISTICS:: Total Fees $3,09 2016-05-20T08:25:19.1919011Z Trace StreamingApi.Transmit(): Packet too long: QuantConnect.Packets.BacktestResultPacket 2016-05-20T08:25:19.3759117Z Trace Algorithm Id:(BasicTemplateAlgorithm) completed in 9,95 seconds at 12k data points per second. Processing total of 117 005 data points. 2016-05-20T08:25:20.1519560Z Trace BacktestingResultHandler.SendAnalysisResult(): Processed final packet 2016-05-20T08:25:20.1529561Z Trace FileSystemDataFeed.Exit(): Exit triggered. 2016-05-20T08:25:20.1869580Z Trace BrokerageTransactionHandler.Run(): Ending Thread... 2016-05-20T08:25:20.1969586Z Trace BacktestingResultHandler.ProcessLogMessages(): Ready: http://data.quantconnect.com/backtests/#####/0/BasicTemplateAlgorithm-log.txt 2016-05-20T08:25:20.1979587Z Trace StateCheck.Ping.Run(): Exited thread. 2016-05-20T08:25:20.2329607Z Trace FileSystemDataFeed.Run(): Ending Thread... 2016-05-20T08:25:20.2389610Z Trace Your log was successfully created and can be downloaded from: http://data.quantconnect.com/backtests/#####/0/BasicTemplateAlgorithm-log.txt 2016-05-20T08:25:20.2979644Z Trace Waiting for threads to exit... 2016-05-20T08:25:20.5269775Z Trace BacktestingResultHandler.Run(): Ending Thread... 2016-05-20T08:25:20.5979816Z Trace Waiting for threads to exit... 2016-05-20T08:25:20.5979816Z Trace Engine.Run(): Disconnecting from brokerage... 2016-05-20T08:25:20.5979816Z Trace Engine.Run(): Disposing of setup handler... 2016-05-20T08:25:20.6009817Z Trace Engine.Main(): Analysis Completed and Results Posted. 2016-05-20T08:25:20.6019818Z Trace BacktestingResultHandler.ProcessLogMessages(): Ready: http://data.quantconnect.com/backtests/#####/0/BasicTemplateAlgorithm-log.txt 2016-05-20T08:25:20.6029818Z Trace FileSystemDataFeed.Exit(): Exit triggered.

 

Log output to LeanWinForm when it isn't working with Resolution.Daily and OnData(TradeBars data):

2016-05-20T08:45:28.7140818Z Trace Time.TradeableDates(): Security Count: 1 2016-05-20T08:45:28.7160820Z Trace Config.GetValue(): forward-console-messages - Using default value: True 2016-05-20T08:45:28.7560842Z Trace AlgorithmManager.Run(): Begin DataStream - Start: 2013-10-07 00:00:00 Stop: 2013-10-11 23:59:59 2016-05-20T08:45:28.7650848Z Trace FileSystemDataFeed.GetEnumerator(): Begin: 2013-10-07 04:00:00 UTC 2016-05-20T08:45:28.9300942Z Trace FileSystemDataFeed.Run(): Data Feed Completed at 2013-10-12 04:00:00 UTC 2016-05-20T08:45:28.9310943Z Trace AlgorithmManager.Run(): Firing On End Of Algorithm... 2016-05-20T08:45:28.9310943Z Trace Engine.Run(): Exiting Algorithm Manager 2016-05-20T08:45:29.1051042Z Trace BacktestingResultHandler.SendAnalysisResult(): Processed final packet 2016-05-20T08:45:29.1061043Z Trace FileSystemDataFeed.Exit(): Exit triggered. 2016-05-20T08:45:29.1451065Z Trace BrokerageTransactionHandler.Run(): Ending Thread... 2016-05-20T08:45:29.1641076Z Trace BacktestingResultHandler.ProcessLogMessages(): Ready: http://data.quantconnect.com/backtests/#####/0/BasicTemplateAlgorithm-log.txt 2016-05-20T08:45:29.1661077Z Trace StateCheck.Ping.Run(): Exited thread. 2016-05-20T08:45:29.1841087Z Trace FileSystemDataFeed.Run(): Ending Thread... 2016-05-20T08:45:29.1881090Z Trace BacktestingResultHandler.Run(): Ending Thread... 2016-05-20T08:45:29.2671135Z Trace Waiting for threads to exit... 2016-05-20T08:45:29.2671135Z Trace Engine.Run(): Disconnecting from brokerage... 2016-05-20T08:45:29.2671135Z Trace Engine.Run(): Disposing of setup handler... 2016-05-20T08:45:29.2671135Z Trace Engine.Main(): Analysis Completed and Results Posted. 2016-05-20T08:45:29.2671135Z Trace BacktestingResultHandler.ProcessLogMessages(): Ready: http://data.quantconnect.com/backtests/#####/0/BasicTemplateAlgorithm-log.txt 2016-05-20T08:45:29.2671135Z Trace FileSystemDataFeed.Exit(): Exit triggered.

 

I am backtesting this locally in Win7 and use VS2015.2 community edition.

What am I missing here?