1. C:\Users\63036\Desktop\LeanCLI>lean backtest "Energetic Apricot Gorilla" --download-data
  2. Select the organization to purchase and download data with: yi ren
  3. [?1h=20210908 23:00:06.283 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default
  4. value:
  5. 20210908 23:00:06.291 TRACE:: Composer(): Loading Assemblies from /Lean/Launcher/bin/Debug
  6. 20210908 23:00:06.304 TRACE:: Python for .NET Assembly:
  7. QuantConnect.DataSource.ExamplePythonScriptMyCustomDataTypeDoNotUse, Version=1.0.0.0, Culture=neutral,
  8. PublicKeyToken=null
  9. 20210908 23:00:06.332 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.6.0, Culture=neutral,
  10. PublicKeyToken=5000fea6cba702dd
  11. 20210908 23:00:06.350 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value:
  12. ../../../Data/
  13. 20210908 23:00:06.353 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
  14. 20210908 23:00:06.353 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value:
  15. /Lean/Data
  16. 20210908 23:00:06.353 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) Host:
  17. DESKTOP-IRVG37J
  18. 20210908 23:00:06.357 TRACE:: Engine.Main(): Started 11:00 PM
  19. 20210908 23:00:06.358 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value:
  20. LocalLeanManager
  21. 20210908 23:00:06.370 TRACE:: JobQueue.NextJob(): Selected /LeanCLI/main.py
  22. 20210908 23:00:06.416 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
  23. 20210908 23:00:06.417 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default
  24. value: 1440
  25. 20210908 23:00:06.417 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
  26. 20210908 23:00:06.420 TRACE:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default
  27. value: DataPermissionManager
  28. 20210908 23:00:06.429 TRACE:: Config.GetValue(): data-purchase-limit - Using default value:
  29. 79228162514264337593543950335
  30. Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an
  31. invocation.
  32. ---> System.InvalidOperationException: ApiDataProvider(): Must agree to terms at
  33. https://www.quantconnect.com/terms/data/?organization=97092a1c19fb05e80f8da331c1a5b4aa, before using the
  34. ApiDataProvider
  35. at QuantConnect.Lean.Engine.DataFeeds.ApiDataProvider..ctor() in
  36. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/DataFeeds/ApiDataProvider.cs:line 92
  37. --- End of inner exception stack trace ---
  38. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean&
  39. canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
  40. at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
  41. at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache,
  42. Boolean wrapExceptions)
  43. at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
  44. at QuantConnect.Util.Composer.GetExportedValueByTypeName[T](String typeName) in
  45. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Util/Composer.cs:line 259
  46. at QuantConnect.Lean.Engine.LeanEngineAlgorithmHandlers.FromConfiguration(Composer composer) in
  47. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/LeanEngineAlgorithmHandlers.cs:line 198
  48. at QuantConnect.Lean.Engine.Initializer.GetAlgorithmHandlers() in
  49. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Initializer.cs:line 78
  50. at QuantConnect.Lean.Launcher.Program.Main(String[] args) in
  51. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Launcher/Program.cs:line 72
  52. Error: Something went wrong while running 'Energetic Apricot Gorilla' in the 'backtesting' environment, the output is
  53. stored in 'Energetic Apricot Gorilla\backtests\2021-09-09_07-00-03'
  54. C:\Users\63036\Desktop\LeanCLI>lean backtest "Pensive Magenta Dinosaur" --download-data
  55. Select the organization to purchase and download data with: yi ren
  56. [?1h=20210908 23:03:05.136 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default
  57. value:
  58. 20210908 23:03:05.144 TRACE:: Composer(): Loading Assemblies from /Lean/Launcher/bin/Debug
  59. 20210908 23:03:05.158 TRACE:: Python for .NET Assembly:
  60. QuantConnect.DataSource.ExamplePythonScriptMyCustomDataTypeDoNotUse, Version=1.0.0.0, Culture=neutral,
  61. PublicKeyToken=null
  62. 20210908 23:03:05.185 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.6.0, Culture=neutral,
  63. PublicKeyToken=5000fea6cba702dd
  64. 20210908 23:03:05.206 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value:
  65. ../../../Data/
  66. 20210908 23:03:05.209 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
  67. 20210908 23:03:05.209 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value:
  68. /Lean/Data
  69. 20210908 23:03:05.209 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) Host:
  70. DESKTOP-IRVG37J
  71. 20210908 23:03:05.212 TRACE:: Engine.Main(): Started 11:03 PM
  72. 20210908 23:03:05.214 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value:
  73. LocalLeanManager
  74. 20210908 23:03:05.226 TRACE:: JobQueue.NextJob(): Selected /LeanCLI/main.py
  75. 20210908 23:03:05.274 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
  76. 20210908 23:03:05.274 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default
  77. value: 1440
  78. 20210908 23:03:05.275 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
  79. 20210908 23:03:05.277 TRACE:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default
  80. value: DataPermissionManager
  81. 20210908 23:03:05.286 TRACE:: Config.GetValue(): data-purchase-limit - Using default value:
  82. 79228162514264337593543950335
  83. Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an
  84. invocation.
  85. ---> System.InvalidOperationException: ApiDataProvider(): Must agree to terms at
  86. https://www.quantconnect.com/terms/data/?organization=97092a1c19fb05e80f8da331c1a5b4aa, before using the
  87. ApiDataProvider
  88. at QuantConnect.Lean.Engine.DataFeeds.ApiDataProvider..ctor() in
  89. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/DataFeeds/ApiDataProvider.cs:line 92
  90. --- End of inner exception stack trace ---
  91. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean&
  92. canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
  93. at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
  94. at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache,
  95. Boolean wrapExceptions)
  96. at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
  97. at QuantConnect.Util.Composer.GetExportedValueByTypeName[T](String typeName) in
  98. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Util/Composer.cs:line 259
  99. at QuantConnect.Lean.Engine.LeanEngineAlgorithmHandlers.FromConfiguration(Composer composer) in
  100. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/LeanEngineAlgorithmHandlers.cs:line 198
  101. at QuantConnect.Lean.Engine.Initializer.GetAlgorithmHandlers() in
  102. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Initializer.cs:line 78
  103. at QuantConnect.Lean.Launcher.Program.Main(String[] args) in
  104. /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Launcher/Program.cs:line 72
  105. Error: Something went wrong while running 'Pensive Magenta Dinosaur' in the 'backtesting' environment, the output is
  106. stored in 'Pensive Magenta Dinosaur\backtests\2021-09-09_07-03-01'
+ Expand

 

  1. class PensiveMagentaDinosaur(QCAlgorithm):
  2. def Initialize(self):
  3. self.SetStartDate(2021, 3, 7) # Set Start Date
  4. self.SetCash(100000) # Set Strategy Cash
  5. self.AddEquity("SPY", Resolution.Minute)
  6. def OnData(self, data):
  7. '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
  8. Arguments:
  9. data: Slice object keyed by symbol containing the stock data
  10. '''
  11. if not self.Portfolio.Invested:
  12. self.SetHoldings("SPY", 1)

What's wrong with that

Author

Yi ren

September 2021