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

Is this a bug for broker?



  • I am trying to implement my own broker, after reading the source, I am quite confused.
    https://github.com/backtrader/backtrader/blob/master/backtrader/broker.py#L46

    class MetaBroker(MetaParams):
        def __init__(cls, name, bases, dct):
            '''
            Class has already been created ... fill missing methods if needed be
            '''
            # Initialize the class
            super(MetaBroker, cls).__init__(name, bases, dct)
            translations = {
                'get_cash': 'getcash',
                'get_value': 'getvalue',
            }
    
            for attr, trans in translations.items():
                if not hasattr(cls, attr):
                    setattr(cls, name, getattr(cls, trans))
    

    may be you are intent to given an alias name to the function, and this
    setattr(cls, name, getattr(cls, trans))
    should be
    setattr(cls, attr, getattr(cls, trans))

    am i right? or am i missing something?


Log in to reply
 

});