Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Better Error Reporting from Custom Data Types

Open AlexCatarino opened this issue 1 year ago • 3 comments

Expected Behavior

LEAN provides information about errors in Custom Data Types.

Actual Behavior

The Reader of Custom Data types doesn't always display the error to the user.

Potential Solution

TextSubscriptionDataSourceReader.ReaderError should not be null. OnReaderError will not log anywhere if it is.

Reproducing the Problem

Run CustomDataBitcoinAlgorithm in live mode. There is a bug at

coin.EndTime =  datetime.utcnow().astimezone(timezone(str(config.ExchangeTimeZone))).replace(tzinfo=None)

since the timezone constructor doesn't accept a string argument. We should receive a message:

'timezone() argument 1 must be datetime.timedelta, not str'

we can fix that line with

coin.EndTime = Extensions.ConvertFromUtc(datetime.utcnow(), config.ExchangeTimeZone)

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

AlexCatarino avatar Sep 19 '23 14:09 AlexCatarino

In addition to error non-reporting, the execution also doesn't stop at breakpoints placed in custom data class in debug mode which makes it even difficult to debug errors in it.

AmazingAbhi avatar Nov 14 '23 04:11 AmazingAbhi

In addition to error non-reporting, the execution also doesn't stop at breakpoints placed in custom data class in debug mode which makes it even difficult to debug errors in it.

Hey @AmazingAbhi! Mind clarifying how are you running Lean and reproducing the issue your mentioning? I assume python? If you can share and algorithm to reproduce the issue even better, this helps us pin and solve the issues faster, thank you!

Martin-Molinero avatar Nov 14 '23 12:11 Martin-Molinero

Issue is lean cli specific:

  1. Clone this bitstamp algo: https://www.quantconnect.com/terminal/clone/13895484/9619c8238a1f87f95f967d2db94f64bf/clone-of%3A-key-concepts-example-%5Bpy%5D
  2. Add a breakpoint anywhere in Reader function of custom data class
  3. Click on 'Debug using Lean CLI'
  4. Run in lean cli using 'lean backtest <project_name> --debug pycharm

Execution should stop at breakpoint but it doesn't.

AmazingAbhi avatar Nov 14 '23 13:11 AmazingAbhi