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

PSE commission and fees scheme



  • Hi, newbie here. I am trying to replicate the commission and fees scheme of Philippine Stock Exchange by subclassing CommInfoBase.

    The scheme is discussed here with sample computation.
    https://www.pinoymoneytalk.com/fees-computation-buying-selling-stocks/

    My subclass looks like this:

    from backtrader.comminfo import CommInfoBase
    
    
    class PSECommInfo(CommInfoBase):
    
        def _getcommission(self, size, price, pseudoexec):
            '''Calculates the commission of an operation at a given price
            pseudoexec: if True the operation has not yet been executed
    
            PSE fees reference:
            https://www.pinoymoneytalk.com/fees-computation-buying-selling-stocks/
            '''
    
            gross_transaction_amount = abs(size * price)
    
            if gross_transaction_amount * 0.0025 > 20:
                broker_commission = gross_transaction_amount * 0.0025
            else:
                broker_commission = 20
    
            broker_commission_VAT = broker_commission * 0.12
            SCCP_fee = gross_transaction_amount * 0.0001
            PSE_transaction_fee = gross_transaction_amount * 0.00005
    
            # Only for selling
            stock_transaction_tax = gross_transaction_amount * 0.005
    
            return broker_commission + broker_commission_VAT + SCCP_fee + PSE_transaction_fee + stock_transaction_tax
    

    My question is, how can I add the stock_transaction_tax on selling only?

    Thanks in advance!



  • It seems like I can refer it to size. If size is negative, does it mean it will sell?

    from backtrader.comminfo import CommInfoBase
    
    
    class PSECommInfo(CommInfoBase):
    
        def _getcommission(self, size, price, pseudoexec):
            '''Calculates the commission of an operation at a given price
            pseudoexec: if True the operation has not yet been executed
    
            PSE fees reference:
            https://www.pinoymoneytalk.com/fees-computation-buying-selling-stocks/
            '''
    
            gross_transaction_amount = abs(size * price)
    
            if gross_transaction_amount * 0.0025 > 20:
                broker_commission = gross_transaction_amount * 0.0025
            else:
                broker_commission = 20
    
            broker_commission_VAT = broker_commission * 0.12
            SCCP_fee = gross_transaction_amount * 0.0001
            PSE_transaction_fee = gross_transaction_amount * 0.00005
    
            fees = broker_commission + broker_commission_VAT + SCCP_fee + PSE_transaction_fee
    
            if size < 0:
                # Only for selling
                stock_transaction_tax = gross_transaction_amount * 0.005
                fees += stock_transaction_tax
    
            return fees
    

  • administrators

    @josephjospeh said in PSE commission and fees scheme:

    If size is negative, does it mean it will sell?

    Yes.



  • Hi @backtrader, would it be better to transfer other fees in getoperationcost?

    Nevermind, getoperationcost is not for fees. It just seems odd to put all of those miscellaneous fees in that function and treat them as commission.


  • administrators

    @josephjospeh said in PSE commission and fees scheme:

    Nevermind, getoperationcost is not for fees

    It is not. Fees (commisions) are in getcommission and the method which is expected to be overriden _getcommission)


Log in to reply
 

});