[R-SIG-Finance] addTxns addfees
G See
gsee000 at gmail.com
Thu Jul 5 01:15:31 CEST 2012
Hi Hideyoshi,
addTxn is not vectorized, and it does not have a txnData argument. To
see how the function is intended to be used, please read
?addTxn
Then look at the demos that are included with blotter as well as the
examples in ?blotter.
HTH,
Garrett
On Wed, Jul 4, 2012 at 5:46 PM, Hideyoshi Maeda
<hideyoshi.maeda at gmail.com> wrote:
> If an example is required
>
> Here is an example:
>
> rm(list=ls(pos=.blotter),pos=.blotter)
> rm(list=ls(pos=.instrument),pos=.instrument)
> rm(list=ls(pos=.strategy),pos=.strategy)
>
> currency('USD')
> stock("SPY", currency="USD", mulitplier=1)
>
> getSymbols('SPY', from='2012-03-01', to='2012-07-04')
>
> portf.name <- "dummy.Portfolio"
>
> initPortf(portf.name, 'SPY', initDate='2012-02-29')
> initAcct(portf.name, portf.name, initDate='2012-02-29', initEq=1e6)
>
> qty <- rep(c(1,-1), nrow(SPY)/2)
> price <- SPY[,4]
> txnfees <- rep(-5, nrow(SPY))
> txndata <- cbind(qty, price, txnfees)
> colnames(txndata) <- c("Quantity","Price","txnfees")
>
> blotter:::addTxns(Portfolio=portf.name, Symbol='SPY', TxnData=txndata )
>
> txns <- getTxns(Portfolio=portf.name, Symbol='SPY')
>
> head(txns)
> This will show the buying and selling of 1 share on alternate days at the close but will not show any of the fees relating to each transaction.
>
> Thanks
>
> HLM
>
> On 5 Jul 2012, at 01:48, Hideyoshi Maeda wrote:
>
>> Hi I am looking at the addTxns function in blotter, and I would like to add fees data/information in the TxnData argument (as a column).
>>
>> When looking at the function, by running
>>
>> blotter:::addTxns
>> it seems to use the column names "Price" and "Quantity" but automatically sets/assigns the TxnFees to zero.
>>
>> Is there a way of overwriting this, so that it can be included in my analysis?
>>
More information about the R-SIG-Finance
mailing list