Feature Request: Stamp Duty
In the UK, a 0.5% stamp duty applies to stock purchases but not sales.
This means for the UK market, I will be looking to create a commission scheme which has a mix of
COM_PERCfor buying and only a
In other words my broker has a flat fee but I need to take into account the profit killing stamp duty :)
Not sure how many markets this applies to but it would be useful enhancement for the UK.
There seems to be some misunderstanding here:
COMM_FIXEDis not a flat-fee commission, but represents a fixed value per item bought (shares, futures, options, ...)
To put the stamp-duty in place (including a flat-fee) see Docs - User Defined Commissions
You need to override
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 '''
> 0if the operation is a
buyand will be
< 0if you are using
Ok - I see... I will take a look. Thanks for the pointer!
You would obviously return a fixed amount regardless of
size(hence flat) plus the
0.5%stamp duty if
size > 0
I only just got around to looking at this again. If anyone else, has the same requirement, the code I developed is as follows:
class stampDutyCommisionScheme(bt.CommInfoBase): ''' This commission scheme uses a fixed commission and stamp duty for share purchases. Share sales are subject only to the fixed commission. The scheme is intended for trading UK equities on the main market. ''' params = ( ('stamp_duty', 0.005), ('commission', 5), ('stocklike', True), ('commtype', bt.CommInfoBase.COMM_FIXED), ) def _getcommission(self, size, price, pseudoexec): ''' If size is greater than 0, this indicates a long / buying of shares. If size is less than 0, it idicates a short / selling of shares. ''' if size > 0: return self.p.commission + (size * price * self.p.stamp_duty) elif size < 0: return self.p.commission else: return 0 #just in case for some reason the size is 0.