@jacksonx Please see the comments in the code. Backtrader broker requires position's datetime attribute to be set. The value is not that important and could be any valid python datetime object. In my case this date is taken from the previously stored transaction.
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/