For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
I read the code about backtrader/utils/autodict/AutoDict,but find something maybe wrong...
-
class AutoDict(dict): _closed = False def _close(self): self._closed = True for key, val in self.items(): if isinstance(val, (AutoDict, AutoOrderedDict)): val._close() def _open(self): self._closed = False def __missing__(self, key): if self._closed: raise KeyError value = self[key] = AutoDict() return value def __getattr__(self, key): if False and key.startswith('_'): raise AttributeError return self[key] def __setattr__(self, key, value): if False and key.startswith('_'): self.__dict__[key] = value return self[key] = value
your code about : if False and some_code: do something
I think ,it will never run do something.mybe you just want write this code.
mybe,you should replace "False" with "self._closed", I guess.I have used backtrader for more than one year to backtest my strategy, I also find many errors, so,I have to read the source code,to understand backtrader's framework and details.
Anyway, thank you!
-
It's code that was tested for development and considered, was left there but nullified.
@tianjixuetu said in I read the code about backtrader/utils/autodict/AutoDict,but find something maybe wrong...:
I also find many errors
Which you of course duly reported.