[R-SIG-Finance] addTxns addfees
G See
gsee000 at gmail.com
Thu Jul 5 01:29:48 CEST 2012
My apologies. I see what you are talking about, and I see where that
is hardcoded in. So, you would need to replace
TxnFee <- 0
with
TxnFee <- as.numeric(TxnData[row, "txnfees"])
On Wed, Jul 4, 2012 at 6:24 PM, Hideyoshi Maeda
<hideyoshi.maeda at gmail.com> wrote:
> Thanks for your response.
>
> I am aware that addTxn is not vectorized...
>
> but what I am using below is addTxns...(note the 's' after Txn)
>
> This allows transaction data through the TxnData argument
>
> It is, in effect, a vectorised version of addTxn...even the blotter demo from
>
> demo(amzn_test)
>
> uses this....
>
> However unlike the demo...i wanted to include Transaction fees, and wanted to know if this was possible...as the function for addTxns automatically assigns this to zero...
>
>
>
> On 5 Jul 2012, at 09:15, G See wrote:
>
>> 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