Skip to content
Prev 6655 / 15274 Next

quantstrat- adding transaction fee to rule

Andre,

I was able to replicate the problem.  While it was true that we were not
passing dots properly in all places (this is now fixed), the problem turned
out to be a little more complicated than that because the order book is
stored as a character xts time series, so the TxnFees also needed to be
converted to numeric.

You may now specify TxnFees a a parameter in the arguments=list() for
ruleSignal.  In the Faber demo, to set TxnFees to -5 as you requested, this
looks like:

####

# There are two rules:
# The first is to buy when the price crosses above the SMA
stratFaber <- add.rule(stratFaber, name='ruleSignal', arguments =
list(sigcol="Cl.gt.SMA", sigval=TRUE, orderqty=1000, ordertype='market',
orderside='long', pricemethod='market',TxnFees=-5), type='enter',
path.dep=TRUE)
# The second is to sell when the price crosses below the SMA
stratFaber <- add.rule(stratFaber, name='ruleSignal', arguments =
list(sigcol="Cl.lt.SMA", sigval=TRUE, orderqty='all', ordertype='market',
orderside='long', pricemethod='market',TxnFees=-5), type='exit',
path.dep=TRUE)

####

Thanks for reporting the bug.  It is fixed in SVN r393 (quantstrat) and
r394 (blotter).  It is available either from SVN now, or should be
available as binaries on R-Forge tomorrow.

Thanks for the detailed report, it made replicating the bug much easier.

Regards,

    - Brian

On Sun, 12 Sep 2010 12:22:36 +0200, Andre Barroso
<andre.barroso at gmail.com>
wrote:
orderqty=1000,ordertype='market',
orderqty=1000,ordertype='market',
it
I