Made an example using a basic autoregressive process (lags chosen by Yule Walker equations). This is a proof of concept to show how to build a basic AR process that acts as a way to predict the market, I created a spread between model prediction and market. When the market shifts away from the “smoothed […]

Quantstrat version of a reddit post: http://www.reddit.com/r/algotrading/comments/wrblb/not_enough_code_on_this_sub_check_out_my_first/ Two rules: 1. Buy when SMA(10) > SMA(100) 2. Hold Cash Otherwise *** THIS IS NOT INVESTMENT ADVICE, I AM NOT YOUR BROKER, ADVISOR, FUND MANAGER OR HAVE ANY DUTY OF CARE, FIDUCIARY DUTY OR ANYTHING SIMILAR. I AM NOT LIABLE FOR ANY LOSSES *** As always Credit […]

Whipped up something quick to test if stock X follows a random walk… GOOG apparently does not. #load libraries library(quantmod) library(vrtest) # get Data replace goog with your stock of choice symbol = “GOOG” currency(“USD”) stock(symbol, currency=”USD”, multiplier = 1) getSymbols(symbol,src=”yahoo”) #make returns rets<-ROC(Cl(GOOG)) #get rid of the NA for the first term rets2<-rets[2:length(rets)] #Variance […]

I have made an update with getSymbols, so you can test out basic strategies, as always this is NOT investment advice and should not be used in implementation (don’t be crazy!).This is for demonstration purposes only!. This is long short, I used a basic indicator, N period moving average of the return, when it is […]

Gives a funny looking equity curve, this is for demonstration purposes only and to get your feet wet with quanstrat. If you have any issues/comments/tips/errors feel free to leave a comment or contact me. Try it yourself on some stocks and and tell me what results you get.     *I am not your investmentĀ adviser, […]