SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: how does the transactionFee work [ Reply ]
By: Brian Peterson on 2015-05-07 12:55
[forum:42220]
The code you copy may make more sense in context here:

https://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/addTxn.R?view=markup&root=blotter

That code is only executed if a single transaction causes the position to cross through zero.

In average cost accounting, the cost basis only changes if you are moving the position further from zero, and you only realize P&L if you are moving the position closer to zero. So we (like many brokers) need to split any transaction that crosses the position through zero.

Most of the time, transactions don't cross the position through zero.

So you can probably ignore that code if that's not the way you trade, or look at it in context to understand what we're doing to split it. Another 'reasonable' option would have put all the fees on one part of the zero-position-divide, but we decided that splitting it is fairer to different ways of thinknig about your P&L.

Regards,

Brian

RE: how does the transactionFee work [ Reply ]
By: Anand Iragavarapu on 2015-05-07 12:39
[forum:42219]
Thanks Brian for the quick response.

the method works fine. however I am confused with the below code in the addTxn method.

if (PrevPosQty != 0 && sign(PrevPosQty + TxnQty) != sign(PrevPosQty) &&
PrevPosQty != -TxnQty) {
txnFeeQty = txnfees/abs(TxnQty)
addTxn(Portfolio = pname, Symbol = Symbol, TxnDate = TxnDate,
TxnQty = -PrevPosQty, TxnPrice = TxnPrice, ..., TxnFees = txnFeeQty *
abs(PrevPosQty), ConMult = ConMult, verbose = verbose,
eps = eps)
TxnDate = TxnDate + 2 * eps
TxnQty = TxnQty + PrevPosQty
PrevPosQty = 0
txnfees = txnFeeQty * abs(TxnQty + PrevPosQty)
}

I observed that the transaction fee is being divided by PrevPosQty and then multiplied by the TxnQty. why is this being done?

RE: how does the transactionFee work [ Reply ]
By: Brian Peterson on 2015-05-07 10:15
[forum:42218]
if you have a fixed fee, just pass it as a number. The documentation is clear that this is allowed. You only need a function for tnxFees if you have something more complicated, like a percentage charge, or a per-contract charge. If you have a fixed fee, e.g. $9.95, just pass it as 9.95

how does the transactionFee work [ Reply ]
By: Anand Iragavarapu on 2015-05-07 06:32
[forum:42217]
My broker charges a fixed fee per transaction instead of a percent. how can i incorporate it in addTxn function. is it that i need to calculate the total transaction value divide it by quantity and then supply it to the function.

can i not just add the transactionFees as a value.

Thanks to:
Vienna University of Economics and Business Powered By FusionForge