[R-SIG-Finance] quantstrat - model transactions on specific dates

Mark Knecht markknecht at gmail.com
Thu Oct 9 23:00:27 CEST 2014


On Thu, Oct 9, 2014 at 1:35 PM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
> On Thu, Oct 9, 2014 at 3:31 PM, Brian G. Peterson <brian at braverock.com> wrote:
>> On 10/09/2014 03:05 PM, Mark Knecht wrote:
>>>
>>>     I would like to do something in quantstrat like set up an initial
>>> buy for all symbols in a portfolio on a certain date. To that end I
>>> want a signal column that says the date is matching my buy date and
>>> then I'l execute a specific rule. However signals need to match
>>> columns which led me to wanting the index in a column as a value. To
>>> that end the code below basically does this but returns  a numerical
>>> value which (I think) is referenced to 1970-01-01.
>>
>> It seems to me that the simplest thing would be to just establish your
>> initial portfolio.
>>
>> Initialize the portfolio, then construct a data.frame for the txnData
>> argument of addTxns.
>>
>> Call addTxns before calling applyStrategy.
>>
>> Alternately, you could modify sigFlatten to essentially do the opposite, and
>> initiate on a certain time.
>>
> You're thinking of sigTimestamp (which was based on sigFlatten, but
> I'm not sure was ever made public).  Mark, I think sigTimestamp is
> what you're looking for.
>
>> Regards,
>>
>> Brian
>>


Brian & Joshua,
   Thanks. I'll investigate them both.

   Longer term though I think my general question may still come up.
I've been looking at rebalancing at the portfolio level. Best I can
tell the applyStrategy.rebalance function rebalances individual stocks
based on the last entry date of that stock but not, for instance, on a
specific date like the a calendar quarter. (I wasn't going to post
this all right now until I was really sure so don't take this too
seriously.) Anyway I want to write something like what Faber &
Richardson wrote about in 'The Ivy Portfolio' where the whole
portfolio is rebalanced on a given date, like end-of-month,
independent of whether I'm using the 10 month SMA or not. For that
reason I figured I might need a way to match indexes to dates going
though time.

   Anyway, enough for now. Thanks for all your help guys!

Cheers,
Mark



More information about the R-SIG-Finance mailing list