For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
possible bug in TradeAnalyzer.get_analysis
-
Hello,
I am using
backtrader==1.9.64.122
Below you can see the output ofbt.analyzers.TradeAnalyzer
, accessed by.get_analysis()
of the analyzer. The field['won']['total']
always showsboolean
where anint
value is expected.AutoOrderedDict([('total', AutoOrderedDict([('total', 1), ('open', 0), ('closed', 1)])), ('streak', AutoOrderedDict([('won', AutoOrderedDict([('current', True), ('longest', True)])), ('lost', AutoOrderedDict([('current', 0), ('longest', 0)]))])), ('pnl', AutoOrderedDict([('gross', AutoOrderedDict([('total', 0.0007999999999999119), ('average', 0.0007999999999999119)])), ('net', AutoOrderedDict([('total', 0.0007999999999999119), ('average', 0.0007999999999999119)]))])), ('won', AutoOrderedDict([('total', True), ('pnl', AutoOrderedDict([('total', 0.0007999999999999119), ('average', 0.0007999999999999119), ('max', 0.0007999999999999119)]))])), ('lost', AutoOrderedDict([('total', 0), ('pnl', AutoOrderedDict([('total', 0.0), ('average', 0.0), ('max', 0.0)]))])), ('long', AutoOrderedDict([('total', 1), ('pnl', AutoOrderedDict([('total', 0.0007999999999999119), ('average', 0.0007999999999999119), ('won', AutoOrderedDict([('total', 0.0007999999999999119), ('average', 0.0007999999999999119), ('max', 0.0007999999999999119)])), ('lost', AutoOrderedDict([('total', 0.0), ('average', 0.0), ('max', 0.0)]))])), ('won', True), ('lost', 0)])), ('short', AutoOrderedDict([('total', 0), ('pnl', AutoOrderedDict([('total', 0.0), ('average', 0.0), ('won', AutoOrderedDict([('total', 0.0), ('average', 0.0), ('max', 0.0)])), ('lost', AutoOrderedDict([('total', 0.0), ('average', 0.0), ('max', 0.0)]))])), ('won', False), ('lost', 0)])), ('len', AutoOrderedDict([('total', 15), ('average', 15.0), ('max', 15), ('min', 15), ('won', AutoOrderedDict([('total', 15), ('average', 15.0), ('max', 15), ('min', 15)])), ('lost', AutoOrderedDict([('total', 0), ('average', 0.0), ('max', 0)])), ('long', AutoOrderedDict([('total', 15), ('average', 15.0), ('max', 15), ('min', 15), ('won', AutoOrderedDict([('total', 15), ('average', 15.0), ('max', 15), ('min', 15)])), ('lost', AutoOrderedDict([('total', 0), ('average', 0.0), ('max', 0), ('min', 9223372036854775807)]))])), ('short', AutoOrderedDict([('total', 0), ('average', 0.0), ('max', 0), ('min', 9223372036854775807), ('won', AutoOrderedDict([('total', 0), ('average', 0.0), ('max', 0), ('min', 9223372036854775807)])), ('lost', AutoOrderedDict([('total', 0), ('average', 0.0), ('max', 0), ('min', 9223372036854775807)]))]))]))]) AutoOrderedDict([('total', AutoOrderedDict([('total', 0)]))])
-
This is an artifact, because you only have 1 trade and initial sum is done using a
won/lost
boolean. If you had more trades you wouldn't seeTrue
.