Comments for rbresearch https://rbresearch.wordpress.com Quantitative research, trading strategy ideas, and backtesting for the FX and equity markets Tue, 24 Sep 2013 21:06:56 +0000 hourly 1 http://wordpress.com/ Comment on Momentum in R: Part 2 by Ilya https://rbresearch.wordpress.com/2012/10/20/momentum-in-r-part-2/#comment-312 Tue, 24 Sep 2013 21:06:56 +0000 http://rbresearch.wordpress.com/?p=105#comment-312 In reply to Sandor.

getSymbols has an argument for adjusting the data. Also, if you’d like to do things manually, I suppose you can just divide the close by the adjusted close of the first time period, then divide the rest of the data by that same number.

]]>
Comment on Momentum in R: Part 4 with Quantstrat by rbresearch https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-304 Mon, 17 Jun 2013 15:25:28 +0000 http://rbresearch.wordpress.com/?p=120#comment-304 In reply to Aaron.

Hi Aaron,

The monthlyPrices() function as well as a few other functions in that post are on my github repo and you can access that here: https://github.com/rbresearch/Ranking

That should take care of the error you were getting, let me know if you have any other questions.

Ross

]]>
Comment on Momentum in R: Part 4 with Quantstrat by Aaron https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-303 Sun, 16 Jun 2013 10:35:39 +0000 http://rbresearch.wordpress.com/?p=120#comment-303 I’m getting the following error in the very first part that is preventing me from proceeding:

> symbols.close <- monthlyPrices(symbols)
Error: could not find function "monthlyPrices"

All the prior code works fine.

]]>
Comment on Momentum in R: Part 4 with Quantstrat by daniel https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-287 Thu, 28 Feb 2013 09:16:43 +0000 http://rbresearch.wordpress.com/?p=120#comment-287 In reply to rbresearch.

Ok Ross, I didn’t know about getTxns() function. Now it’s clear. Thank you very much for the support and congratulations again for this impressive job!
Best regards.

]]>
Comment on Momentum in R: Part 4 with Quantstrat by rbresearch https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-286 Thu, 28 Feb 2013 03:35:34 +0000 http://rbresearch.wordpress.com/?p=120#comment-286 In reply to daniel.

Hi Daniel,

Great question, I am glad to see you have been exploring this in detail.

Let us look at XLE.
> tail(XLE)
XLE.Open XLE.High XLE.Low XLE.Close XLE.Volume XLE.Adjusted XLE.Rank
2012-07-31 66.37 70.68 64.64 69.65 291007200 68.99 4
2012-08-31 69.91 73.03 68.16 71.53 212709700 70.85 5
2012-09-30 71.46 77.35 70.40 73.43 206863800 73.06 1
2012-10-31 73.94 75.19 71.02 71.94 236902800 71.58 1
2012-11-30 71.66 73.06 67.77 71.06 234855900 70.70 2
2012-12-31 71.60 73.39 69.57 71.42 198245000 71.42 3

We would expect a signal to be generated on 2012-09-30 to buy XLE at 73.43.

> tail(getOrderBook("Rank")$Rank$XLE)[,1:2]
Order.Qty Order.Price
2012-05-30 19:00:08 "all" "63.63"
2012-06-29 19:00:08 "all" "66.37"
2012-07-30 19:00:08 "all" "69.65"
2012-08-30 19:00:08 "all" "71.53"
2012-09-29 19:00:08 "1000" "73.43"
2012-12-30 18:00:08 "all" "71.42"

That makes sense and we see an order for 1000 shares at 73.43. That doesn’t mean the trade was executed at that price. What was it actually executed at? You can look at what is printed from applyStrategy or get the transactions with getTxns.
> tail(getTxns("Rank", "XLE"))[,1:2]
Txn.Qty Txn.Price
2009-11-29 18:00:08 -1000 57.01
2010-10-30 19:00:08 1000 62.71
2011-06-29 19:00:08 -1000 76.45
2011-11-29 18:00:08 1000 69.13
2011-12-30 18:00:08 -1000 70.69
2012-09-29 19:00:08 1000 71.94

We can see here that the trade is actually executed at 71.94, the closing price of next month. So there is a lag of one month before the trade is executed.

]]>
Comment on Momentum in R: Part 4 with Quantstrat by daniel https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-285 Wed, 27 Feb 2013 11:00:23 +0000 http://rbresearch.wordpress.com/?p=120#comment-285 Hi Ross,

I’m checking the symbol.rank given for the AGG symbol (for instance), and the order execution of the order book, and it seems that there is a look ahead bias in the strategy execution. You haven’t apply any lag to the symbol.rank signals. I enclose you what can be found in the documentation:

Default behaviour of appplyStrategy:
=> for monthly, quarterly and yearly data, quantstrat will use the current bar to get the price.
=> for anything with a higher frequency (eg. weekly, daily, intraday), quantstrat will use the next bar to get the price.”

Did you have this into account?

Thx and best regards
Daniel

]]>
Comment on Momentum in R: Part 4 with Quantstrat by daniel https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-283 Tue, 26 Feb 2013 08:41:50 +0000 http://rbresearch.wordpress.com/?p=120#comment-283 In reply to rbresearch.

Ok Ross,

I see what you mean, thank you very much!

]]>
Comment on Momentum in R: Part 4 with Quantstrat by rbresearch https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-282 Tue, 26 Feb 2013 01:13:11 +0000 http://rbresearch.wordpress.com/?p=120#comment-282 In reply to daniel.

Hi Daniel,

The backtest in part 3 is simplified and just uses the 1 period simple returns on the overall return calculation. Using quantstrat, the returns are based on actual transactions (e.g. buy 1000 shares of IVV at 141.88). This is the reason why the backtest statistics are different.

]]>
Comment on Momentum in R: Part 4 with Quantstrat by daniel https://rbresearch.wordpress.com/2013/02/19/momentum-in-r-part-4-with-quantstrat/#comment-280 Mon, 25 Feb 2013 19:36:10 +0000 http://rbresearch.wordpress.com/?p=120#comment-280 Hi Ross,

I haven’t had much time to work with the quantstrat package, but it seems that the quantstrtat version of your strategy provides different stadistics than the plain version (Momentum in R: Part 3). Using the same lookback periods (6,9,12) with ave3ROC function, and selecting the top 4 best assets, the quantstrat version underperform the plain versión. Surely I missing sth. Any thoughts?

Thx in advance

Daniel

]]>
Comment on Momentum with R: Part 1 by daniel https://rbresearch.wordpress.com/2012/08/23/momentum-with-r-part-1/#comment-279 Mon, 25 Feb 2013 19:22:02 +0000 http://rbresearch.wordpress.com/?p=101#comment-279 In reply to rbresearch.

Thx Ross!

Really impressive job with these posts!! Congratulations!

Regards

Daniel

]]>