For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Access get_credit_interest in next()



  • Hello again!

    I am trying to get the interest expense in Next() block, but the problem is when an position is closed, the bbroker self.d_credit[data] is reset to zero, so I cannot get the interest applicable to the last day the stock was held. Is it possible to get interest each day in next()?

    Also: I notice the credit interest is included in order.executed.comm; is it possible to get the interest separately out of this?

    Thanks!!


  • administrators

    No. It is obvious you need a custom commission scheme which keeps track of the interest in a separate member attribute.



  • Thanks @backtrader, sounds good. Any tips how I could edit the following commission scheme to do just that?

    class CommInfo_Custom(bt.CommInfoBase):
        params = (
            ('commtype', bt.CommInfoBase.COMM_PERC), #commission to be understood as %
            # Custom broker commission fee params:
            ('min_fee', 0),  # The broker uses a %commission fee, with the "min_fee" as the minimum fee per trade. 
        )
    
        def _getcommission(self, size, price, pseudoexec):
            commvalue = abs(size) * price * self.p.commission         # %based commission value
            commvalue = max(self.p.min_fee,commvalue)                 # choose the greater of $min_fee and percentage calculated
            return commvalue
    

    Much appreciated


Log in to reply
 

});